[MPlayer-dev-eng] [PATCH] Keep audio buffer for OSS

Mikulas Patocka mikulas at artax.karlin.mff.cuni.cz
Mon Aug 2 17:05:36 CEST 2004


Hi

audio_pause and audio_resume should keep data in audio buffer. However
they don't do it for OSS audio driver. This causes problem that if the
audio buffer is X seconds large, the movie skips X seconds forward on each
pause/unpause operation.

This patch fixes it --- it uses OSS trigger function (and falls back to
old method if the driver doesn't support it), so that it audio data are
being held in the buffer.

Mikulas
-------------- next part --------------
--- ../mplayer-1.0pre4-bak/libao2/ao_oss.c	2004-04-06 18:55:36.000000000 +0100
+++ libao2/ao_oss.c	2004-08-01 20:44:57.000000000 +0100
@@ -306,12 +306,30 @@
 // stop playing, keep buffers (for pause)
 static void audio_pause()
 {
+#if defined(SNDCTL_DSP_GETCAPS) && defined(DSP_CAP_TRIGGER) && defined(SNDCTL_DSP_GETTRIGGER) && defined(SNDCTL_DSP_SETTRIGGER)
+    int c;
+    if (ioctl(audio_fd, SNDCTL_DSP_GETCAPS, &c) || !(c & DSP_CAP_TRIGGER)) goto stop;
+    if (ioctl(audio_fd, SNDCTL_DSP_GETTRIGGER, &c)) goto stop;
+    c &= ~PCM_ENABLE_OUTPUT;
+    if (ioctl(audio_fd, SNDCTL_DSP_SETTRIGGER, &c)) goto stop;
+    return;
+    stop:
+#endif
     uninit(1);
 }
 
 // resume playing, after audio_pause()
 static void audio_resume()
 {
+#if defined(SNDCTL_DSP_GETCAPS) && defined(DSP_CAP_TRIGGER) && defined(SNDCTL_DSP_GETTRIGGER) && defined(SNDCTL_DSP_SETTRIGGER)
+    int c;
+    if (ioctl(audio_fd, SNDCTL_DSP_GETCAPS, &c) || !(c & DSP_CAP_TRIGGER)) goto stop;
+    if (ioctl(audio_fd, SNDCTL_DSP_GETTRIGGER, &c)) goto stop;
+    c |= PCM_ENABLE_OUTPUT;
+    if (ioctl(audio_fd, SNDCTL_DSP_SETTRIGGER, &c)) goto stop;
+    return;
+    stop:
+#endif
     reset();
 }
 


More information about the MPlayer-dev-eng mailing list