aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authortaw27 <taw27@84d2e878-0bd5-11dd-ad15-13eda11d74c5>2008-07-22 23:32:08 +0000
committertaw27 <taw27@84d2e878-0bd5-11dd-ad15-13eda11d74c5>2008-07-22 23:32:08 +0000
commit8e16e1f335f019391e9a6cdbaf9f77f0f55e1b1d (patch)
tree2b6cacba9cd0a0cd118e589c3892502aa0f7b2fa /src
parent8c2f7a4c43d8fca38beb9a2adc68afd662946b12 (diff)
Audio tweaks. I still don't understand...
git-svn-id: svn://cook.msm.cam.ac.uk:745/thrust3d/thrust3d@154 84d2e878-0bd5-11dd-ad15-13eda11d74c5
Diffstat (limited to 'src')
-rw-r--r--src/audio.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/src/audio.c b/src/audio.c
index bc66d83..45efa47 100644
--- a/src/audio.c
+++ b/src/audio.c
@@ -25,6 +25,8 @@
#include "types.h"
+int ppp = 0;
+
static void audio_mix(void *data, Uint8 *stream8, int len) {
AudioContext *a = data;
@@ -73,6 +75,9 @@ static void audio_mix(void *data, Uint8 *stream8, int len) {
break;
}
}
+ //if ( (i==0) && !(ppp++ % 10000) ) {
+ // printf("%li / %li (%.2f%%)\n", a->sounds[i].dpos, a->sounds[i].dlen, (double)a->sounds[i].dpos*100.0/a->sounds[i].dlen);
+ //}
}
@@ -229,7 +234,6 @@ static void *audio_play_vorbis(void *add_void) {
decode_block_samples = len - decode_samples_done;
decode_done = 1;
}
- if ( a->debug ) printf("AU: Channel %i: Decoding %li samples this time\n", idx, decode_block_samples);
decode_block_length = vi->channels*2*decode_block_samples;
decode_samples_done += decode_block_samples;
@@ -256,18 +260,21 @@ static void *audio_play_vorbis(void *add_void) {
a->sounds[idx].data = malloc(len*vi->channels*2);
}
memcpy(a->sounds[idx].data+a->sounds[idx].decode_pos, cvt.buf, cvt.len_cvt);
- /* I have ABSOLUTELY NO IDEA why the division by two is needed. Anyone? */
a->sounds[idx].decode_pos += cvt.len_cvt / 2;
/* It's safe to start playing at this point */
if ( !a->sounds[idx].playing ) {
- a->sounds[idx].dlen = vi->channels*(len-1);
+ a->sounds[idx].dlen = 2*(len-1);
a->sounds[idx].dpos = 0;
a->sounds[idx].repeat = add->repeat;
a->sounds[idx].volume = add->volume;
a->sounds[idx].playing = 1; /* Must be done last - tell the mixer thread it can use this */
}
+ if ( a->debug ) printf("AU: Channel %i: Decoded %li samples this time. "
+ "I am now %.1f seconds ahead of the playing position.\n",
+ idx, decode_block_samples, ((double)a->sounds[idx].decode_pos-(2*a->sounds[idx].dpos))/(44100*2*2));
+
/* Sleep for eight seconds while periodically checking for shutdown */
for ( w=0; w<80; w++ ) {
if ( a->shutdown ) {