/[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 476 by matthewc, Sat Oct 4 00:03:24 2003 UTC revision 509 by stargo, Wed Oct 22 12:16:03 2003 UTC
# Line 29  Line 29 
29  #define MAX_QUEUE       10  #define MAX_QUEUE       10
30    
31  int g_dsp_fd;  int g_dsp_fd;
32  BOOL g_dsp_busy;  BOOL g_dsp_busy = False;
33    
34  static struct audio_packet {  static struct audio_packet
35    {
36          struct stream s;          struct stream s;
37          uint16 tick;          uint16 tick;
38          uint8 index;          uint8 index;
# Line 43  wave_out_open(void) Line 44  wave_out_open(void)
44  {  {
45          char *dsp_dev = "/dev/dsp";          char *dsp_dev = "/dev/dsp";
46    
47          if ((g_dsp_fd = open(dsp_dev, O_WRONLY)) == -1)          if ((g_dsp_fd = open(dsp_dev, O_WRONLY | O_NONBLOCK)) == -1)
48          {          {
49                  perror(dsp_dev);                  perror(dsp_dev);
50                  return False;                  return False;
51          }          }
52    
53          /* Non-blocking so that user interface is responsive */          /* Non-blocking so that user interface is responsive */
54          fcntl(g_dsp_fd, F_SETFL, fcntl(g_dsp_fd, F_GETFL)|O_NONBLOCK);          fcntl(g_dsp_fd, F_SETFL, fcntl(g_dsp_fd, F_GETFL) | O_NONBLOCK);
55          return True;          return True;
56  }  }
57    
# Line 61  wave_out_close(void) Line 62  wave_out_close(void)
62  }  }
63    
64  BOOL  BOOL
65  wave_out_format_supported(WAVEFORMATEX *pwfx)  wave_out_format_supported(WAVEFORMATEX * pwfx)
66  {  {
67          if (pwfx->wFormatTag != WAVE_FORMAT_PCM)          if (pwfx->wFormatTag != WAVE_FORMAT_PCM)
68                  return False;                  return False;
# Line 74  wave_out_format_supported(WAVEFORMATEX * Line 75  wave_out_format_supported(WAVEFORMATEX *
75  }  }
76    
77  BOOL  BOOL
78  wave_out_set_format(WAVEFORMATEX *pwfx)  wave_out_set_format(WAVEFORMATEX * pwfx)
79  {  {
80          int speed, channels, format;          int speed, channels, format;
81    
# Line 113  wave_out_set_format(WAVEFORMATEX *pwfx) Line 114  wave_out_set_format(WAVEFORMATEX *pwfx)
114  }  }
115    
116  void  void
117    wave_out_volume(uint16 left, uint16 right)
118    {
119            static BOOL use_dev_mixer = False;
120            uint32 volume;
121            int fd_mix = -1;
122    
123            volume = left / (65536 / 100);
124            volume |= right / (65536 / 100) << 8;
125    
126            if (use_dev_mixer)
127            {
128                    if ((fd_mix = open( "/dev/mixer", O_RDWR|O_NONBLOCK )) == -1 )
129                    {
130                            perror("open /dev/mixer");
131                            return;
132                    }
133    
134                    if (ioctl(fd_mix, MIXER_WRITE(SOUND_MIXER_PCM), &volume) == -1)
135                    {
136                            perror("MIXER_WRITE(SOUND_MIXER_PCM)");
137                            return;
138                    }
139    
140                    close(fd_mix);
141            }
142    
143            if (ioctl(g_dsp_fd, MIXER_WRITE(SOUND_MIXER_PCM), &volume) == -1)
144            {
145                    perror("MIXER_WRITE(SOUND_MIXER_PCM)");
146                    use_dev_mixer = True;
147                    return;
148            }
149    }
150    
151    void
152  wave_out_write(STREAM s, uint16 tick, uint8 index)  wave_out_write(STREAM s, uint16 tick, uint8 index)
153  {  {
154          struct audio_packet *packet = &packet_queue[queue_hi];          struct audio_packet *packet = &packet_queue[queue_hi];
# Line 129  wave_out_write(STREAM s, uint16 tick, ui Line 165  wave_out_write(STREAM s, uint16 tick, ui
165          packet->s = *s;          packet->s = *s;
166          packet->tick = tick;          packet->tick = tick;
167          packet->index = index;          packet->index = index;
168            packet->s.p += 4;
169    
170          /* we steal the data buffer from s, give it a new one */          /* we steal the data buffer from s, give it a new one */
171          s->data = malloc(s->size);          s->data = malloc(s->size);
# Line 155  wave_out_play(void) Line 192  wave_out_play(void)
192                  packet = &packet_queue[queue_lo];                  packet = &packet_queue[queue_lo];
193                  out = &packet->s;                  out = &packet->s;
194    
195                  len = write(g_dsp_fd, out->p, out->end-out->p);                  len = write(g_dsp_fd, out->p, out->end - out->p);
196                  if (len == -1)                  if (len == -1)
197                  {                  {
198                          if (errno != EWOULDBLOCK)                          if (errno != EWOULDBLOCK)

Legend:
Removed from v.476  
changed lines
  Added in v.509

  ViewVC Help
Powered by ViewVC 1.1.26