/[rdesktop]/sourceforge.net/trunk/rdesktop/rdpsnd_oss.c
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /sourceforge.net/trunk/rdesktop/rdpsnd_oss.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1247 by stargo, Wed Jul 12 09:57:05 2006 UTC revision 1254 by stargo, Sun Sep 17 10:32:18 2006 UTC
# Line 28  Line 28 
28  #endif  #endif
29    
30  #include "rdesktop.h"  #include "rdesktop.h"
31    #include "rdpsnd.h"
32  #include <unistd.h>  #include <unistd.h>
33  #include <fcntl.h>  #include <fcntl.h>
34  #include <errno.h>  #include <errno.h>
# Line 35  Line 36 
36  #include <sys/ioctl.h>  #include <sys/ioctl.h>
37  #include <sys/soundcard.h>  #include <sys/soundcard.h>
38    
39    #define DEFAULTDEVICE   "/dev/dsp"
40  #define MAX_LEN         512  #define MAX_LEN         512
 #define MAX_QUEUE       10  
41    
 int g_dsp_fd;  
 BOOL g_dsp_busy = False;  
42  static int snd_rate;  static int snd_rate;
43  static short samplewidth;  static short samplewidth;
44    
 static struct audio_packet  
 {  
         struct stream s;  
         uint16 tick;  
         uint8 index;  
 } packet_queue[MAX_QUEUE];  
 static unsigned int queue_hi, queue_lo;  
   
45  BOOL  BOOL
46  wave_out_open(void)  wave_out_open(void)
47  {  {
# Line 58  wave_out_open(void) Line 49  wave_out_open(void)
49    
50          if (dsp_dev == NULL)          if (dsp_dev == NULL)
51          {          {
52                  dsp_dev = xstrdup("/dev/dsp");                  dsp_dev = xstrdup(DEFAULTDEVICE);
53          }          }
54    
55          if ((g_dsp_fd = open(dsp_dev, O_WRONLY)) == -1)          if ((g_dsp_fd = open(dsp_dev, O_WRONLY)) == -1)
# Line 201  wave_out_volume(uint16 left, uint16 righ Line 192  wave_out_volume(uint16 left, uint16 righ
192  }  }
193    
194  void  void
 wave_out_write(STREAM s, uint16 tick, uint8 index)  
 {  
         struct audio_packet *packet = &packet_queue[queue_hi];  
         unsigned int next_hi = (queue_hi + 1) % MAX_QUEUE;  
   
         if (next_hi == queue_lo)  
         {  
                 error("No space to queue audio packet\n");  
                 return;  
         }  
   
         queue_hi = next_hi;  
   
         packet->s = *s;  
         packet->tick = tick;  
         packet->index = index;  
         packet->s.p += 4;  
   
         /* we steal the data buffer from s, give it a new one */  
         s->data = (uint8 *) malloc(s->size);  
   
         if (!g_dsp_busy)  
                 wave_out_play();  
 }  
   
 void  
195  wave_out_play(void)  wave_out_play(void)
196  {  {
197          struct audio_packet *packet;          struct audio_packet *packet;
# Line 237  wave_out_play(void) Line 202  wave_out_play(void)
202          static BOOL started = False;          static BOOL started = False;
203          struct timeval tv;          struct timeval tv;
204    
205          if (queue_lo == queue_hi)          if (rdpsnd_queue_empty())
206          {          {
207                  g_dsp_busy = 0;                  g_dsp_busy = 0;
208                  return;                  return;
209          }          }
210    
211          packet = &packet_queue[queue_lo];          packet = rdpsnd_queue_current_packet();
212          out = &packet->s;          out = &packet->s;
213    
214          if (!started)          if (!started)
# Line 277  wave_out_play(void) Line 242  wave_out_play(void)
242    
243                  if (elapsed >= (duration * 85) / 100)                  if (elapsed >= (duration * 85) / 100)
244                  {                  {
245                          rdpsnd_send_completion(packet->tick, packet->index);                          /* We need to add 50 to tell windows that time has passed while
246                          free(out->data);                           * playing this packet */
247                          queue_lo = (queue_lo + 1) % MAX_QUEUE;                          rdpsnd_send_completion(packet->tick + 50, packet->index);
248                            rdpsnd_queue_next();
249                          started = False;                          started = False;
250                  }                  }
251                  else                  else

Legend:
Removed from v.1247  
changed lines
  Added in v.1254

  ViewVC Help
Powered by ViewVC 1.1.26