diff options
author | Max Kellermann <max@duempel.org> | 2011-10-08 18:19:43 +0200 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2011-10-20 02:55:05 +0200 |
commit | 42e248a8da0f2043e752166d4a34615c850384ec (patch) | |
tree | 4ddc2a8d349fd28dd1529900c83437aa57fc9033 /src/pcm_convert.c | |
parent | e71a652985768e5f4ad78f23786dff08081214db (diff) | |
download | mpd-42e248a8da0f2043e752166d4a34615c850384ec.tar.gz mpd-42e248a8da0f2043e752166d4a34615c850384ec.tar.xz mpd-42e248a8da0f2043e752166d4a34615c850384ec.zip |
pcm_convert: add function pcm_convert_channels()
For future internal use.
Diffstat (limited to 'src/pcm_convert.c')
-rw-r--r-- | src/pcm_convert.c | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/src/pcm_convert.c b/src/pcm_convert.c index c145e437a..58137fd0e 100644 --- a/src/pcm_convert.c +++ b/src/pcm_convert.c @@ -56,6 +56,56 @@ void pcm_convert_deinit(struct pcm_convert_state *state) pcm_buffer_deinit(&state->byteswap_buffer); } +G_GNUC_UNUSED +static const void * +pcm_convert_channels(struct pcm_buffer *buffer, enum sample_format format, + uint8_t dest_channels, + uint8_t src_channels, const void *src, + size_t src_size, size_t *dest_size_r, + GError **error_r) +{ + const void *dest = NULL; + + switch (format) { + case SAMPLE_FORMAT_UNDEFINED: + case SAMPLE_FORMAT_S8: + case SAMPLE_FORMAT_S24: + case SAMPLE_FORMAT_FLOAT: + g_set_error(error_r, pcm_convert_quark(), 0, + "Channel conversion not implemented for format '%s'", + sample_format_to_string(format)); + return NULL; + + case SAMPLE_FORMAT_S16: + dest = pcm_convert_channels_16(buffer, dest_channels, + src_channels, src, + src_size, dest_size_r); + break; + + case SAMPLE_FORMAT_S24_P32: + dest = pcm_convert_channels_24(buffer, dest_channels, + src_channels, src, + src_size, dest_size_r); + break; + + case SAMPLE_FORMAT_S32: + dest = pcm_convert_channels_32(buffer, dest_channels, + src_channels, src, + src_size, dest_size_r); + break; + } + + if (dest == NULL) { + g_set_error(error_r, pcm_convert_quark(), 0, + "Conversion from %u to %u channels " + "is not implemented", + src_channels, dest_channels); + return NULL; + } + + return dest; +} + static const int16_t * pcm_convert_16(struct pcm_convert_state *state, const struct audio_format *src_format, |