diff options
author | Max Kellermann <max@duempel.org> | 2009-03-02 16:41:10 +0100 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2009-03-02 16:41:10 +0100 |
commit | a5a15beac2eedeccbb11e4f2f28878f5df00c38b (patch) | |
tree | c40c44e5fe17db9f1d8d1a897635a34488a87690 | |
parent | 3165e26f9a39ef0acc2f2e286874cc27bfb03c54 (diff) | |
download | mpd-a5a15beac2eedeccbb11e4f2f28878f5df00c38b.tar.gz mpd-a5a15beac2eedeccbb11e4f2f28878f5df00c38b.tar.xz mpd-a5a15beac2eedeccbb11e4f2f28878f5df00c38b.zip |
pcm_convert: added 32 bit support
All PCM sub libraries have 32 bit support now. Add support to the
glue function pcm_convert().
-rw-r--r-- | src/pcm_convert.c | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/src/pcm_convert.c b/src/pcm_convert.c index dbef443dd..cf4676489 100644 --- a/src/pcm_convert.c +++ b/src/pcm_convert.c @@ -123,6 +123,43 @@ pcm_convert_24(struct pcm_convert_state *state, return buf; } +static const int32_t * +pcm_convert_32(struct pcm_convert_state *state, + const struct audio_format *src_format, + const void *src_buffer, size_t src_size, + const struct audio_format *dest_format, + size_t *dest_size_r) +{ + const int32_t *buf; + size_t len; + + assert(dest_format->bits == 32); + + buf = pcm_convert_to_32(&state->format_buffer, src_format->bits, + src_buffer, src_size, &len); + if (!buf) + g_error("pcm_convert_to_32() failed"); + + if (src_format->channels != dest_format->channels) { + buf = pcm_convert_channels_32(&state->channels_buffer, + dest_format->channels, + src_format->channels, + buf, len, &len); + if (!buf) + g_error("pcm_convert_channels_32() failed"); + } + + if (src_format->sample_rate != dest_format->sample_rate) + buf = pcm_resample_32(&state->resample, + dest_format->channels, + src_format->sample_rate, buf, len, + dest_format->sample_rate, + &len); + + *dest_size_r = len; + return buf; +} + const void * pcm_convert(struct pcm_convert_state *state, const struct audio_format *src_format, @@ -141,6 +178,11 @@ pcm_convert(struct pcm_convert_state *state, src_format, src, src_size, dest_format, dest_size_r); + case 32: + return pcm_convert_32(state, + src_format, src, src_size, + dest_format, dest_size_r); + default: g_error("cannot convert to %u bit\n", dest_format->bits); return 0; |