[vlc-commits] ALSA: fix time measurements

Rémi Denis-Courmont git at videolan.org
Wed Nov 14 19:35:01 CET 2012


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Wed Nov 14 20:32:06 2012 +0200| [8c3486529655569fb4e695caa835cafd37072a2f] | committer: Rémi Denis-Courmont

ALSA: fix time measurements

The latency needs to be returned also when not (yet) running to start
playback on time (the audio output core inserts zeroes accordingly).

Also, then there is no point to using PCM status, as only one single
parameter is used. This simplifies the code and works around a bug
(probably in ALSA plugin framework) whereby delay was always zero
when using the ALSA<->PulseAudio I/O plugin.

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=8c3486529655569fb4e695caa835cafd37072a2f
---

 modules/audio_output/alsa.c |   16 ++++------------
 1 file changed, 4 insertions(+), 12 deletions(-)

diff --git a/modules/audio_output/alsa.c b/modules/audio_output/alsa.c
index 4ed251d..f8857f7 100644
--- a/modules/audio_output/alsa.c
+++ b/modules/audio_output/alsa.c
@@ -545,22 +545,14 @@ error:
 static int TimeGet (audio_output_t *aout, mtime_t *restrict pts)
 {
     aout_sys_t *sys = aout->sys;
-    snd_pcm_t *pcm = sys->pcm;
-    snd_pcm_status_t *status;
-    int val;
+    snd_pcm_sframes_t frames;
 
-    snd_pcm_status_alloca (&status);
-    val = snd_pcm_status (pcm, status);
-    if (val < 0)
+    int val = snd_pcm_delay (sys->pcm, &frames);
+    if (val)
     {
-        msg_Err (aout, "cannot get status: %s", snd_strerror (val));
+        msg_Err (aout, "cannot estimate delay: %s", snd_strerror (val));
         return -1;
     }
-
-    if (snd_pcm_status_get_state (status) != SND_PCM_STATE_RUNNING)
-        return -1;
-
-    snd_pcm_sframes_t frames = snd_pcm_status_get_delay (status);
     *pts = mdate () + (frames * CLOCK_FREQ / sys->format.i_rate);
     return 0;
 }



More information about the vlc-commits mailing list