decoder: pass the correct buffer length to pcm_convert()

When a global audio format is configured (setting
"audio_output_format"), decoder_data() overwrote the "length"
parameter with the size of the output buffer (result of
pcm_convert_size()).  Declare a separate variable for the output
buffer length.
This commit is contained in:
Max Kellermann 2008-11-18 22:45:51 +01:00
parent 33b5015469
commit 362ca300d6

View File

@ -232,13 +232,14 @@ decoder_data(struct decoder *decoder,
if (audio_format_equals(&dc.in_audio_format, &dc.out_audio_format)) {
data = _data;
} else {
length = pcm_convert_size(&dc.in_audio_format, length,
&dc.out_audio_format);
if (length > conv_buffer_size) {
size_t out_length =
pcm_convert_size(&dc.in_audio_format, length,
&dc.out_audio_format);
if (out_length > conv_buffer_size) {
if (conv_buffer != NULL)
free(conv_buffer);
conv_buffer = xmalloc(length);
conv_buffer_size = length;
conv_buffer = xmalloc(out_length);
conv_buffer_size = out_length;
}
data = conv_buffer;