Merge pull request #44986 from aaronfranke/audiostream

Descriptive error message when using AudioStream(OGG/MP3) incorrectly
This commit is contained in:
Rémi Verschelde 2021-01-07 11:42:40 +01:00 committed by GitHub
commit cf4c58838f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 2 deletions

View File

@ -120,7 +120,10 @@ AudioStreamPlaybackMP3::~AudioStreamPlaybackMP3() {
Ref<AudioStreamPlayback> AudioStreamMP3::instance_playback() {
Ref<AudioStreamPlaybackMP3> mp3s;
ERR_FAIL_COND_V(data == nullptr, mp3s);
ERR_FAIL_COND_V_MSG(data == nullptr, mp3s,
"This AudioStreamMP3 does not have an audio file assigned "
"to it. AudioStreamMP3 should not be created from the "
"inspector or with `.new()`. Instead, load an audio file.");
mp3s.instance();
mp3s->mp3_stream = Ref<AudioStreamMP3>(this);

View File

@ -124,7 +124,10 @@ AudioStreamPlaybackOGGVorbis::~AudioStreamPlaybackOGGVorbis() {
Ref<AudioStreamPlayback> AudioStreamOGGVorbis::instance_playback() {
Ref<AudioStreamPlaybackOGGVorbis> ovs;
ERR_FAIL_COND_V(data == nullptr, ovs);
ERR_FAIL_COND_V_MSG(data == nullptr, ovs,
"This AudioStreamOGGVorbis does not have an audio file assigned "
"to it. AudioStreamOGGVorbis should not be created from the "
"inspector or with `.new()`. Instead, load an audio file.");
ovs.instance();
ovs->vorbis_stream = Ref<AudioStreamOGGVorbis>(this);