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

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

revision 838 by stargo, Tue Mar 8 12:29:19 2005 UTC revision 840 by stargo, Tue Mar 8 17:03:08 2005 UTC
# Line 27  Line 27 
27  #include <ao/ao.h>  #include <ao/ao.h>
28    
29  #define MAX_QUEUE       10  #define MAX_QUEUE       10
30  #define WAVEOUTBUF      32  #define WAVEOUTBUF      64
31    
32  int g_dsp_fd;  int g_dsp_fd;
33  ao_device *o_device = NULL;  ao_device *o_device = NULL;
34  int default_driver;  int default_driver;
35  int g_samplerate;  int g_samplerate;
36    int g_channels;
37  BOOL g_dsp_busy = False;  BOOL g_dsp_busy = False;
38  static short g_samplewidth;  static short g_samplewidth;
39    
# Line 54  wave_out_open(void) Line 55  wave_out_open(void)
55    
56          format.bits = 16;          format.bits = 16;
57          format.channels = 2;          format.channels = 2;
58            g_channels = 2;
59          format.rate = 44100;          format.rate = 44100;
60          g_samplerate = 44100;          g_samplerate = 44100;
61          format.byte_format = AO_FMT_LITTLE;          format.byte_format = AO_FMT_LITTLE;
# Line 111  wave_out_set_format(WAVEFORMATEX * pwfx) Line 113  wave_out_set_format(WAVEFORMATEX * pwfx)
113    
114          format.bits = pwfx->wBitsPerSample;          format.bits = pwfx->wBitsPerSample;
115          format.channels = pwfx->nChannels;          format.channels = pwfx->nChannels;
116            g_channels = pwfx->nChannels;
117          format.rate = 44100;          format.rate = 44100;
118          g_samplerate = pwfx->nSamplesPerSec;          g_samplerate = pwfx->nSamplesPerSec;
119          format.byte_format = AO_FMT_LITTLE;          format.byte_format = AO_FMT_LITTLE;
# Line 184  wave_out_play(void) Line 187  wave_out_play(void)
187          if (g_samplerate == 22050)          if (g_samplerate == 22050)
188          {          {
189                  /* Resample to 44100 */                  /* Resample to 44100 */
190                  for (i = 0; (i < ((WAVEOUTBUF / 8) * (3 - g_samplewidth))) && (out->p < out->end);                  for (i = 0; (i < ((WAVEOUTBUF / 4) * (3 - g_samplewidth))) && (out->p < out->end);
191                       i++)                       i++)
192                  {                  {
193                          offset = i * 4 * g_samplewidth;                          if (g_channels == 2)
194                          memcpy(&outbuf[0 * g_samplewidth + offset], out->p, g_samplewidth);                                  offset = ((i * 2) - (i & 1)) * g_samplewidth;
195                          memcpy(&outbuf[2 * g_samplewidth + offset], out->p, g_samplewidth);                          else
196                          out->p += 2;                                  offset = (i * 2) * g_samplewidth;
197    
198                          memcpy(&outbuf[1 * g_samplewidth + offset], out->p, g_samplewidth);                          memcpy(&outbuf[offset], out->p, g_samplewidth);
199                          memcpy(&outbuf[3 * g_samplewidth + offset], out->p, g_samplewidth);                          memcpy(&outbuf[g_channels * g_samplewidth + offset], out->p, g_samplewidth);
200                          out->p += 2;                          out->p += 2;
201                          len += 4 * g_samplewidth;  
202                            len += 2 * g_samplewidth;
203                  }                  }
204          }          }
205          else          else

Legend:
Removed from v.838  
changed lines
  Added in v.840

  ViewVC Help
Powered by ViewVC 1.1.26