aboutsummaryrefslogtreecommitdiff
path: root/src/audio.c
diff options
context:
space:
mode:
authortaw27 <taw27@84d2e878-0bd5-11dd-ad15-13eda11d74c5>2008-07-03 22:42:01 +0000
committertaw27 <taw27@84d2e878-0bd5-11dd-ad15-13eda11d74c5>2008-07-03 22:42:01 +0000
commitfea63a209b61b8c81185203f908f502ca788edeb (patch)
tree66ec1de84b4dfeb982e4f88c581106ece70f0866 /src/audio.c
parent054957c9b7d6e45f1dc8282da94c09e9d51dae1e (diff)
Rearrange last sample fudges
git-svn-id: svn://cook.msm.cam.ac.uk:745/thrust3d/thrust3d@128 84d2e878-0bd5-11dd-ad15-13eda11d74c5
Diffstat (limited to 'src/audio.c')
-rw-r--r--src/audio.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/audio.c b/src/audio.c
index 9cfc384..8c4eadf 100644
--- a/src/audio.c
+++ b/src/audio.c
@@ -60,7 +60,7 @@ static void audio_mix(void *data, Uint8 *stream8, int len) {
stream[j] += samp * a->sounds[i].volume;
}
- if ( a->sounds[i].dpos == a->sounds[i].dlen-2 ) {
+ if ( a->sounds[i].dpos == a->sounds[i].dlen ) {
if ( a->sounds[i].repeat ) {
a->sounds[i].dpos = 0;
if ( a->debug ) printf("AU: Channel %i: Looping at offset %i/%i\n", i, j, len);
@@ -137,7 +137,8 @@ static void *audio_play_wav(void *add_void) {
/* Put the sound data in the slot */
a->sounds[idx].data = (Sint16 *)cvt.buf;
- a->sounds[idx].dlen = cvt.len_cvt / 2;
+ /* Not entirely sure whose fault it is that the last (stereo) sample is wrong */
+ a->sounds[idx].dlen = cvt.len_cvt / 2 - 2; /* Convert bytes to samples */
a->sounds[idx].dpos = 0;
a->sounds[idx].repeat = add->repeat;
a->sounds[idx].volume = add->volume;
@@ -225,7 +226,8 @@ static void *audio_play_vorbis(void *add_void) {
/* Put the sound data in the slot */
a->sounds[idx].data = (Sint16 *)cvt.buf;
- a->sounds[idx].dlen = cvt.len_cvt / 2;
+ /* Assuming that the same dud last (stereo) sample occurs here. This may not be the case. */
+ a->sounds[idx].dlen = cvt.len_cvt / 2 - 2;
a->sounds[idx].dpos = 0;
a->sounds[idx].repeat = add->repeat;
a->sounds[idx].volume = add->volume;