changeset 23809:6c348181fb20

Somewhat hackish fix for A-V desync with ao_oss and frame stepping: send 0-samples according to the amount of data lost during pause.
author reimar
date Thu, 19 Jul 2007 19:15:59 +0000
parents f689ce781c5d
children f95a8440cbfc
files libao2/ao_oss.c
diffstat 1 files changed, 9 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/libao2/ao_oss.c	Thu Jul 19 17:15:56 2007 +0000
+++ b/libao2/ao_oss.c	Thu Jul 19 19:15:59 2007 +0000
@@ -147,6 +147,7 @@
 static char *dsp=PATH_DEV_DSP;
 static audio_buf_info zz;
 static int audio_fd=-1;
+static int prepause_space;
 
 static const char *oss_mixer_device = PATH_DEV_MIXER;
 static int oss_mixer_channel = SOUND_MIXER_PCM;
@@ -448,13 +449,21 @@
 // stop playing, keep buffers (for pause)
 static void audio_pause(void)
 {
+    prepause_space = get_space();
     uninit(1);
 }
 
 // resume playing, after audio_pause()
 static void audio_resume(void)
 {
+    int fillcnt;
     reset();
+    fillcnt = get_space() - prepause_space;
+    if (fillcnt > 0) {
+      void *silence = calloc(fillcnt, 1);
+      play(silence, fillcnt, 0);
+      free(silence);
+    }
 }