pcm_convert: added 32 bit support
All PCM sub libraries have 32 bit support now. Add support to the glue function pcm_convert().
This commit is contained in:
parent
3165e26f9a
commit
a5a15beac2
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user