summaryrefslogtreecommitdiff
path: root/scene/2d/audio_stream_player_2d.cpp
diff options
context:
space:
mode:
authorJuan Linietsky <reduzio@gmail.com>2023-01-23 10:43:13 +0100
committerJuan Linietsky <reduzio@gmail.com>2023-01-23 10:47:01 +0100
commit4383b5ab1eb98007631106eafca3d583d03bd20e (patch)
tree94fd122f303305d393cfce680d7d0fa00fd2223a /scene/2d/audio_stream_player_2d.cpp
parenteaf306e0b15e4283883f06bf903b05711a4dbfe8 (diff)
Simplify AudioStreamPolyphonic
* Make AudioStreamPolyphonic not requre a polling thread (simpler, faster) * Improve error reporting in AudioStreamPlayer*::get_stream_playback() error reporting to improve usability.
Diffstat (limited to 'scene/2d/audio_stream_player_2d.cpp')
-rw-r--r--scene/2d/audio_stream_player_2d.cpp6
1 files changed, 2 insertions, 4 deletions
diff --git a/scene/2d/audio_stream_player_2d.cpp b/scene/2d/audio_stream_player_2d.cpp
index c4de3a124b..7b681eac7a 100644
--- a/scene/2d/audio_stream_player_2d.cpp
+++ b/scene/2d/audio_stream_player_2d.cpp
@@ -391,10 +391,8 @@ bool AudioStreamPlayer2D::get_stream_paused() const {
}
Ref<AudioStreamPlayback> AudioStreamPlayer2D::get_stream_playback() {
- if (!stream_playbacks.is_empty()) {
- return stream_playbacks[stream_playbacks.size() - 1];
- }
- return nullptr;
+ ERR_FAIL_COND_V_MSG(stream_playbacks.is_empty(), Ref<AudioStreamPlayback>(), "Player is inactive. Call play() before requesting get_stream_playback().");
+ return stream_playbacks[stream_playbacks.size() - 1];
}
void AudioStreamPlayer2D::set_max_polyphony(int p_max_polyphony) {