aboutsummaryrefslogtreecommitdiff
path: root/src/audio.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/audio.c')
-rw-r--r--src/audio.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/audio.c b/src/audio.c
index ba37289..cc963b6 100644
--- a/src/audio.c
+++ b/src/audio.c
@@ -52,7 +52,13 @@ static void audio_mix(void *data, Uint8 *stream8, int len) {
Sint16 samp;
Sint32 test;
- samp = a->sounds[i].data[a->sounds[i].dpos++];
+ if ( (a->sounds[i].decode_pos == 0) || (a->sounds[i].dpos < a->sounds[i].decode_pos) ) {
+ samp = a->sounds[i].data[a->sounds[i].dpos++];
+ } else {
+ if ( a->debug ) printf("AU: Channel %i: Decoding thread underran\n", i);
+ samp = 0;
+ }
+
test = stream[j] + samp*a->sounds[i].volume;
if ( test > 32767 ) {
if ( stream[j] != 32767 ) {
@@ -156,6 +162,7 @@ static void *audio_play_wav(void *add_void) {
a->sounds[idx].dpos = 0;
a->sounds[idx].repeat = add->repeat;
a->sounds[idx].volume = add->volume;
+ a->sounds[idx].decode_pos = 0;
a->sounds[idx].playing = 1; /* Must be done last - tell the mixer thread it can use this */
out: