Fix freeze on exit on audiostreamplayers when setting invalid stream, closes #10093

This commit is contained in:
Juan Linietsky 2017-09-01 16:42:50 -03:00
parent 3694c58d3c
commit 42659b0d9f
3 changed files with 7 additions and 5 deletions

View file

@ -246,12 +246,14 @@ void AudioStreamPlayer2D::set_stream(Ref<AudioStream> p_stream) {
stream = p_stream;
stream_playback = p_stream->instance_playback();
AudioServer::get_singleton()->unlock();
if (stream_playback.is_null()) {
stream.unref();
ERR_FAIL_COND(stream_playback.is_null());
}
AudioServer::get_singleton()->unlock();
}
Ref<AudioStream> AudioStreamPlayer2D::get_stream() const {

View file

@ -555,12 +555,12 @@ void AudioStreamPlayer3D::set_stream(Ref<AudioStream> p_stream) {
stream = p_stream;
stream_playback = p_stream->instance_playback();
AudioServer::get_singleton()->unlock();
if (stream_playback.is_null()) {
stream.unref();
ERR_FAIL_COND(stream_playback.is_null());
}
AudioServer::get_singleton()->unlock();
}
Ref<AudioStream> AudioStreamPlayer3D::get_stream() const {

View file

@ -139,12 +139,12 @@ void AudioStreamPlayer::set_stream(Ref<AudioStream> p_stream) {
stream = p_stream;
stream_playback = p_stream->instance_playback();
AudioServer::get_singleton()->unlock();
if (stream_playback.is_null()) {
stream.unref();
ERR_FAIL_COND(stream_playback.is_null());
}
AudioServer::get_singleton()->unlock();
}
Ref<AudioStream> AudioStreamPlayer::get_stream() const {