[vlc-commits] alsa: set period time before buffer time

Rémi Denis-Courmont git at videolan.org
Mon Aug 5 18:44:36 CEST 2013


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Mon Aug  5 19:43:57 2013 +0300| [6ee77139764919f0af8a8a15c8fc31cfdf571b05] | committer: Rémi Denis-Courmont

alsa: set period time before buffer time

Currently, the period time is more critical, so constrain it first.
Both values are interdependant with some drivers.

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

 modules/audio_output/alsa.c |   13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/modules/audio_output/alsa.c b/modules/audio_output/alsa.c
index 5c87c1e..9c2e46a 100644
--- a/modules/audio_output/alsa.c
+++ b/modules/audio_output/alsa.c
@@ -472,6 +472,15 @@ static int Start (audio_output_t *aout, audio_sample_format_t *restrict fmt)
     }
     sys->rate = fmt->i_rate;
 
+#if 1 /* work-around for period-long latency outputs (e.g. PulseAudio): */
+    param = AOUT_MIN_PREPARE_TIME;
+    val = snd_pcm_hw_params_set_period_time_near (pcm, hw, &param, NULL);
+    if (val)
+    {
+        msg_Err (aout, "cannot set period: %s", snd_strerror (val));
+        goto error;
+    }
+#endif
     /* Set buffer size */
     param = AOUT_MAX_ADVANCE_TIME;
     val = snd_pcm_hw_params_set_buffer_time_near (pcm, hw, &param, NULL);
@@ -489,15 +498,13 @@ static int Start (audio_output_t *aout, audio_sample_format_t *restrict fmt)
     }
     else
         param /= 2;
-#else /* work-around for period-long latency outputs (e.g. PulseAudio): */
-    param = AOUT_MIN_PREPARE_TIME;
-#endif
     val = snd_pcm_hw_params_set_period_time_near (pcm, hw, &param, NULL);
     if (val)
     {
         msg_Err (aout, "cannot set period: %s", snd_strerror (val));
         goto error;
     }
+#endif
 
     /* Commit hardware parameters */
     val = snd_pcm_hw_params (pcm, hw);



More information about the vlc-commits mailing list