diff options
author | Michael Gernoth <michael@gernoth.net> | 2006-10-01 15:07:55 +0000 |
---|---|---|
committer | Michael Gernoth <michael@gernoth.net> | 2006-10-01 15:07:55 +0000 |
commit | de56acd4937e3e3d37a9c6a5a5d26e44eb0876ad (patch) | |
tree | cd8109b54cf8b6c638d6ede6247203ca8a11f046 /rdpsnd_dsp.c | |
parent | deace67d29d83f4a4174c01ef3a487c38f38f3ae (diff) | |
download | rdesktop-de56acd4937e3e3d37a9c6a5a5d26e44eb0876ad.zip |
fix conversion between arbitrary samplerates
git-svn-id: svn://svn.code.sf.net/p/rdesktop/code/trunk/rdesktop@1281 423420c4-83ab-492f-b58f-81f9feb106b5
Diffstat (limited to 'rdpsnd_dsp.c')
-rw-r--r-- | rdpsnd_dsp.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/rdpsnd_dsp.c b/rdpsnd_dsp.c index 102b6bc..15d413d 100644 --- a/rdpsnd_dsp.c +++ b/rdpsnd_dsp.c @@ -186,6 +186,7 @@ rdpsnd_dsp_resample(unsigned char **out, unsigned char *in, unsigned int size, SRC_DATA resample_data; float *infloat, *outfloat; int innum, outnum; + int err; #else int offset; #endif @@ -240,7 +241,7 @@ rdpsnd_dsp_resample(unsigned char **out, unsigned char *in, unsigned int size, } innum = size / samplewidth; - outnum = innum * (resample_to_srate / format->nSamplesPerSec); + outnum = ((float)innum * ((float)resample_to_srate / (float)format->nSamplesPerSec)) + 1; infloat = xmalloc(sizeof(float) * innum); outfloat = xmalloc(sizeof(float) * outnum); @@ -255,12 +256,14 @@ rdpsnd_dsp_resample(unsigned char **out, unsigned char *in, unsigned int size, resample_data.src_ratio = (double) resample_to_srate / (double) format->nSamplesPerSec; resample_data.end_of_input = 0; - src_process(src_converter, &resample_data); + if ((err = src_process(src_converter, &resample_data)) != 0) + error("src_process: %s", src_strerror(err)); + xfree(infloat); - outsize = outnum * samplewidth; + outsize = resample_data.output_frames_gen * resample_to_channels * samplewidth; *out = xmalloc(outsize); - src_float_to_short_array(outfloat, (short *) *out, outnum); + src_float_to_short_array(outfloat, (short *) *out, resample_data.output_frames_gen * resample_to_channels); xfree(outfloat); #else |