diff options
author | Juan Linietsky <reduzio@gmail.com> | 2015-12-21 10:51:27 -0300 |
---|---|---|
committer | Juan Linietsky <reduzio@gmail.com> | 2015-12-21 10:51:27 -0300 |
commit | 9bf7adfc1fcf1e57b5279f3d56983bc222366562 (patch) | |
tree | 0d58218cfc7c045e1bed7826f99b34ebd0fdd502 /scene/audio | |
parent | 46dee92c8eb2eed4ed72e0b79670889eca5e1896 (diff) |
-another approach to solving the deadlock problem :|
Diffstat (limited to 'scene/audio')
-rw-r--r-- | scene/audio/stream_player.cpp | 7 | ||||
-rw-r--r-- | scene/audio/stream_player.h | 1 |
2 files changed, 7 insertions, 1 deletions
diff --git a/scene/audio/stream_player.cpp b/scene/audio/stream_player.cpp index 4cfca0492a..d08fdd0c76 100644 --- a/scene/audio/stream_player.cpp +++ b/scene/audio/stream_player.cpp @@ -75,7 +75,10 @@ void StreamPlayer::sp_update() { //check that all this audio has been flushed before stopping the stream int to_mix = resampler.get_total() - resampler.get_todo(); if (to_mix==0) { - stop(); + if (!stop_request) { + stop_request=true; + call_deferred("stop"); + } return; } @@ -164,6 +167,7 @@ void StreamPlayer::stop() { //_THREAD_SAFE_METHOD_ AudioServer::get_singleton()->stream_set_active(stream_rid,false); + stop_request=false; playback->stop(); resampler.flush(); @@ -389,6 +393,7 @@ StreamPlayer::StreamPlayer() { stream_rid=AudioServer::get_singleton()->audio_stream_create(&internal_stream); buffering_ms=500; loop_point=0; + stop_request=false; } diff --git a/scene/audio/stream_player.h b/scene/audio/stream_player.h index be090f50e1..0a29e78de7 100644 --- a/scene/audio/stream_player.h +++ b/scene/audio/stream_player.h @@ -66,6 +66,7 @@ class StreamPlayer : public Node { float volume; float loop_point; int buffering_ms; + volatile bool stop_request; AudioRBResampler resampler; |