OutputThread: retain negative mix ratio

Fixes MixRamp breakage.
This commit is contained in:
Max Kellermann 2014-09-18 13:50:23 +02:00
parent a0ef27a0cd
commit b6fa22bd84
2 changed files with 11 additions and 1 deletions

1
NEWS
View File

@ -1,6 +1,7 @@
ver 0.18.15 (not yet released) ver 0.18.15 (not yet released)
* command * command
- list: reset used size after the list has been processed - list: reset used size after the list has been processed
* fix MixRamp
* work around build failure on NetBSD * work around build failure on NetBSD
ver 0.18.14 (2014/09/11) ver 0.18.14 (2014/09/11)

View File

@ -385,11 +385,20 @@ ao_filter_chunk(struct audio_output *ao, const struct music_chunk *chunk,
if (length > other_length) if (length > other_length)
length = other_length; length = other_length;
float mix_ratio = chunk->mix_ratio;
if (mix_ratio >= 0)
/* reverse the mix ratio (because the
arguments to pcm_mix() are reversed), but
only if the mix ratio is non-negative; a
negative mix ratio is a MixRamp special
case */
mix_ratio = 1.0 - mix_ratio;
void *dest = ao->cross_fade_buffer.Get(other_length); void *dest = ao->cross_fade_buffer.Get(other_length);
memcpy(dest, other_data, other_length); memcpy(dest, other_data, other_length);
if (!pcm_mix(dest, data, length, if (!pcm_mix(dest, data, length,
ao->in_audio_format.format, ao->in_audio_format.format,
1.0 - chunk->mix_ratio)) { mix_ratio)) {
FormatError(output_domain, FormatError(output_domain,
"Cannot cross-fade format %s", "Cannot cross-fade format %s",
sample_format_to_string(ao->in_audio_format.format)); sample_format_to_string(ao->in_audio_format.format));