diff options
author | chanon <chanon.s@gmail.com> | 2018-06-19 18:56:05 +0700 |
---|---|---|
committer | chanon <chanon.s@gmail.com> | 2018-06-22 15:00:57 +0700 |
commit | 2bdac0a5d90811158c0615ab4d16e5dcff933957 (patch) | |
tree | e98973e300734d11568cde0c2c4ef8e102f58836 | |
parent | 0a1c1c660fc6aa0689816e85f2b6791c225c6d63 (diff) |
fix can't set AudioStreamPlayer stream to null
-rw-r--r-- | scene/2d/audio_stream_player_2d.cpp | 10 | ||||
-rw-r--r-- | scene/3d/audio_stream_player_3d.cpp | 10 | ||||
-rw-r--r-- | scene/audio/audio_player.cpp | 1 |
3 files changed, 10 insertions, 11 deletions
diff --git a/scene/2d/audio_stream_player_2d.cpp b/scene/2d/audio_stream_player_2d.cpp index 54541293fd..97438780a0 100644 --- a/scene/2d/audio_stream_player_2d.cpp +++ b/scene/2d/audio_stream_player_2d.cpp @@ -242,7 +242,6 @@ void AudioStreamPlayer2D::_notification(int p_what) { void AudioStreamPlayer2D::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()); @@ -254,14 +253,15 @@ void AudioStreamPlayer2D::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()); } } diff --git a/scene/3d/audio_stream_player_3d.cpp b/scene/3d/audio_stream_player_3d.cpp index e7b3645001..8e29af087c 100644 --- a/scene/3d/audio_stream_player_3d.cpp +++ b/scene/3d/audio_stream_player_3d.cpp @@ -552,7 +552,6 @@ void AudioStreamPlayer3D::_notification(int p_what) { void AudioStreamPlayer3D::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()); @@ -564,14 +563,15 @@ void AudioStreamPlayer3D::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()); } } diff --git a/scene/audio/audio_player.cpp b/scene/audio/audio_player.cpp index 408c00334a..06539f6c1a 100644 --- a/scene/audio/audio_player.cpp +++ b/scene/audio/audio_player.cpp @@ -159,7 +159,6 @@ void AudioStreamPlayer::set_stream(Ref<AudioStream> p_stream) { if (p_stream.is_valid() && stream_playback.is_null()) { stream.unref(); - ERR_FAIL_COND(stream_playback.is_null()); } } |