summaryrefslogtreecommitdiff
path: root/scene/resources/audio_stream_sample.cpp
diff options
context:
space:
mode:
authorRafał Mikrut <mikrutrafal54@gmail.com>2019-11-20 16:22:16 +0100
committerRafał Mikrut <mikrutrafal54@gmail.com>2019-11-20 16:22:16 +0100
commit99d8626f4a313471410db421891e90fe768cd929 (patch)
treeb5e855e2c2a8b142af4fc01cfbc0a0257a01ccc5 /scene/resources/audio_stream_sample.cpp
parent58ca9f17a2650bb381972210d1babbf34ac6819c (diff)
Fix some overflows and unitialized variables
Diffstat (limited to 'scene/resources/audio_stream_sample.cpp')
-rw-r--r--scene/resources/audio_stream_sample.cpp5
1 files changed, 3 insertions, 2 deletions
diff --git a/scene/resources/audio_stream_sample.cpp b/scene/resources/audio_stream_sample.cpp
index 5b61654c5d..286f9e37cd 100644
--- a/scene/resources/audio_stream_sample.cpp
+++ b/scene/resources/audio_stream_sample.cpp
@@ -95,8 +95,8 @@ void AudioStreamPlaybackSample::do_resample(const Depth *p_src, AudioFrame *p_ds
// this function will be compiled branchless by any decent compiler
int32_t final, final_r, next, next_r;
- while (amount--) {
-
+ while (amount) {
+ amount--;
int64_t pos = offset >> MIX_FRAC_BITS;
if (is_stereo && !is_ima_adpcm)
pos <<= 1;
@@ -444,6 +444,7 @@ int AudioStreamSample::get_loop_end() const {
void AudioStreamSample::set_mix_rate(int p_hz) {
+ ERR_FAIL_COND(p_hz == 0);
mix_rate = p_hz;
}
int AudioStreamSample::get_mix_rate() const {