diff options
author | RĂ©mi Verschelde <remi@verschelde.fr> | 2022-06-22 23:33:51 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-06-22 23:33:51 +0200 |
commit | d1dac8427a6a41e8fc0a76807887a57a8fe6fd10 (patch) | |
tree | 8d23b28484ab0712abeeb2e6134f4ed9ceba36cc /modules/vorbis | |
parent | e9ca15b6a6788fd739e85ba3f6ed3ee21c246257 (diff) | |
parent | afd2bbaa5f8bda7ad1e830d75d80fbdffbbd08ec (diff) |
Merge pull request #55846 from ellenhp/fix_ogg_edge_cases
Fix ogg edge cases
Diffstat (limited to 'modules/vorbis')
-rw-r--r-- | modules/vorbis/audio_stream_ogg_vorbis.cpp | 17 |
1 files changed, 7 insertions, 10 deletions
diff --git a/modules/vorbis/audio_stream_ogg_vorbis.cpp b/modules/vorbis/audio_stream_ogg_vorbis.cpp index b645a48c88..89a6b03ff8 100644 --- a/modules/vorbis/audio_stream_ogg_vorbis.cpp +++ b/modules/vorbis/audio_stream_ogg_vorbis.cpp @@ -36,23 +36,22 @@ int AudioStreamPlaybackOGGVorbis::_mix_internal(AudioFrame *p_buffer, int p_frames) { ERR_FAIL_COND_V(!ready, 0); - ERR_FAIL_COND_V(!active, 0); + + if (!active) { + return 0; + } int todo = p_frames; int start_buffer = 0; - int frames_mixed_this_step = p_frames; - - while (todo && active) { + while (todo > 0 && active) { AudioFrame *buffer = p_buffer; if (start_buffer > 0) { buffer = buffer + start_buffer; } int mixed = _mix_frames_vorbis(buffer, todo); - if (mixed < 0) { - return 0; - } + ERR_FAIL_COND_V(mixed < 0, 0); todo -= mixed; frames_mixed += mixed; start_buffer += mixed; @@ -67,16 +66,14 @@ int AudioStreamPlaybackOGGVorbis::_mix_internal(AudioFrame *p_buffer, int p_fram // we still have buffer to fill, start from this element in the next iteration. start_buffer = p_frames - todo; } else { - frames_mixed_this_step = p_frames - todo; for (int i = p_frames - todo; i < p_frames; i++) { p_buffer[i] = AudioFrame(0, 0); } active = false; - todo = 0; } } } - return frames_mixed_this_step; + return p_frames - todo; } int AudioStreamPlaybackOGGVorbis::_mix_frames_vorbis(AudioFrame *p_buffer, int p_frames) { |