[vlc-commits] [Git][videolan/vlc][master] 2 commits: Revert "es_out: restore the previous ES_OUT_SET_PCR behavior"

Rémi Denis-Courmont (@Courmisch) gitlab at videolan.org
Tue Mar 22 18:34:10 UTC 2022



Rémi Denis-Courmont pushed to branch master at VideoLAN / VLC


Commits:
91111920 by Thomas Guillem at 2022-03-22T18:18:42+00:00
Revert "es_out: restore the previous ES_OUT_SET_PCR behavior"

Racy with threaded demuxers.

This reverts commit 88ad68a96184c5faf4a31d65c99544a7bb4eef1b.

Refs #26716

- - - - -
203b1972 by Thomas Guillem at 2022-03-22T18:18:42+00:00
es_out: fix automatic clock selection

When the PCR is sent before the module probe function finishes (threaded
modules).

Fixes #26716

- - - - -


1 changed file:

- src/input/es_out.c


Changes:

=====================================
src/input/es_out.c
=====================================
@@ -1317,17 +1317,19 @@ static void EsOutProgramHandleClockSource( es_out_t *out, es_out_pgrm_t *p_pgrm
     /* XXX: The clock source selection depends on input_CanPaceControl() but
      * this variable is only initialized from the input_thread_t after the
      * demux is opened. Programs and ES tracks can be created from the demux
-     * open callback or midstream (from the demux callback). Therefore, we
-     * can't handle the clock source selection after the program is created
-     * since input_CanPaceControl() might not be initialized. To fix this
-     * issue, handle clock source selection after/when the es_out is activated
-     * (from ES_OUT_PRIV_SET_MODE) or when a program is created. */
-    assert( p_sys->b_active );
+     * open callback or midstream (from the demux callback). To fix this issue,
+     * handle clock source selection when the first PCR is sent (from
+     * ES_OUT_SET_PCR). */
 
     switch( p_sys->user_clock_source )
     {
         case VLC_CLOCK_MASTER_AUTO:
-            if (input_CanPaceControl(p_input))
+            /* If not active, input_CanPaceControl() returns an uninitialized
+             * value. If not active while sending a PCR, it means the demux
+             * module is pacing itself (via a thread or API callbacks).
+             * Therefore, we can assume that the input can't control its pace.
+             * */
+            if( p_sys->b_active && input_CanPaceControl( p_input ) )
             {
                 p_pgrm->active_clock_source = VLC_CLOCK_MASTER_AUDIO;
                 break;
@@ -1522,9 +1524,6 @@ static es_out_pgrm_t *EsOutProgramAdd( es_out_t *out, input_source_t *source, in
         return NULL;
     }
 
-    if( p_sys->b_active )
-        EsOutProgramHandleClockSource( out, p_pgrm );
-
     if( p_sys->b_paused )
         input_clock_ChangePause( p_pgrm->p_input_clock, p_sys->b_paused, p_sys->i_pause_date );
     const vlc_tick_t pts_delay = p_sys->i_pts_delay + p_sys->i_pts_jitter
@@ -3354,6 +3353,12 @@ static int EsOutVaControlLocked( es_out_t *out, input_source_t *source,
         if( !p_pgrm )
             return VLC_EGENERIC;
 
+        if( p_pgrm->active_clock_source == VLC_CLOCK_MASTER_AUTO )
+        {
+            EsOutProgramHandleClockSource( out, p_pgrm );
+            assert( p_pgrm->active_clock_source != VLC_CLOCK_MASTER_AUTO );
+        }
+
         i_pcr = va_arg( args, vlc_tick_t );
         if( i_pcr == VLC_TICK_INVALID )
         {
@@ -3701,19 +3706,6 @@ static int EsOutVaPrivControlLocked( es_out_t *out, int query, va_list args )
         p_sys->b_active = i_mode != ES_OUT_MODE_NONE;
         p_sys->i_mode = i_mode;
 
-        if( p_sys->b_active && i_mode != ES_OUT_MODE_END )
-        {
-            es_out_pgrm_t *p_pgrm;
-            vlc_list_foreach(p_pgrm, &p_sys->programs, node)
-            {
-                if( p_pgrm->active_clock_source == VLC_CLOCK_MASTER_AUTO )
-                {
-                    EsOutProgramHandleClockSource( out, p_pgrm );
-                    assert( p_pgrm->active_clock_source != VLC_CLOCK_MASTER_AUTO );
-                }
-            }
-        }
-
         /* Reapply policy mode */
         es_out_id_t *es;
 



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/ac95bf19f9991f506170a3dcb3c57268cb944727...203b197211f0fe83e29cc27549ed12a0e2b03eac

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/ac95bf19f9991f506170a3dcb3c57268cb944727...203b197211f0fe83e29cc27549ed12a0e2b03eac
You're receiving this email because of your account on code.videolan.org.


VideoLAN code repository instance


More information about the vlc-commits mailing list