From 42e248a8da0f2043e752166d4a34615c850384ec Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Sat, 8 Oct 2011 18:19:43 +0200 Subject: pcm_convert: add function pcm_convert_channels() For future internal use. --- src/pcm_convert.c | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) (limited to 'src/pcm_convert.c') 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, -- cgit v1.2.3