diff options
Diffstat (limited to 'servers/audio/audio_stream.cpp')
-rw-r--r-- | servers/audio/audio_stream.cpp | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/servers/audio/audio_stream.cpp b/servers/audio/audio_stream.cpp index d7b2c2c5e0..b9000a3ea7 100644 --- a/servers/audio/audio_stream.cpp +++ b/servers/audio/audio_stream.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ +/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ @@ -76,7 +76,14 @@ 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]; - _mix_internal(internal_buffer + 4, INTERNAL_BUFFER_LEN); + if (is_playing()) { + _mix_internal(internal_buffer + 4, INTERNAL_BUFFER_LEN); + } else { + //fill with silence, not playing + for (int i = 0; i < INTERNAL_BUFFER_LEN; ++i) { + internal_buffer[i + 4] = AudioFrame(0, 0); + } + } mix_offset -= (INTERNAL_BUFFER_LEN << FP_BITS); } } |