summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJuan Linietsky <reduzio@gmail.com>2017-09-27 10:31:24 -0300
committerGitHub <noreply@github.com>2017-09-27 10:31:24 -0300
commitd5cccf26a99e5eb3c04efb953ce76e58fa2d524f (patch)
tree626f82c0dc06e33fc2a5bab351a659dfe75646f7
parentdc18b8d7e848a4de7f91e30c1ba23b634395c22e (diff)
parentf12b4e5fa3b3aeec71399e0f329b0cad281ac301 (diff)
Merge pull request #11633 from marcelofg55/fix_audio_clear
Fixed bug with clearing the stream in AudioPlayerStream
-rw-r--r--scene/audio/audio_player.cpp9
1 files changed, 5 insertions, 4 deletions
diff --git a/scene/audio/audio_player.cpp b/scene/audio/audio_player.cpp
index 14dd39a491..058b162e83 100644
--- a/scene/audio/audio_player.cpp
+++ b/scene/audio/audio_player.cpp
@@ -122,7 +122,6 @@ void AudioStreamPlayer::_notification(int p_what) {
void AudioStreamPlayer::set_stream(Ref<AudioStream> p_stream) {
- ERR_FAIL_COND(!p_stream.is_valid());
AudioServer::get_singleton()->lock();
mix_buffer.resize(AudioServer::get_singleton()->thread_get_mix_buffer_size());
@@ -134,12 +133,14 @@ void AudioStreamPlayer::set_stream(Ref<AudioStream> p_stream) {
setseek = -1;
}
- stream = p_stream;
- stream_playback = p_stream->instance_playback();
+ if (p_stream.is_valid()) {
+ stream = p_stream;
+ stream_playback = p_stream->instance_playback();
+ }
AudioServer::get_singleton()->unlock();
- if (stream_playback.is_null()) {
+ if (p_stream.is_valid() && stream_playback.is_null()) {
stream.unref();
ERR_FAIL_COND(stream_playback.is_null());
}