Created
March 14, 2018 01:44
-
-
Save inactive123/d2465ebefcc50f0572dfb1b32f98ab5b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/audio/audio_driver.c b/audio/audio_driver.c | |
index bc2231c76e..ab0f0bd73c 100644 | |
--- a/audio/audio_driver.c | |
+++ b/audio/audio_driver.c | |
@@ -739,6 +739,8 @@ size_t audio_driver_sample_batch(const int16_t *data, size_t frames) | |
**/ | |
void audio_driver_sample_rewind(int16_t left, int16_t right) | |
{ | |
+ if (audio_driver_rewind_ptr == 0) | |
+ return; | |
audio_driver_rewind_buf[--audio_driver_rewind_ptr] = right; | |
audio_driver_rewind_buf[--audio_driver_rewind_ptr] = left; | |
} | |
@@ -762,7 +764,10 @@ size_t audio_driver_sample_batch_rewind(const int16_t *data, size_t frames) | |
size_t samples = frames << 1; | |
for (i = 0; i < samples; i++) | |
- audio_driver_rewind_buf[--audio_driver_rewind_ptr] = data[i]; | |
+ { | |
+ if (audio_driver_rewind_ptr > 0) | |
+ audio_driver_rewind_buf[--audio_driver_rewind_ptr] = data[i]; | |
+ } | |
return frames; | |
} | |
@@ -842,17 +847,18 @@ void audio_driver_monitor_adjust_system_rates(void) | |
void audio_driver_setup_rewind(void) | |
{ | |
unsigned i; | |
- | |
/* Push audio ready to be played. */ | |
audio_driver_rewind_ptr = audio_driver_rewind_size; | |
for (i = 0; i < audio_driver_data_ptr; i += 2) | |
{ | |
- audio_driver_rewind_buf[--audio_driver_rewind_ptr] = | |
- audio_driver_output_samples_conv_buf[i + 1]; | |
+ if (audio_driver_rewind_ptr > 0) | |
+ audio_driver_rewind_buf[--audio_driver_rewind_ptr] = | |
+ audio_driver_output_samples_conv_buf[i + 1]; | |
- audio_driver_rewind_buf[--audio_driver_rewind_ptr] = | |
- audio_driver_output_samples_conv_buf[i + 0]; | |
+ if (audio_driver_rewind_ptr > 0) | |
+ audio_driver_rewind_buf[--audio_driver_rewind_ptr] = | |
+ audio_driver_output_samples_conv_buf[i + 0]; | |
} | |
audio_driver_data_ptr = 0; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment