Browse Source

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

Juan Linietsky 8 years ago
parent
commit
42659b0d9f

+ 3 - 1
scene/2d/audio_stream_player_2d.cpp

@@ -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 {

+ 2 - 2
scene/3d/audio_stream_player_3d.cpp

@@ -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 {

+ 2 - 2
scene/audio/audio_player.cpp

@@ -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 {