diff options
author | Max Kellermann <max@duempel.org> | 2009-01-08 00:46:38 +0100 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2009-01-08 00:46:38 +0100 |
commit | 2a83138913dbfc90958c52527fbfc1fc1bbf76e5 (patch) | |
tree | dd46a56d1c4f3ae7d49fdb00ce3f5d06e9628d2e /src/pcm_convert.c | |
parent | aab85577bf7576895ccae0403d5cb95aa113f7f0 (diff) | |
download | mpd-2a83138913dbfc90958c52527fbfc1fc1bbf76e5.tar.gz mpd-2a83138913dbfc90958c52527fbfc1fc1bbf76e5.tar.xz mpd-2a83138913dbfc90958c52527fbfc1fc1bbf76e5.zip |
pcm_resample: use pcm_buffer (1/2)
Return a temporary buffer from pcm_resample_*() and pcm_convert().
Diffstat (limited to '')
-rw-r--r-- | src/pcm_convert.c | 30 |
1 files changed, 14 insertions, 16 deletions
diff --git a/src/pcm_convert.c b/src/pcm_convert.c index b9db24b9a..9f285eae5 100644 --- a/src/pcm_convert.c +++ b/src/pcm_convert.c @@ -76,16 +76,15 @@ pcm_convert_16(const struct audio_format *src_format, g_error("pcm_convert_channels_16() failed"); } - if (src_format->sample_rate == dest_format->sample_rate) { - assert(dest_size >= len); - memcpy(dest_buffer, buf, len); - } else { - len = pcm_resample_16(dest_format->channels, + if (src_format->sample_rate != dest_format->sample_rate) + buf = pcm_resample_16(&state->resample, + dest_format->channels, src_format->sample_rate, buf, len, dest_format->sample_rate, - dest_buffer, dest_size, - &state->resample); - } + &len); + + assert(dest_size >= len); + memcpy(dest_buffer, buf, len); return len; } @@ -117,16 +116,15 @@ pcm_convert_24(const struct audio_format *src_format, g_error("pcm_convert_channels_24() failed"); } - if (src_format->sample_rate == dest_format->sample_rate) { - assert(dest_size >= len); - memcpy(dest_buffer, buf, len); - } else { - len = pcm_resample_24(dest_format->channels, + if (src_format->sample_rate != dest_format->sample_rate) + buf = pcm_resample_24(&state->resample, + dest_format->channels, src_format->sample_rate, buf, len, dest_format->sample_rate, - (int32_t*)dest_buffer, dest_size, - &state->resample); - } + &len); + + assert(dest_size >= len); + memcpy(dest_buffer, buf, len); return len; } |