rdpsnd_dsp.c revision 6e9aa255e3376b2da5824c09c4c62bc233463bfe
/*
rdesktop: A Remote Desktop Protocol client.
Sound DSP routines
Copyright (C) Michael Gernoth <mike@zerfleddert.de> 2006-2008
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(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
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/*
* Oracle GPL Disclaimer: For the avoidance of doubt, except that if any license choice
* other than GPL or LGPL is available it will apply instead, Oracle elects to use only
* the General Public License version 2 (GPLv2) at this time for any software where
* a choice of GPL license versions is made available with the language indicating
* that GPLv2 or any later version may be used, or where a choice of which version
* of the GPL is applied is otherwise unspecified.
*/
#include <strings.h>
#include "rdesktop.h"
#include "rdpsnd.h"
#include "rdpsnd_dsp.h"
#ifdef HAVE_LIBSAMPLERATE
#include <samplerate.h>
#define SRC_CONVERTER SRC_SINC_MEDIUM_QUALITY
#endif
#define MAX_VOLUME 65535
#ifdef HAVE_LIBSAMPLERATE
#endif
void
{
softvol_left = left;
}
void
{
unsigned int factor_left, factor_right;
return;
{
}
{
{
/* Left */
/* Right */
}
}
else
{
{
/* Left */
/* Right */
}
}
}
void
{
int i;
return;
if (size & 0x1)
warning("badly aligned sound data");
for (i = 0; i < (int) size; i += 2)
{
}
}
{
#ifdef HAVE_LIBSAMPLERATE
int err;
#endif
return False;
return False;
#ifdef HAVE_LIBSAMPLERATE
if (src_converter != NULL)
{
return False;
}
#endif
return True;
}
{
return False;
return False;
return False;
return True;
}
{
#ifdef HAVE_LIBSAMPLERATE
int err;
#else
#endif
int outsize = 0;
int i;
return 0;
#ifdef B_ENDIAN
if (!stream_be)
#endif
{
for (i = 0; i < newsize / samplewidth; i++)
{
in +
else
in +
}
}
/* Expand 8bit input-samples to 16bit */
#ifndef HAVE_LIBSAMPLERATE /* libsamplerate needs 16bit samples */
#endif
{
/* source: 8 bit, dest: 16bit */
{
for (i = 0; i < (int) size; i++)
{
}
size *= 2;
}
}
/* Do the resampling */
#ifdef HAVE_LIBSAMPLERATE
if (src_converter == NULL)
{
warning("no samplerate converter available!\n");
return 0;
}
#else
/* Michaels simple linear resampler */
{
warning("downsampling currently not supported!\n");
return 0;
}
{
#if 0 /* Partial for linear resampler */
#endif
int j;
break;
#if 0 /* Linear resampling, TODO: soundquality fixes (LP filter) */
if (samplewidth == 1)
{
for (j = 0; j < resample_to_channels; j++)
{
(samplewidth * j), samplewidth);
(samplewidth * j), samplewidth);
}
}
else
{
for (j = 0; j < resample_to_channels; j++)
{
(samplewidth * j), samplewidth);
(samplewidth * j), samplewidth);
}
}
#else /* Nearest neighbor search */
for (j = 0; j < resample_to_channels; j++)
{
(samplewidth * j), samplewidth);
}
#endif
}
#endif
/* Shrink 16bit output-samples to 8bit */
#ifndef HAVE_LIBSAMPLERATE /* libsamplerate produces 16bit samples */
#endif
{
/* source: 16 bit, dest: 8 bit */
if (resample_to_bitspersample == 8)
{
for (i = 0; i < outsize; i++)
{
}
outsize /= 2;
}
}
#ifdef B_ENDIAN
if (!stream_be)
#endif
return outsize;
}
{
/* softvol and byteswap do not change the amount of data they
return, so they can operate on the input-stream */
#ifdef B_ENDIAN
{
}
#endif
{
}
return &out;
}