diff options
Diffstat (limited to 'scene/audio')
-rw-r--r-- | scene/audio/audio_stream_player.cpp (renamed from scene/audio/audio_player.cpp) | 31 | ||||
-rw-r--r-- | scene/audio/audio_stream_player.h (renamed from scene/audio/audio_player.h) | 12 |
2 files changed, 26 insertions, 17 deletions
diff --git a/scene/audio/audio_player.cpp b/scene/audio/audio_stream_player.cpp index 4eae3b04e7..2688041d18 100644 --- a/scene/audio/audio_player.cpp +++ b/scene/audio/audio_stream_player.cpp @@ -1,5 +1,5 @@ /*************************************************************************/ -/* audio_player.cpp */ +/* audio_stream_player.cpp */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ @@ -28,7 +28,7 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#include "audio_player.h" +#include "audio_stream_player.h" #include "core/engine.h" @@ -91,13 +91,19 @@ void AudioStreamPlayer::_mix_internal(bool p_fadeout) { void AudioStreamPlayer::_mix_audio() { - if (!stream_playback.is_valid() || !active) + if (!stream_playback.is_valid() || !active || + (stream_paused && !stream_fade)) { return; + } - if (stream_paused) { - if (stream_paused_fade) { - _mix_internal(true); - stream_paused_fade = false; + if (stream_fade) { + _mix_internal(true); + stream_fade = false; + + if (stream_stop) { + stream_playback->stop(); + active = false; + set_process_internal(false); } return; } @@ -203,6 +209,7 @@ void AudioStreamPlayer::play(float p_from_pos) { if (stream_playback.is_valid()) { //mix_volume_db = volume_db; do not reset volume ramp here, can cause clicks + stream_stop = false; setseek = p_from_pos; active = true; set_process_internal(true); @@ -219,9 +226,8 @@ void AudioStreamPlayer::seek(float p_seconds) { void AudioStreamPlayer::stop() { if (stream_playback.is_valid()) { - stream_playback->stop(); - active = false; - set_process_internal(false); + stream_stop = true; + stream_fade = true; } } @@ -295,7 +301,7 @@ void AudioStreamPlayer::set_stream_paused(bool p_pause) { if (p_pause != stream_paused) { stream_paused = p_pause; - stream_paused_fade = p_pause ? true : false; + stream_fade = p_pause ? true : false; } } @@ -385,7 +391,8 @@ AudioStreamPlayer::AudioStreamPlayer() { setseek = -1; active = false; stream_paused = false; - stream_paused_fade = false; + stream_fade = false; + stream_stop = false; mix_target = MIX_TARGET_STEREO; AudioServer::get_singleton()->connect("bus_layout_changed", this, "_bus_layout_changed"); diff --git a/scene/audio/audio_player.h b/scene/audio/audio_stream_player.h index 2e9526c335..fba8ce7dd3 100644 --- a/scene/audio/audio_player.h +++ b/scene/audio/audio_stream_player.h @@ -1,5 +1,5 @@ /*************************************************************************/ -/* audio_player.h */ +/* audio_stream_player.h */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ @@ -28,8 +28,8 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#ifndef AUDIOPLAYER_H -#define AUDIOPLAYER_H +#ifndef AUDIO_STREAM_PLAYER_H +#define AUDIO_STREAM_PLAYER_H #include "scene/main/node.h" #include "servers/audio/audio_stream.h" @@ -58,7 +58,8 @@ private: float volume_db; bool autoplay; bool stream_paused; - bool stream_paused_fade; + bool stream_fade; + bool stream_stop; StringName bus; MixTarget mix_target; @@ -110,4 +111,5 @@ public: }; VARIANT_ENUM_CAST(AudioStreamPlayer::MixTarget) -#endif // AUDIOPLAYER_H + +#endif // AUDIO_STREAM_PLAYER_H |