[vlc-commits] [Git][videolan/vlc][master] 4 commits: es_out: fix input_source_t leak on error

Thomas Guillem gitlab at videolan.org
Tue Jun 1 13:51:54 UTC 2021



Thomas Guillem pushed to branch master at VideoLAN / VLC


Commits:
67fe08b7 by Thomas Guillem at 2021-06-01T13:08:14+00:00
es_out: fix input_source_t leak on error

- - - - -
07e78801 by Thomas Guillem at 2021-06-01T13:08:14+00:00
clock: attach a logger

- - - - -
ef14ac9a by Thomas Guillem at 2021-06-01T13:08:14+00:00
clock: expose CR_MAX_GAP internally

- - - - -
c56c3f3f by Thomas Guillem at 2021-06-01T13:08:14+00:00
clock: check for pcr_delay validity

Don't wait more than CR_MAX_GAP. The CR_MAX_GAP might be too big
(60 seconds). This algorithm, like the one in input_clock.c could be
improved by comparing stream and system date.

This a work around buggy demuxers or corrupted samples/streams. That is
the reason that the new log should draw attention to developers.

- - - - -


5 changed files:

- src/clock/clock.c
- src/clock/clock.h
- src/clock/clock_internal.h
- src/clock/input_clock.c
- src/input/es_out.c


Changes:

=====================================
src/clock/clock.c
=====================================
@@ -30,6 +30,7 @@
 
 struct vlc_clock_main_t
 {
+    struct vlc_logger *logger;
     vlc_mutex_t lock;
     vlc_cond_t cond;
 
@@ -234,11 +235,17 @@ vlc_clock_monotonic_to_system_locked(vlc_clock_t *clock, vlc_tick_t now,
          * ride of the input clock. This code is adapted from input_clock.c and
          * is used to introduce the same delay than the input clock (first PTS
          * - first PCR). */
-        const vlc_tick_t pcr_delay =
+        vlc_tick_t pcr_delay =
             main_clock->first_pcr.system == VLC_TICK_INVALID ? 0 :
             (ts - main_clock->first_pcr.stream) / rate +
             main_clock->first_pcr.system - now;
 
+        if (pcr_delay > CR_MAX_GAP)
+        {
+            vlc_error(main_clock->logger, "Invalid PCR delay ! Ignoring it...");
+            pcr_delay = 0;
+        }
+
         const vlc_tick_t input_delay = main_clock->input_dejitter + pcr_delay;
 
         const vlc_tick_t delay =
@@ -359,13 +366,20 @@ void vlc_clock_Wait(vlc_clock_t *clock, vlc_tick_t system_now, vlc_tick_t ts,
     vlc_mutex_unlock(&main_clock->lock);
 }
 
-vlc_clock_main_t *vlc_clock_main_New(void)
+vlc_clock_main_t *vlc_clock_main_New(struct vlc_logger *parent_logger)
 {
     vlc_clock_main_t *main_clock = malloc(sizeof(vlc_clock_main_t));
 
     if (main_clock == NULL)
         return NULL;
 
+    main_clock->logger = vlc_LogHeaderCreate(parent_logger, "clock");
+    if (main_clock->logger == NULL)
+    {
+        free(main_clock);
+        return NULL;
+    }
+
     vlc_mutex_init(&main_clock->lock);
     vlc_cond_init(&main_clock->cond);
     main_clock->input_master = main_clock->master = NULL;
@@ -473,6 +487,7 @@ void vlc_clock_main_ChangePause(vlc_clock_main_t *main_clock, vlc_tick_t now,
 void vlc_clock_main_Delete(vlc_clock_main_t *main_clock)
 {
     assert(main_clock->rc == 1);
+    vlc_LogDestroy(main_clock->logger);
     free(main_clock);
 }
 


=====================================
src/clock/clock.h
=====================================
@@ -58,7 +58,7 @@ struct vlc_clock_cbs
 /**
  * This function creates the vlc_clock_main_t of the program
  */
-vlc_clock_main_t *vlc_clock_main_New(void);
+vlc_clock_main_t *vlc_clock_main_New(struct vlc_logger *parent_logger);
 
 /**
  * Destroy the clock main


=====================================
src/clock/clock_internal.h
=====================================
@@ -26,6 +26,9 @@
 
 #include <vlc_common.h>
 
+/* Maximum gap allowed between two CRs. */
+#define CR_MAX_GAP VLC_TICK_FROM_SEC(60)
+
 /*****************************************************************************
  * Structures
  *****************************************************************************/


=====================================
src/clock/input_clock.c
=====================================
@@ -78,9 +78,6 @@
  * Constants
  *****************************************************************************/
 
-/* Maximum gap allowed between two CRs. */
-#define CR_MAX_GAP VLC_TICK_FROM_SEC(60)
-
 /* Latency introduced on DVDs with CR == 0 on chapter change - this is from
  * my dice --Meuuh */
 #define CR_MEAN_PTS_GAP VLC_TICK_FROM_MS(300)


=====================================
src/input/es_out.c
=====================================
@@ -1446,7 +1446,7 @@ static es_out_pgrm_t *EsOutProgramAdd( es_out_t *out, input_source_t *source, in
         return NULL;
 
     /* Init */
-    p_pgrm->source = input_source_Hold( source );
+    p_pgrm->source = source;
     p_pgrm->i_id = i_group;
     p_pgrm->i_es = 0;
     p_pgrm->b_selected = false;
@@ -1455,7 +1455,7 @@ static es_out_pgrm_t *EsOutProgramAdd( es_out_t *out, input_source_t *source, in
     p_pgrm->p_meta = NULL;
     p_pgrm->active_clock_source = VLC_CLOCK_MASTER_AUTO;
 
-    p_pgrm->p_main_clock = vlc_clock_main_New();
+    p_pgrm->p_main_clock = vlc_clock_main_New( p_input->obj.logger );
     if( !p_pgrm->p_main_clock )
     {
         free( p_pgrm );
@@ -1492,6 +1492,8 @@ static es_out_pgrm_t *EsOutProgramAdd( es_out_t *out, input_source_t *source, in
     if( i_group == p_sys->i_group_id || ( !p_sys->p_pgrm && p_sys->i_group_id == 0 ) )
         EsOutProgramSelect( out, p_pgrm );
 
+    input_source_Hold( source );
+
     return p_pgrm;
 }
 



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/36596846205e64cb0c529586c50a4f3789a5c206...c56c3f3fbb68ec6fc24f0c35511559ecd35965d0

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




More information about the vlc-commits mailing list