CVS: rdesktop rdpsnd_libao.c,1.1,1.2
Michael Gernoth <[email protected]>
| Newsgroups | gmane.network.rdesktop.cvs |
|---|---|
| Message-ID | <[email protected]> |
Update of /cvsroot/rdesktop/rdesktop
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31885
Modified Files:
rdpsnd_libao.c
Log Message:
add initial support for multiple windows samplerates
Index: rdpsnd_libao.c
===================================================================
RCS file: /cvsroot/rdesktop/rdesktop/rdpsnd_libao.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** rdpsnd_libao.c 8 Mar 2005 03:33:35 -0000 1.1
--- rdpsnd_libao.c 8 Mar 2005 04:25:12 -0000 1.2
***************
*** 32,35 ****
--- 32,36 ----
ao_device *o_device = NULL;
int default_driver;
+ int g_samplerate;
BOOL g_dsp_busy = False;
static short g_samplewidth;
***************
*** 54,57 ****
--- 55,59 ----
format.channels = 2;
format.rate = 44100;
+ g_samplerate = 44100;
format.byte_format = AO_FMT_LITTLE;
***************
*** 94,100 ****
return False;
/* The only common denominator between libao output drivers is a sample-rate of
! 44100, windows gives a max of 22050. we need to upsample that...
! TODO: support 11025, too */
! if (pwfx->nSamplesPerSec != 22050)
return False;
--- 96,101 ----
return False;
/* The only common denominator between libao output drivers is a sample-rate of
! 44100, we need to upsample 22050 to it */
! if ((pwfx->nSamplesPerSec != 44100) && (pwfx->nSamplesPerSec != 22050))
return False;
***************
*** 107,114 ****
ao_sample_format format;
- printf("%d\n",pwfx->wBitsPerSample);
format.bits = pwfx->wBitsPerSample;
format.channels = pwfx->nChannels;
format.rate = 44100;
format.byte_format = AO_FMT_LITTLE;
--- 108,115 ----
ao_sample_format format;
format.bits = pwfx->wBitsPerSample;
format.channels = pwfx->nChannels;
format.rate = 44100;
+ g_samplerate = pwfx->nSamplesPerSec;
format.byte_format = AO_FMT_LITTLE;
***************
*** 164,200 ****
struct audio_packet *packet;
STREAM out;
! unsigned char expanded[8];
! while (1)
{
! if (queue_lo == queue_hi)
! {
! g_dsp_busy = 0;
! return;
! }
!
! packet = &packet_queue[queue_lo];
! out = &packet->s;
! /* Resample 22050 -> 44100 */
! /* TODO: Do this for 11025, too... */
! memcpy(&expanded[0],out->p,g_samplewidth);
! memcpy(&expanded[2*g_samplewidth],out->p,g_samplewidth);
! out->p += 2;
! memcpy(&expanded[1*g_samplewidth],out->p,g_samplewidth);
! memcpy(&expanded[3*g_samplewidth],out->p,g_samplewidth);
! out->p += 2;
! ao_play(o_device, expanded, g_samplewidth*4);
! if (out->p == out->end)
{
! rdpsnd_send_completion(packet->tick, packet->index);
! free(out->data);
! queue_lo = (queue_lo + 1) % MAX_QUEUE;
! } else {
! g_dsp_busy = 1;
! return;
}
}
}
--- 165,215 ----
struct audio_packet *packet;
STREAM out;
! unsigned char expanded[16];
! int offset,len,i;
! if (queue_lo == queue_hi)
{
! g_dsp_busy = 0;
! return;
! }
! packet = &packet_queue[queue_lo];
! out = &packet->s;
! len = 0;
! if (g_samplerate == 22050 )
! {
! /* Resample to 44100 */
! for(i=0; (i<(2*(3-g_samplewidth))) && (out->p < out->end); i++)
{
! offset=i*4*g_samplewidth;
! memcpy(&expanded[0*g_samplewidth+offset],out->p,g_samplewidth);
! memcpy(&expanded[2*g_samplewidth+offset],out->p,g_samplewidth);
! out->p += 2;
!
! memcpy(&expanded[1*g_samplewidth+offset],out->p,g_samplewidth);
! memcpy(&expanded[3*g_samplewidth+offset],out->p,g_samplewidth);
! out->p += 2;
! len += 4*g_samplewidth;
}
}
+ else
+ {
+ len = (16 > (out->end - out->p)) ? (out->end - out->p) : 16;
+ memcpy(expanded,out->p,len);
+ out->p += len;
+ }
+
+ ao_play(o_device, expanded, len);
+
+ if (out->p == out->end)
+ {
+ rdpsnd_send_completion(packet->tick, packet->index);
+ free(out->data);
+ queue_lo = (queue_lo + 1) % MAX_QUEUE;
+ }
+
+ g_dsp_busy = 1;
+ return;
}
-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click