diff options
author | Ellen Poe <ellenhp@google.com> | 2021-08-27 10:27:58 -0700 |
---|---|---|
committer | Ellen Poe <ellenhp@google.com> | 2021-08-27 10:27:58 -0700 |
commit | 53843ba872e3e76c05e8bf9a86d1876914e1ba89 (patch) | |
tree | 890e4ddaa3dd8c4e3124c3d140f6b5b2a4e88adc /scene | |
parent | 460e0ce314dbc6d14945cdc7d44e964d4e5c16ec (diff) |
Require AudioStream::mix to return the number of frames successfully mixed
Diffstat (limited to 'scene')
-rw-r--r-- | scene/resources/audio_stream_sample.cpp | 7 | ||||
-rw-r--r-- | scene/resources/audio_stream_sample.h | 2 |
2 files changed, 6 insertions, 3 deletions
diff --git a/scene/resources/audio_stream_sample.cpp b/scene/resources/audio_stream_sample.cpp index ef070589e4..2ab9b7b5a4 100644 --- a/scene/resources/audio_stream_sample.cpp +++ b/scene/resources/audio_stream_sample.cpp @@ -221,12 +221,12 @@ void AudioStreamPlaybackSample::do_resample(const Depth *p_src, AudioFrame *p_ds } } -void AudioStreamPlaybackSample::mix(AudioFrame *p_buffer, float p_rate_scale, int p_frames) { +int AudioStreamPlaybackSample::mix(AudioFrame *p_buffer, float p_rate_scale, int p_frames) { if (!base->data || !active) { for (int i = 0; i < p_frames; i++) { p_buffer[i] = AudioFrame(0, 0); } - return; + return 0; } int len = base->data_bytes; @@ -395,12 +395,15 @@ void AudioStreamPlaybackSample::mix(AudioFrame *p_buffer, float p_rate_scale, in } if (todo) { + int mixed_frames = p_frames - todo; //bit was missing from mix int todo_ofs = p_frames - todo; for (int i = todo_ofs; i < p_frames; i++) { p_buffer[i] = AudioFrame(0, 0); } + return mixed_frames; } + return p_frames; } AudioStreamPlaybackSample::AudioStreamPlaybackSample() {} diff --git a/scene/resources/audio_stream_sample.h b/scene/resources/audio_stream_sample.h index 70b8ba79ad..8bf3d29123 100644 --- a/scene/resources/audio_stream_sample.h +++ b/scene/resources/audio_stream_sample.h @@ -73,7 +73,7 @@ public: virtual float get_playback_position() const override; virtual void seek(float p_time) override; - virtual void mix(AudioFrame *p_buffer, float p_rate_scale, int p_frames) override; + virtual int mix(AudioFrame *p_buffer, float p_rate_scale, int p_frames) override; AudioStreamPlaybackSample(); }; |