From 139daf0e035645054129b9e31a188721fea0973a Mon Sep 17 00:00:00 2001 From: Hein-Pieter van Braam Date: Sun, 17 Dec 2017 22:31:35 +0100 Subject: Don't try to mix a sample that has already ended On short samples the sample may finish playing before the mixer is done. This fills the remaining time with zeros and ends mixing. This fixes the users getting the following error logged: ::_mix_internal: Condition ' !active ' is true. --- servers/audio/audio_stream.cpp | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'servers/audio') diff --git a/servers/audio/audio_stream.cpp b/servers/audio/audio_stream.cpp index d7b2c2c5e0..15d4a11223 100644 --- a/servers/audio/audio_stream.cpp +++ b/servers/audio/audio_stream.cpp @@ -76,6 +76,13 @@ void AudioStreamPlaybackResampled::mix(AudioFrame *p_buffer, float p_rate_scale, internal_buffer[1] = internal_buffer[INTERNAL_BUFFER_LEN + 1]; internal_buffer[2] = internal_buffer[INTERNAL_BUFFER_LEN + 2]; internal_buffer[3] = internal_buffer[INTERNAL_BUFFER_LEN + 3]; + if (!is_playing()) { + for (int i = 4; i < INTERNAL_BUFFER_LEN; ++i) { + internal_buffer[i] = AudioFrame(0, 0); + } + + return; + } _mix_internal(internal_buffer + 4, INTERNAL_BUFFER_LEN); mix_offset -= (INTERNAL_BUFFER_LEN << FP_BITS); } -- cgit v1.2.3