[vlc-commits] Fix flawed logic

Rémi Denis-Courmont git at videolan.org
Sat Jul 23 19:43:09 CEST 2011


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Sat Jul 23 20:42:49 2011 +0300| [9b9dd16dcccc11b9e87fec79d477871ef382fbc4] | committer: Rémi Denis-Courmont

Fix flawed logic

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

 modules/audio_output/pulse.c |   14 +++++++-------
 1 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/modules/audio_output/pulse.c b/modules/audio_output/pulse.c
index a21f50a..ea6bb15 100644
--- a/modules/audio_output/pulse.c
+++ b/modules/audio_output/pulse.c
@@ -193,14 +193,14 @@ static void stream_latency_cb(pa_stream *s, void *userdata)
     if (adj < -ADJUST_MAX)
         adj = -ADJUST_MAX;
 
-    if (abs(adj) < (inrate >> 10))
-        adj = 0; /* favor native rate to avoid resampling */
+    unsigned outrate = sys->rate - adj;
+    /* Favor native rate to avoid resampling (FIXME: really a good idea?) */
+    if (abs(outrate - inrate) < (inrate >> 10))
+        outrate = inrate;
 
     /* This keeps the effective rate within specified range
      * (+/-AOUT_MAX_RESAMPLING% - see <vlc_aout.h>) of the nominal rate. */
-    unsigned outrate = inrate - adj;
     const int limit = inrate * AOUT_MAX_RESAMPLING / 100;
-
     if (outrate > inrate + limit)
         outrate = inrate + limit;
     if (outrate < inrate - limit)
@@ -391,9 +391,9 @@ static void Play(aout_instance_t *aout)
         msg_Dbg(aout, "uncorking");
     }
 
-#if 0 /* Fault injector to test underrun recovery */
-    static unsigned u = 0;
-    if ((++u % 500) == 0) {
+#if 1 /* Fault injector to test underrun recovery */
+    static volatile unsigned u = 0;
+    if ((++u % 1000) == 0) {
         msg_Err(aout, "fault injection");
         pa_operation_unref(pa_stream_flush(s, NULL, NULL));
     }



More information about the vlc-commits mailing list