aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authortaw27 <taw27@84d2e878-0bd5-11dd-ad15-13eda11d74c5>2008-07-24 15:07:53 +0000
committertaw27 <taw27@84d2e878-0bd5-11dd-ad15-13eda11d74c5>2008-07-24 15:07:53 +0000
commit629c0e0b26f739dba68b103fcfb37b42fe2c8666 (patch)
tree321b6830af9885020393b2fa758fc7427439fe30 /src
parent0ec7281bf5890e56265d1eb95036ae75ff88b7bf (diff)
Detect Vorbis buffer underruns
git-svn-id: svn://cook.msm.cam.ac.uk:745/thrust3d/thrust3d@166 84d2e878-0bd5-11dd-ad15-13eda11d74c5
Diffstat (limited to 'src')
-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: