summaryrefslogtreecommitdiff
path: root/scene
diff options
context:
space:
mode:
Diffstat (limited to 'scene')
-rw-r--r--scene/audio/stream_player.cpp7
-rw-r--r--scene/audio/stream_player.h1
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;