2006-09-17 16:41:16 +02:00
|
|
|
/*
|
|
|
|
rdesktop: A Remote Desktop Protocol client.
|
|
|
|
Sound DSP routines
|
2011-04-13 12:51:50 +02:00
|
|
|
Copyright (C) Michael Gernoth mike@zerfleddert.de 2006-2008
|
2006-09-17 16:41:16 +02:00
|
|
|
|
2010-01-12 09:31:06 +01:00
|
|
|
This program is free software: you can redistribute it and/or modify
|
2006-09-17 16:41:16 +02:00
|
|
|
it under the terms of the GNU General Public License as published by
|
2010-01-12 09:31:06 +01:00
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
2006-09-17 16:41:16 +02:00
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
2010-01-12 09:31:06 +01:00
|
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2006-09-17 16:41:16 +02:00
|
|
|
*/
|
|
|
|
|
2006-10-01 20:22:05 +02:00
|
|
|
#include <strings.h>
|
|
|
|
|
2006-09-17 16:41:16 +02:00
|
|
|
#include "rdesktop.h"
|
|
|
|
#include "rdpsnd.h"
|
|
|
|
#include "rdpsnd_dsp.h"
|
|
|
|
|
2006-10-01 15:57:34 +02:00
|
|
|
#ifdef HAVE_LIBSAMPLERATE
|
|
|
|
#include <samplerate.h>
|
|
|
|
|
|
|
|
#define SRC_CONVERTER SRC_SINC_MEDIUM_QUALITY
|
|
|
|
#endif
|
|
|
|
|
2006-09-17 16:41:16 +02:00
|
|
|
#define MAX_VOLUME 65535
|
|
|
|
|
|
|
|
static uint16 softvol_left = MAX_VOLUME;
|
|
|
|
static uint16 softvol_right = MAX_VOLUME;
|
2006-10-01 14:16:50 +02:00
|
|
|
static uint32 resample_to_srate = 44100;
|
|
|
|
static uint16 resample_to_bitspersample = 16;
|
|
|
|
static uint16 resample_to_channels = 2;
|
2006-10-01 15:57:34 +02:00
|
|
|
#ifdef HAVE_LIBSAMPLERATE
|
|
|
|
static SRC_STATE *src_converter = NULL;
|
|
|
|
#endif
|
2006-09-17 16:41:16 +02:00
|
|
|
|
|
|
|
void
|
|
|
|
rdpsnd_dsp_softvol_set(uint16 left, uint16 right)
|
|
|
|
{
|
|
|
|
softvol_left = left;
|
|
|
|
softvol_right = right;
|
|
|
|
DEBUG(("rdpsnd_dsp_softvol_set: left: %u, right: %u\n", left, right));
|
|
|
|
}
|
|
|
|
|
2006-09-17 17:25:10 +02:00
|
|
|
void
|
2007-01-04 05:55:56 +01:00
|
|
|
rdpsnd_dsp_softvol(unsigned char *buffer, unsigned int size, RD_WAVEFORMATEX * format)
|
2006-09-17 16:41:16 +02:00
|
|
|
{
|
|
|
|
unsigned int factor_left, factor_right;
|
2006-09-17 17:08:48 +02:00
|
|
|
unsigned char *posin = buffer;
|
|
|
|
unsigned char *posout = buffer;
|
|
|
|
|
|
|
|
if ((softvol_left == MAX_VOLUME) && (softvol_right == MAX_VOLUME))
|
|
|
|
return;
|
2006-09-17 16:41:16 +02:00
|
|
|
|
2006-09-18 12:20:02 +02:00
|
|
|
factor_left = (softvol_left * 256) / MAX_VOLUME;
|
|
|
|
factor_right = (softvol_right * 256) / MAX_VOLUME;
|
2006-09-17 16:41:16 +02:00
|
|
|
|
|
|
|
if (format->nChannels == 1)
|
|
|
|
{
|
|
|
|
factor_left = factor_right = (factor_left + factor_right) / 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (format->wBitsPerSample == 8)
|
|
|
|
{
|
2006-09-17 17:49:14 +02:00
|
|
|
sint8 val;
|
2006-09-17 16:41:16 +02:00
|
|
|
|
2006-09-17 17:08:48 +02:00
|
|
|
while (posout < buffer + size)
|
2006-09-17 16:41:16 +02:00
|
|
|
{
|
|
|
|
/* Left */
|
|
|
|
val = *posin++;
|
|
|
|
val = (val * factor_left) >> 8;
|
|
|
|
*posout++ = val;
|
|
|
|
|
|
|
|
/* Right */
|
|
|
|
val = *posin++;
|
|
|
|
val = (val * factor_right) >> 8;
|
|
|
|
*posout++ = val;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2006-09-17 17:49:14 +02:00
|
|
|
sint16 val;
|
2006-09-17 16:41:16 +02:00
|
|
|
|
2006-09-17 17:08:48 +02:00
|
|
|
while (posout < buffer + size)
|
2006-09-17 16:41:16 +02:00
|
|
|
{
|
|
|
|
/* Left */
|
|
|
|
val = *posin++;
|
|
|
|
val |= *posin++ << 8;
|
|
|
|
val = (val * factor_left) >> 8;
|
|
|
|
*posout++ = val & 0xff;
|
|
|
|
*posout++ = val >> 8;
|
|
|
|
|
|
|
|
/* Right */
|
|
|
|
val = *posin++;
|
|
|
|
val |= *posin++ << 8;
|
|
|
|
val = (val * factor_right) >> 8;
|
|
|
|
*posout++ = val & 0xff;
|
|
|
|
*posout++ = val >> 8;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-09-17 20:08:51 +02:00
|
|
|
DEBUG(("using softvol with factors left: %d, right: %d (%d/%d)\n", factor_left,
|
|
|
|
factor_right, format->wBitsPerSample, format->nChannels));
|
2006-09-17 16:41:16 +02:00
|
|
|
}
|
|
|
|
|
2006-09-17 17:25:10 +02:00
|
|
|
void
|
2007-01-04 05:55:56 +01:00
|
|
|
rdpsnd_dsp_swapbytes(unsigned char *buffer, unsigned int size, RD_WAVEFORMATEX * format)
|
2006-09-17 17:25:10 +02:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
uint8 swap;
|
|
|
|
|
|
|
|
if (format->wBitsPerSample == 8)
|
|
|
|
return;
|
|
|
|
|
2008-02-08 11:35:16 +01:00
|
|
|
if (size & 0x1)
|
|
|
|
warning("badly aligned sound data");
|
|
|
|
|
2007-02-10 08:12:36 +01:00
|
|
|
for (i = 0; i < (int) size; i += 2)
|
2006-09-17 17:25:10 +02:00
|
|
|
{
|
|
|
|
swap = *(buffer + i);
|
|
|
|
*(buffer + i) = *(buffer + i + 1);
|
|
|
|
*(buffer + i + 1) = swap;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-01-08 05:47:06 +01:00
|
|
|
RD_BOOL
|
2006-10-01 14:16:50 +02:00
|
|
|
rdpsnd_dsp_resample_set(uint32 device_srate, uint16 device_bitspersample, uint16 device_channels)
|
|
|
|
{
|
2006-10-01 15:57:34 +02:00
|
|
|
#ifdef HAVE_LIBSAMPLERATE
|
|
|
|
int err;
|
|
|
|
#endif
|
|
|
|
|
2006-10-01 14:16:50 +02:00
|
|
|
if (device_bitspersample != 16 && device_bitspersample != 8)
|
|
|
|
return False;
|
|
|
|
|
|
|
|
if (device_channels != 1 && device_channels != 2)
|
|
|
|
return False;
|
|
|
|
|
|
|
|
resample_to_srate = device_srate;
|
|
|
|
resample_to_bitspersample = device_bitspersample;
|
|
|
|
resample_to_channels = device_channels;
|
|
|
|
|
2006-10-01 15:57:34 +02:00
|
|
|
#ifdef HAVE_LIBSAMPLERATE
|
|
|
|
if (src_converter != NULL)
|
|
|
|
src_converter = src_delete(src_converter);
|
|
|
|
|
|
|
|
if ((src_converter = src_new(SRC_CONVERTER, device_channels, &err)) == NULL)
|
|
|
|
{
|
|
|
|
warning("src_new failed: %d!\n", err);
|
|
|
|
return False;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2006-10-01 14:16:50 +02:00
|
|
|
return True;
|
|
|
|
}
|
|
|
|
|
2007-01-08 05:47:06 +01:00
|
|
|
RD_BOOL
|
2007-01-04 05:55:56 +01:00
|
|
|
rdpsnd_dsp_resample_supported(RD_WAVEFORMATEX * format)
|
2006-10-01 14:16:50 +02:00
|
|
|
{
|
|
|
|
if (format->wFormatTag != WAVE_FORMAT_PCM)
|
|
|
|
return False;
|
|
|
|
if ((format->nChannels != 1) && (format->nChannels != 2))
|
|
|
|
return False;
|
|
|
|
if ((format->wBitsPerSample != 8) && (format->wBitsPerSample != 16))
|
|
|
|
return False;
|
|
|
|
|
|
|
|
return True;
|
|
|
|
}
|
|
|
|
|
|
|
|
uint32
|
|
|
|
rdpsnd_dsp_resample(unsigned char **out, unsigned char *in, unsigned int size,
|
2007-01-08 05:47:06 +01:00
|
|
|
RD_WAVEFORMATEX * format, RD_BOOL stream_be)
|
2006-10-01 14:16:50 +02:00
|
|
|
{
|
2006-10-01 15:57:34 +02:00
|
|
|
#ifdef HAVE_LIBSAMPLERATE
|
|
|
|
SRC_DATA resample_data;
|
|
|
|
float *infloat, *outfloat;
|
2006-10-01 17:07:55 +02:00
|
|
|
int err;
|
2006-10-01 15:57:34 +02:00
|
|
|
#else
|
2006-10-01 19:23:30 +02:00
|
|
|
int ratio1k = (resample_to_srate * 1000) / format->nSamplesPerSec;
|
2006-10-01 15:57:34 +02:00
|
|
|
#endif
|
2006-10-01 19:23:30 +02:00
|
|
|
int innum, outnum;
|
2006-10-01 23:46:38 +02:00
|
|
|
unsigned char *tmpdata = NULL, *tmp = NULL;
|
2006-10-01 14:16:50 +02:00
|
|
|
int samplewidth = format->wBitsPerSample / 8;
|
2006-10-01 15:57:34 +02:00
|
|
|
int outsize = 0;
|
2006-10-01 16:31:09 +02:00
|
|
|
int i;
|
2006-10-01 14:16:50 +02:00
|
|
|
|
2006-10-01 14:26:01 +02:00
|
|
|
if ((resample_to_bitspersample == format->wBitsPerSample) &&
|
|
|
|
(resample_to_channels == format->nChannels) &&
|
|
|
|
(resample_to_srate == format->nSamplesPerSec))
|
|
|
|
return 0;
|
|
|
|
|
2006-10-01 15:57:34 +02:00
|
|
|
#ifdef B_ENDIAN
|
|
|
|
if (!stream_be)
|
2006-10-01 16:31:09 +02:00
|
|
|
rdpsnd_dsp_swapbytes(in, size, format);
|
2006-10-01 15:57:34 +02:00
|
|
|
#endif
|
2006-10-01 16:31:09 +02:00
|
|
|
|
2006-10-01 23:46:38 +02:00
|
|
|
if (resample_to_channels != format->nChannels)
|
|
|
|
{
|
|
|
|
int newsize = (size / format->nChannels) * resample_to_channels;
|
2007-02-10 08:12:36 +01:00
|
|
|
tmpdata = (unsigned char *) xmalloc(newsize);
|
2006-10-01 23:46:38 +02:00
|
|
|
|
|
|
|
for (i = 0; i < newsize / samplewidth; i++)
|
|
|
|
{
|
|
|
|
if (format->nChannels > resample_to_channels)
|
|
|
|
memcpy(tmpdata + (i * samplewidth),
|
|
|
|
in +
|
|
|
|
(((i * format->nChannels) / resample_to_channels) *
|
|
|
|
samplewidth), samplewidth);
|
|
|
|
else
|
|
|
|
memcpy(tmpdata + (i * samplewidth),
|
|
|
|
in +
|
|
|
|
(((i / resample_to_channels) * format->nChannels +
|
|
|
|
(i % format->nChannels)) * samplewidth), samplewidth);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
in = tmpdata;
|
|
|
|
size = newsize;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-10-01 16:31:09 +02:00
|
|
|
/* Expand 8bit input-samples to 16bit */
|
|
|
|
#ifndef HAVE_LIBSAMPLERATE /* libsamplerate needs 16bit samples */
|
|
|
|
if (format->wBitsPerSample != resample_to_bitspersample)
|
|
|
|
#endif
|
|
|
|
{
|
|
|
|
/* source: 8 bit, dest: 16bit */
|
|
|
|
if (format->wBitsPerSample == 8)
|
2006-10-01 15:57:34 +02:00
|
|
|
{
|
2006-10-01 23:46:38 +02:00
|
|
|
tmp = tmpdata;
|
2007-02-10 08:12:36 +01:00
|
|
|
tmpdata = (unsigned char *) xmalloc(size * 2);
|
|
|
|
for (i = 0; i < (int) size; i++)
|
2006-10-01 16:31:09 +02:00
|
|
|
{
|
|
|
|
tmpdata[i * 2] = in[i];
|
|
|
|
tmpdata[(i * 2) + 1] = 0x00;
|
|
|
|
}
|
|
|
|
in = tmpdata;
|
|
|
|
samplewidth = 16 / 2;
|
|
|
|
size *= 2;
|
|
|
|
|
2006-10-01 23:46:38 +02:00
|
|
|
if (tmp != NULL)
|
|
|
|
xfree(tmp);
|
|
|
|
}
|
2006-10-01 16:31:09 +02:00
|
|
|
}
|
2006-10-01 15:57:34 +02:00
|
|
|
|
2006-10-01 19:23:30 +02:00
|
|
|
innum = size / samplewidth;
|
|
|
|
|
2006-10-01 16:31:09 +02:00
|
|
|
/* Do the resampling */
|
2006-10-01 15:57:34 +02:00
|
|
|
#ifdef HAVE_LIBSAMPLERATE
|
|
|
|
if (src_converter == NULL)
|
|
|
|
{
|
|
|
|
warning("no samplerate converter available!!\n");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2006-10-01 19:23:30 +02:00
|
|
|
outnum = ((float) innum * ((float) resample_to_srate / (float) format->nSamplesPerSec)) + 1;
|
2006-10-01 15:57:34 +02:00
|
|
|
|
2007-02-10 08:12:36 +01:00
|
|
|
infloat = (float *) xmalloc(sizeof(float) * innum);
|
|
|
|
outfloat = (float *) xmalloc(sizeof(float) * outnum);
|
2006-10-01 15:57:34 +02:00
|
|
|
|
|
|
|
src_short_to_float_array((short *) in, infloat, innum);
|
|
|
|
|
|
|
|
bzero(&resample_data, sizeof(resample_data));
|
|
|
|
resample_data.data_in = infloat;
|
|
|
|
resample_data.data_out = outfloat;
|
|
|
|
resample_data.input_frames = innum / resample_to_channels;
|
|
|
|
resample_data.output_frames = outnum / resample_to_channels;
|
|
|
|
resample_data.src_ratio = (double) resample_to_srate / (double) format->nSamplesPerSec;
|
|
|
|
resample_data.end_of_input = 0;
|
|
|
|
|
2006-10-01 17:07:55 +02:00
|
|
|
if ((err = src_process(src_converter, &resample_data)) != 0)
|
|
|
|
error("src_process: %s", src_strerror(err));
|
|
|
|
|
2006-10-01 15:57:34 +02:00
|
|
|
xfree(infloat);
|
|
|
|
|
2006-10-01 17:07:55 +02:00
|
|
|
outsize = resample_data.output_frames_gen * resample_to_channels * samplewidth;
|
2007-02-10 08:12:36 +01:00
|
|
|
*out = (unsigned char *) xmalloc(outsize);
|
2006-10-01 19:23:30 +02:00
|
|
|
src_float_to_short_array(outfloat, (short *) *out,
|
|
|
|
resample_data.output_frames_gen * resample_to_channels);
|
2006-10-01 15:57:34 +02:00
|
|
|
xfree(outfloat);
|
|
|
|
|
|
|
|
#else
|
2006-10-01 19:23:30 +02:00
|
|
|
/* Michaels simple linear resampler */
|
|
|
|
if (resample_to_srate < format->nSamplesPerSec)
|
2006-10-01 14:16:50 +02:00
|
|
|
{
|
2006-10-01 19:23:30 +02:00
|
|
|
warning("downsampling currently not supported!\n");
|
2006-10-01 14:16:50 +02:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2006-10-01 19:23:30 +02:00
|
|
|
outnum = (innum * ratio1k) / 1000;
|
|
|
|
|
|
|
|
outsize = outnum * samplewidth;
|
2007-02-10 08:12:36 +01:00
|
|
|
*out = (unsigned char *) xmalloc(outsize);
|
2006-10-01 19:23:30 +02:00
|
|
|
bzero(*out, outsize);
|
2006-10-01 14:16:50 +02:00
|
|
|
|
2006-10-01 19:23:30 +02:00
|
|
|
for (i = 0; i < outsize / (resample_to_channels * samplewidth); i++)
|
2006-10-01 14:16:50 +02:00
|
|
|
{
|
2006-10-02 01:42:14 +02:00
|
|
|
int source = (i * 1000) / ratio1k;
|
2006-10-02 10:01:24 +02:00
|
|
|
#if 0 /* Partial for linear resampler */
|
|
|
|
int part = (i * 100000) / ratio1k - source * 100;
|
|
|
|
#endif
|
2006-10-01 21:05:30 +02:00
|
|
|
int j;
|
2006-10-01 14:26:01 +02:00
|
|
|
|
2007-02-10 08:12:36 +01:00
|
|
|
if (source * resample_to_channels + samplewidth > (int) size)
|
2006-10-01 19:23:30 +02:00
|
|
|
break;
|
2006-10-01 14:26:01 +02:00
|
|
|
|
2006-10-27 00:26:16 +02:00
|
|
|
#if 0 /* Linear resampling, TODO: soundquality fixes (LP filter) */
|
2006-10-02 10:01:24 +02:00
|
|
|
if (samplewidth == 1)
|
|
|
|
{
|
|
|
|
sint8 cval1, cval2;
|
|
|
|
for (j = 0; j < resample_to_channels; j++)
|
|
|
|
{
|
|
|
|
memcpy(&cval1,
|
|
|
|
in + (source * resample_to_channels * samplewidth) +
|
|
|
|
(samplewidth * j), samplewidth);
|
|
|
|
memcpy(&cval2,
|
|
|
|
in + ((source + 1) * resample_to_channels * samplewidth) +
|
|
|
|
(samplewidth * j), samplewidth);
|
|
|
|
|
2006-10-27 14:58:13 +02:00
|
|
|
cval1 += (sint8) (cval2 * part) / 100;
|
2006-10-02 10:01:24 +02:00
|
|
|
|
|
|
|
memcpy(*out + (i * resample_to_channels * samplewidth) +
|
|
|
|
(samplewidth * j), &cval1, samplewidth);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
sint16 sval1, sval2;
|
|
|
|
for (j = 0; j < resample_to_channels; j++)
|
|
|
|
{
|
|
|
|
memcpy(&sval1,
|
|
|
|
in + (source * resample_to_channels * samplewidth) +
|
|
|
|
(samplewidth * j), samplewidth);
|
|
|
|
memcpy(&sval2,
|
|
|
|
in + ((source + 1) * resample_to_channels * samplewidth) +
|
|
|
|
(samplewidth * j), samplewidth);
|
|
|
|
|
2006-10-27 14:58:13 +02:00
|
|
|
sval1 += (sint16) (sval2 * part) / 100;
|
2006-10-02 10:01:24 +02:00
|
|
|
|
|
|
|
memcpy(*out + (i * resample_to_channels * samplewidth) +
|
|
|
|
(samplewidth * j), &sval1, samplewidth);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#else /* Nearest neighbor search */
|
2006-10-01 21:05:30 +02:00
|
|
|
for (j = 0; j < resample_to_channels; j++)
|
2006-10-01 19:23:30 +02:00
|
|
|
{
|
2006-10-01 21:05:30 +02:00
|
|
|
memcpy(*out + (i * resample_to_channels * samplewidth) + (samplewidth * j),
|
2006-10-01 23:46:38 +02:00
|
|
|
in + (source * resample_to_channels * samplewidth) +
|
|
|
|
(samplewidth * j), samplewidth);
|
2006-10-01 19:23:30 +02:00
|
|
|
}
|
2006-10-02 10:01:24 +02:00
|
|
|
#endif
|
2006-10-01 14:16:50 +02:00
|
|
|
}
|
2006-10-01 19:23:30 +02:00
|
|
|
outsize = i * resample_to_channels * samplewidth;
|
2006-10-01 15:57:34 +02:00
|
|
|
#endif
|
2006-10-01 14:16:50 +02:00
|
|
|
|
2006-10-01 16:31:09 +02:00
|
|
|
if (tmpdata != NULL)
|
|
|
|
xfree(tmpdata);
|
|
|
|
|
|
|
|
/* Shrink 16bit output-samples to 8bit */
|
|
|
|
#ifndef HAVE_LIBSAMPLERATE /* libsamplerate produces 16bit samples */
|
|
|
|
if (format->wBitsPerSample != resample_to_bitspersample)
|
|
|
|
#endif
|
|
|
|
{
|
|
|
|
/* source: 16 bit, dest: 8 bit */
|
|
|
|
if (resample_to_bitspersample == 8)
|
|
|
|
{
|
|
|
|
for (i = 0; i < outsize; i++)
|
|
|
|
{
|
|
|
|
*out[i] = *out[i * 2];
|
|
|
|
}
|
|
|
|
outsize /= 2;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-10-01 15:57:34 +02:00
|
|
|
#ifdef B_ENDIAN
|
|
|
|
if (!stream_be)
|
2006-10-01 16:31:09 +02:00
|
|
|
rdpsnd_dsp_swapbytes(*out, outsize, format);
|
2006-10-01 15:57:34 +02:00
|
|
|
#endif
|
2006-10-01 16:31:09 +02:00
|
|
|
return outsize;
|
2006-10-01 14:16:50 +02:00
|
|
|
}
|
2006-09-17 16:41:16 +02:00
|
|
|
|
2006-09-17 20:08:51 +02:00
|
|
|
STREAM
|
2006-12-06 14:29:42 +01:00
|
|
|
rdpsnd_dsp_process(unsigned char *data, unsigned int size, struct audio_driver * current_driver,
|
2007-01-04 05:55:56 +01:00
|
|
|
RD_WAVEFORMATEX * format)
|
2006-09-17 20:08:51 +02:00
|
|
|
{
|
|
|
|
static struct stream out;
|
2007-01-08 05:47:06 +01:00
|
|
|
RD_BOOL stream_be = False;
|
2006-09-17 17:08:48 +02:00
|
|
|
|
2006-09-17 20:08:51 +02:00
|
|
|
/* softvol and byteswap do not change the amount of data they
|
|
|
|
return, so they can operate on the input-stream */
|
2006-09-17 16:41:16 +02:00
|
|
|
if (current_driver->wave_out_volume == rdpsnd_dsp_softvol_set)
|
2006-12-06 14:29:42 +01:00
|
|
|
rdpsnd_dsp_softvol(data, size, format);
|
2006-09-17 17:25:10 +02:00
|
|
|
|
|
|
|
#ifdef B_ENDIAN
|
|
|
|
if (current_driver->need_byteswap_on_be)
|
2006-10-01 15:57:34 +02:00
|
|
|
{
|
2006-12-06 14:29:42 +01:00
|
|
|
rdpsnd_dsp_swapbytes(data, size, format);
|
2006-10-01 15:57:34 +02:00
|
|
|
stream_be = True;
|
|
|
|
}
|
2006-09-17 17:25:10 +02:00
|
|
|
#endif
|
2006-09-17 16:41:16 +02:00
|
|
|
|
2006-10-01 14:16:50 +02:00
|
|
|
out.data = NULL;
|
|
|
|
|
2006-10-01 16:03:43 +02:00
|
|
|
if (current_driver->need_resampling)
|
2006-12-06 14:29:42 +01:00
|
|
|
out.size = rdpsnd_dsp_resample(&out.data, data, size, format, stream_be);
|
2006-09-17 20:08:51 +02:00
|
|
|
|
2006-10-01 14:16:50 +02:00
|
|
|
if (out.data == NULL)
|
|
|
|
{
|
2007-02-10 08:12:36 +01:00
|
|
|
out.data = (unsigned char *) xmalloc(size);
|
2006-12-06 14:29:42 +01:00
|
|
|
memcpy(out.data, data, size);
|
|
|
|
out.size = size;
|
2006-10-01 14:16:50 +02:00
|
|
|
}
|
2006-09-17 20:08:51 +02:00
|
|
|
|
|
|
|
out.p = out.data;
|
|
|
|
out.end = out.p + out.size;
|
|
|
|
|
|
|
|
return &out;
|
2006-09-17 16:41:16 +02:00
|
|
|
}
|