aboutsummaryrefslogtreecommitdiff
path: root/src/audio.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/audio.c')
-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 ) {