Hello,

Sekmadienis 01 Lapkritis 2015 22:43:17 rašė:
> reopen 734100
> thanks
> 
> On Sunday 01 November 2015 22:03:41 Modestas Vainius wrote:
> > Hello,
> > 
> > Sekmadienis 01 Lapkritis 2015 18:10:54 rašė:
> > > tags 734100 + fixed-upstream
> > > thanks
> > > 
> > > This should be fixed in upstream VLC 3.0.
> > 
> > Thanks a lot. Could this package be backported to current packages?
> 
> VLC 3.0 is nowhere near release at this point in time. This is up to the
> Debian Multimedia team, not me, but I would not advise uploading it to
> unstable. And I do not know if there are enough human resources to maintain
> an extra VLC 3.0 in experimental.

What I really meant was backporting of those patches to 2.2.1 packages. 
Patches seemed pretty "short" at the glance hence I tried to do that myself.

47f74a83c161173b0d15e95dab8ceb7c97de51b4.patch was strightforward, applies 
cleanly.

Unfortunately, 6ae2905ef7fbc7de3a3a4a1bdf8ad6df46ce570a wasn't that 
strightforward. Had to do some modifications: 1st hunk already there in 2.2.1, 
adapt DecoderPlayAudio hunks and remove the last 2 hunks (from DecoderThread 
routine) since those locks are not present there in 2.2.1 codebase. I attach 
both patches.

The end result builds fine and seems to fix the problem on my machine. Not 
sure if patches break anything on 2.2.1 (i.e. if they need anything else from 
3.0.0 to work properly). Rémi, maybe you could comment on that?

> 
> > This
> > problem has been annoying me for a long time and lately it got only worse.
> > Unfortunately, increasing dmix buffer has some unwanted side effects in
> > other apps (audio-video desync).
> 
> Either those other apps are buggy, or dmix is buggy. The audio delay value
> should account for the dmix buffer.
> 
> Also, PulseAudio is better at mixing multiple apps.

Well, yeah, but I kind of dislike PulseAudio since its inception. I'm slowly 
warming up to the idea that I may have to use it one day but that time has not 
come yet...

-- 
Modestas Vainius <modes...@vainius.eu>
diff --git a/modules/audio_output/alsa.c b/modules/audio_output/alsa.c
index 2d1f99e..4e9fd53 100644
--- a/modules/audio_output/alsa.c
+++ b/modules/audio_output/alsa.c
@@ -495,6 +495,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);
@@ -503,14 +512,22 @@ static int Start (audio_output_t *aout, audio_sample_format_t *restrict fmt)
         msg_Err (aout, "cannot set buffer duration: %s", snd_strerror (val));
         goto error;
     }
-
-    param = AOUT_MIN_PREPARE_TIME;
+#if 0
+    val = snd_pcm_hw_params_get_buffer_time (hw, &param, NULL);
+    if (val)
+    {
+        msg_Warn (aout, "cannot get buffer time: %s", snd_strerror(val));
+        param = AOUT_MIN_PREPARE_TIME;
+    }
+    else
+        param /= 2;
     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);
--- a/src/input/decoder.c
+++ b/src/input/decoder.c
@@ -1180,6 +1180,8 @@ static void DecoderPlayAudio( decoder_t
 
         if( unlikely(p_owner->b_paused != b_paused) )
             continue; /* race with input thread? retry... */
+        vlc_mutex_unlock( &p_owner->lock );
+
         if( p_aout == NULL )
             b_reject = true;
 
@@ -1199,7 +1201,6 @@ static void DecoderPlayAudio( decoder_t
 
         break;
     }
-    vlc_mutex_unlock( &p_owner->lock );
 }
 
 static void DecoderDecodeAudio( decoder_t *p_dec, block_t *p_block )
@@ -1961,11 +1962,10 @@ static int aout_update_format( decoder_t
 
         /* Parameters changed, restart the aout */
         vlc_mutex_lock( &p_owner->lock );
-
-        aout_DecDelete( p_owner->p_aout );
         p_owner->p_aout = NULL;
-
         vlc_mutex_unlock( &p_owner->lock );
+        aout_DecDelete( p_owner->p_aout );
+
         input_resource_PutAout( p_owner->p_resource, p_aout );
     }
 

Reply via email to