only resample when there is need

git-svn-id: svn://svn.code.sf.net/p/rdesktop/code/trunk/rdesktop@1276 423420c4-83ab-492f-b58f-81f9feb106b5
This commit is contained in:
Michael Gernoth 2006-10-01 12:26:01 +00:00
parent b7b4327927
commit 8f8ea57234

View File

@ -159,9 +159,13 @@ rdpsnd_dsp_resample(unsigned char **out, unsigned char *in, unsigned int size,
int samplewidth = format->wBitsPerSample / 8; int samplewidth = format->wBitsPerSample / 8;
int i; int i;
if ((resample_to_bitspersample == format->wBitsPerSample) &&
(resample_to_channels == format->nChannels) &&
(resample_to_srate == format->nSamplesPerSec))
return 0;
if ((resample_to_bitspersample != format->wBitsPerSample) || if ((resample_to_bitspersample != format->wBitsPerSample) ||
(resample_to_channels != format->nChannels) || (resample_to_channels != format->nChannels) || (format->nSamplesPerSec != 22050))
((format->nSamplesPerSec != 44100) && (format->nSamplesPerSec != 22050)))
{ {
if (!warned) if (!warned)
{ {
@ -172,12 +176,10 @@ rdpsnd_dsp_resample(unsigned char **out, unsigned char *in, unsigned int size,
return 0; return 0;
} }
if (format->nSamplesPerSec == 22050)
{
outsize = size * 2; outsize = size * 2;
*out = xmalloc(outsize); *out = xmalloc(outsize);
/* Resample to 44100 */ /* Resample from 22050 to 44100 */
for (i = 0; i < (size / samplewidth); i++) for (i = 0; i < (size / samplewidth); i++)
{ {
/* On a stereo-channel we must make sure that left and right /* On a stereo-channel we must make sure that left and right
@ -195,11 +197,6 @@ rdpsnd_dsp_resample(unsigned char **out, unsigned char *in, unsigned int size,
in + (i * samplewidth), samplewidth); in + (i * samplewidth), samplewidth);
} }
}
else
{
outsize = 0;
}
return outsize; return outsize;
} }
@ -222,9 +219,7 @@ rdpsnd_dsp_process(STREAM s, struct audio_driver * current_driver, WAVEFORMATEX
out.data = NULL; out.data = NULL;
if (current_driver->wave_out_format_supported == rdpsnd_dsp_resample_supported) if (current_driver->wave_out_format_supported == rdpsnd_dsp_resample_supported)
{
out.size = rdpsnd_dsp_resample(&out.data, s->data, s->size, format); out.size = rdpsnd_dsp_resample(&out.data, s->data, s->size, format);
}
if (out.data == NULL) if (out.data == NULL)
{ {