/[rdesktop]/sourceforge.net/trunk/rdesktop/rdpsnd_libao.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_libao.c

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

revision 1045 by stargo, Wed Feb 8 13:35:35 2006 UTC revision 1245 by stargo, Sun Jul 9 23:41:07 2006 UTC
# Line 31  Line 31 
31  #define WAVEOUTBUF      16  #define WAVEOUTBUF      16
32    
33  int g_dsp_fd;  int g_dsp_fd;
 ao_device *o_device = NULL;  
 int default_driver;  
 int g_samplerate;  
 int g_channels;  
34  BOOL g_dsp_busy = False;  BOOL g_dsp_busy = False;
35  static BOOL g_reopened;  static ao_device *o_device = NULL;
36  static short g_samplewidth;  static int default_driver;
37    static int samplerate;
38    static int audiochannels;
39    static BOOL reopened;
40    static short samplewidth;
41    
42  static struct audio_packet  static struct audio_packet
43  {  {
# Line 57  wave_out_open(void) Line 57  wave_out_open(void)
57    
58          format.bits = 16;          format.bits = 16;
59          format.channels = 2;          format.channels = 2;
60          g_channels = 2;          audiochannels = 2;
61          format.rate = 44100;          format.rate = 44100;
62          g_samplerate = 44100;          samplerate = 44100;
63          format.byte_format = AO_FMT_LITTLE;          format.byte_format = AO_FMT_LITTLE;
64    
65          o_device = ao_open_live(default_driver, &format, NULL);          o_device = ao_open_live(default_driver, &format, NULL);
# Line 71  wave_out_open(void) Line 71  wave_out_open(void)
71          g_dsp_fd = 0;          g_dsp_fd = 0;
72          queue_lo = queue_hi = 0;          queue_lo = queue_hi = 0;
73    
74          g_reopened = True;          reopened = True;
75    
76          return True;          return True;
77  }  }
# Line 117  wave_out_set_format(WAVEFORMATEX * pwfx) Line 117  wave_out_set_format(WAVEFORMATEX * pwfx)
117    
118          format.bits = pwfx->wBitsPerSample;          format.bits = pwfx->wBitsPerSample;
119          format.channels = pwfx->nChannels;          format.channels = pwfx->nChannels;
120          g_channels = pwfx->nChannels;          audiochannels = pwfx->nChannels;
121          format.rate = 44100;          format.rate = 44100;
122          g_samplerate = pwfx->nSamplesPerSec;          samplerate = pwfx->nSamplesPerSec;
123          format.byte_format = AO_FMT_LITTLE;          format.byte_format = AO_FMT_LITTLE;
124    
125          g_samplewidth = pwfx->wBitsPerSample / 8;          samplewidth = pwfx->wBitsPerSample / 8;
126    
127          if (o_device != NULL)          if (o_device != NULL)
128                  ao_close(o_device);                  ao_close(o_device);
# Line 133  wave_out_set_format(WAVEFORMATEX * pwfx) Line 133  wave_out_set_format(WAVEFORMATEX * pwfx)
133                  return False;                  return False;
134          }          }
135    
136          g_reopened = True;          reopened = True;
137    
138          return True;          return True;
139  }  }
# Line 182  wave_out_play(void) Line 182  wave_out_play(void)
182          struct timeval tv;          struct timeval tv;
183          int next_tick;          int next_tick;
184    
185          if (g_reopened)          if (reopened)
186          {          {
187                  g_reopened = False;                  reopened = False;
188                  gettimeofday(&tv, NULL);                  gettimeofday(&tv, NULL);
189                  prev_s = tv.tv_sec;                  prev_s = tv.tv_sec;
190                  prev_us = tv.tv_usec;                  prev_us = tv.tv_usec;
# Line 210  wave_out_play(void) Line 210  wave_out_play(void)
210    
211          len = 0;          len = 0;
212    
213          if (g_samplerate == 22050)          if (samplerate == 22050)
214          {          {
215                  /* Resample to 44100 */                  /* Resample to 44100 */
216                  for (i = 0; (i < ((WAVEOUTBUF / 4) * (3 - g_samplewidth))) && (out->p < out->end);                  for (i = 0; (i < ((WAVEOUTBUF / 4) * (3 - samplewidth))) && (out->p < out->end);
217                       i++)                       i++)
218                  {                  {
219                          /* On a stereo-channel we must make sure that left and right                          /* On a stereo-channel we must make sure that left and right
# Line 221  wave_out_play(void) Line 221  wave_out_play(void)
221                             data with channels in mind: 1234 -> 12123434                             data with channels in mind: 1234 -> 12123434
222                             If we have a mono-channel, we can expand the data by simply                             If we have a mono-channel, we can expand the data by simply
223                             doubling the sample-data: 1234 -> 11223344 */                             doubling the sample-data: 1234 -> 11223344 */
224                          if (g_channels == 2)                          if (audiochannels == 2)
225                                  offset = ((i * 2) - (i & 1)) * g_samplewidth;                                  offset = ((i * 2) - (i & 1)) * samplewidth;
226                          else                          else
227                                  offset = (i * 2) * g_samplewidth;                                  offset = (i * 2) * samplewidth;
228    
229                          memcpy(&outbuf[offset], out->p, g_samplewidth);                          memcpy(&outbuf[offset], out->p, samplewidth);
230                          memcpy(&outbuf[g_channels * g_samplewidth + offset], out->p, g_samplewidth);                          memcpy(&outbuf[audiochannels * samplewidth + offset], out->p, samplewidth);
231    
232                          out->p += g_samplewidth;                          out->p += samplewidth;
233                          len += 2 * g_samplewidth;                          len += 2 * samplewidth;
234                  }                  }
235          }          }
236          else          else

Legend:
Removed from v.1045  
changed lines
  Added in v.1245

  ViewVC Help
Powered by ViewVC 1.1.26