[vlc-commits] demux: ps: split seen / configured states

Francois Cartegnie git at videolan.org
Fri Mar 31 14:52:07 CEST 2017


vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Fri Mar 31 14:26:33 2017 +0200| [964b5422bb1cb85313f4c553b54d3ab2a649b5bb] | committer: Francois Cartegnie

demux: ps: split seen / configured states

b_seen was misused for both stream presence
and after configuration

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

 modules/access/dvdnav.c  | 16 ++++++++--------
 modules/access/dvdread.c | 14 +++++++-------
 modules/demux/mpeg/ps.c  | 11 ++++++-----
 modules/demux/mpeg/ps.h  | 12 +++++++-----
 4 files changed, 28 insertions(+), 25 deletions(-)

diff --git a/modules/access/dvdnav.c b/modules/access/dvdnav.c
index c8413eb..c061169 100644
--- a/modules/access/dvdnav.c
+++ b/modules/access/dvdnav.c
@@ -534,7 +534,7 @@ static void Close( vlc_object_t *p_this )
     for( int i = 0; i < PS_TK_COUNT; i++ )
     {
         ps_track_t *tk = &p_sys->tk[i];
-        if( tk->b_seen )
+        if( tk->b_configured )
         {
             es_format_Clean( &tk->fmt );
             if( tk->es ) es_out_Del( p_demux->out, tk->es );
@@ -942,12 +942,12 @@ static int Demux( demux_t *p_demux )
         for( int i = 0; i < PS_TK_COUNT; i++ )
         {
             ps_track_t *tk = &p_sys->tk[i];
-            if( tk->b_seen )
+            if( tk->b_configured )
             {
                 es_format_Clean( &tk->fmt );
                 if( tk->es ) es_out_Del( p_demux->out, tk->es );
             }
-            tk->b_seen = false;
+            tk->b_configured = false;
         }
 
         uint32_t i_width, i_height;
@@ -1316,7 +1316,7 @@ static void ESSubtitleUpdate( demux_t *p_demux )
         for( i_spu = 0; i_spu <= 0x1F; i_spu++ )
         {
             ps_track_t *tk = &p_sys->tk[PS_ID_TO_TK(0xbd20 + i_spu)];
-            if( tk->b_seen )
+            if( tk->b_configured )
             {
                 es_out_Control( p_demux->out, ES_OUT_SET_ES_STATE, tk->es,
                                 (bool)false );
@@ -1382,11 +1382,11 @@ static int DemuxBlock( demux_t *p_demux, const uint8_t *p, int len )
             {
                 ps_track_t *tk = &p_sys->tk[PS_ID_TO_TK(i_id)];
 
-                if( !tk->b_seen )
+                if( !tk->b_configured )
                 {
                     ESNew( p_demux, i_id );
                 }
-                if( tk->b_seen && tk->es &&
+                if( tk->b_configured && tk->es &&
                     !ps_pkt_parse_pes( VLC_OBJECT(p_demux), p_pkt, tk->i_skip ) )
                 {
                     es_out_Send( p_demux->out, tk->es, p_pkt );
@@ -1436,7 +1436,7 @@ static void ESNew( demux_t *p_demux, int i_id )
     ps_track_t  *tk = &p_sys->tk[PS_ID_TO_TK(i_id)];
     bool  b_select = false;
 
-    if( tk->b_seen ) return;
+    if( tk->b_configured ) return;
 
     if( ps_track_fill( tk, 0, i_id, NULL ) )
     {
@@ -1518,7 +1518,7 @@ static void ESNew( demux_t *p_demux, int i_id )
     {
         es_out_Control( p_demux->out, ES_OUT_SET_ES, tk->es );
     }
-    tk->b_seen = true;
+    tk->b_configured = true;
 
     if( tk->fmt.i_cat == VIDEO_ES ) ButtonUpdate( p_demux, false );
 }
diff --git a/modules/access/dvdread.c b/modules/access/dvdread.c
index 972bea9..51e9ef8 100644
--- a/modules/access/dvdread.c
+++ b/modules/access/dvdread.c
@@ -257,7 +257,7 @@ static void Close( vlc_object_t *p_this )
     for( int i = 0; i < PS_TK_COUNT; i++ )
     {
         ps_track_t *tk = &p_sys->tk[i];
-        if( tk->b_seen )
+        if( tk->b_configured )
         {
             es_format_Clean( &tk->fmt );
             if( tk->es ) es_out_Del( p_demux->out, tk->es );
@@ -609,11 +609,11 @@ static int DemuxBlock( demux_t *p_demux, const uint8_t *p, int len )
             {
                 ps_track_t *tk = &p_sys->tk[PS_ID_TO_TK(i_id)];
 
-                if( !tk->b_seen )
+                if( !tk->b_configured )
                 {
                     ESNew( p_demux, i_id, 0 );
                 }
-                if( tk->b_seen && tk->es &&
+                if( tk->b_configured && tk->es &&
                     !ps_pkt_parse_pes( VLC_OBJECT(p_demux), p_pkt, tk->i_skip ) )
                 {
                     es_out_Send( p_demux->out, tk->es, p_pkt );
@@ -647,7 +647,7 @@ static void ESNew( demux_t *p_demux, int i_id, int i_lang )
     ps_track_t  *tk = &p_sys->tk[PS_ID_TO_TK(i_id)];
     char psz_language[3];
 
-    if( tk->b_seen ) return;
+    if( tk->b_configured ) return;
 
     if( ps_track_fill( tk, 0, i_id, NULL ) )
     {
@@ -704,7 +704,7 @@ static void ESNew( demux_t *p_demux, int i_id, int i_lang )
     }
 
     tk->es = es_out_Add( p_demux->out, &tk->fmt );
-    tk->b_seen = true;
+    tk->b_configured = true;
 }
 
 /*****************************************************************************
@@ -841,12 +841,12 @@ static int DvdReadSetArea( demux_t *p_demux, int i_title, int i_chapter,
         for( int i = 0; i < PS_TK_COUNT; i++ )
         {
             ps_track_t *tk = &p_sys->tk[i];
-            if( tk->b_seen )
+            if( tk->b_configured )
             {
                 es_format_Clean( &tk->fmt );
                 if( tk->es ) es_out_Del( p_demux->out, tk->es );
             }
-            tk->b_seen = false;
+            tk->b_configured = false;
         }
 
         if( p_demux->info.i_title != i_title )
diff --git a/modules/demux/mpeg/ps.c b/modules/demux/mpeg/ps.c
index 75d3512..84ba513 100644
--- a/modules/demux/mpeg/ps.c
+++ b/modules/demux/mpeg/ps.c
@@ -256,7 +256,7 @@ static void Close( vlc_object_t *p_this )
     for( i = 0; i < PS_TK_COUNT; i++ )
     {
         ps_track_t *tk = &p_sys->tk[i];
-        if( tk->b_seen )
+        if( tk->b_configured )
         {
             es_format_Clean( &tk->fmt );
             if( tk->es ) es_out_Del( p_demux->out, tk->es );
@@ -383,7 +383,7 @@ static void NotifyDiscontinuity( ps_track_t *p_tk, es_out_t *out )
     for( size_t i = 0; i < PS_TK_COUNT; i++ )
     {
         ps_track_t *tk = &p_tk[i];
-        if( tk->b_seen && tk->es &&
+        if( tk->b_configured && tk->es &&
                 es_out_Control( out, ES_OUT_GET_ES_STATE, tk->es, &b_selected ) == VLC_SUCCESS
                 && b_selected )
         {
@@ -472,6 +472,7 @@ static int Demux( demux_t *p_demux )
                 if( tk->b_seen && !tk->es && tk->fmt.i_cat != UNKNOWN_ES )
                 {
                     tk->es = es_out_Add( p_demux->out, &tk->fmt );
+                    tk->b_configured = true;
                 }
             }
         }
@@ -514,7 +515,7 @@ static int Demux( demux_t *p_demux )
             bool b_new = false;
             ps_track_t *tk = &p_sys->tk[PS_ID_TO_TK(i_id)];
 
-            if( !tk->b_seen )
+            if( !tk->b_configured )
             {
                 if( !ps_track_fill( tk, &p_sys->psm, i_id, p_pkt ) )
                 {
@@ -537,7 +538,7 @@ static int Demux( demux_t *p_demux )
 
                     tk->es = es_out_Add( p_demux->out, &tk->fmt );
                     b_new = true;
-                    tk->b_seen = true;
+                    tk->b_configured = true;
                 }
                 else
                 {
@@ -569,7 +570,7 @@ static int Demux( demux_t *p_demux )
                     es_out_Control( p_demux->out, ES_OUT_SET_PCR, VLC_TS_0 + p_sys->i_pack_scr );
             }
 
-            if( tk->b_seen && tk->es &&
+            if( tk->b_configured && tk->es &&
                 !ps_pkt_parse_pes( VLC_OBJECT(p_demux), p_pkt, tk->i_skip ) )
             {
                 if( tk->fmt.i_cat == AUDIO_ES || tk->fmt.i_cat == VIDEO_ES )
diff --git a/modules/demux/mpeg/ps.h b/modules/demux/mpeg/ps.h
index e7ecbfe..2a72820 100644
--- a/modules/demux/mpeg/ps.h
+++ b/modules/demux/mpeg/ps.h
@@ -61,7 +61,8 @@ static inline const uint8_t *ps_id_to_lang( const ps_psm_t *, int );
 
 typedef struct
 {
-    bool  b_seen;
+    bool        b_configured;
+    bool        b_seen;
     int         i_skip;
     int         i_id;
     int         i_next_block_flags;
@@ -78,6 +79,7 @@ static inline void ps_track_init( ps_track_t tk[PS_TK_COUNT] )
     int i;
     for( i = 0; i < PS_TK_COUNT; i++ )
     {
+        tk[i].b_configured = false;
         tk[i].b_seen = false;
         tk[i].i_skip = 0;
         tk[i].i_id   = 0;
@@ -476,10 +478,10 @@ static inline int ps_pkt_parse_system( block_t *p_pkt, ps_psm_t *p_psm,
             continue;
 
         int i_tk = PS_ID_TO_TK( i_id );
-        if( !tk[i_tk].b_seen &&
+        if( !tk[i_tk].b_configured &&
             !ps_track_fill( &tk[i_tk], p_psm, i_id, NULL ) )
         {
-                tk[i_tk].b_seen = true;
+                tk[i_tk].b_configured = true;
         }
     }
     return VLC_SUCCESS;
@@ -687,7 +689,7 @@ static inline int ps_psm_fill( ps_psm_t *p_psm, block_t *p_pkt,
     {
         ps_track_t tk_tmp;
 
-        if( !tk[i].b_seen || !tk[i].es ) continue;
+        if( !tk[i].b_configured || !tk[i].es ) continue;
 
         if( ps_track_fill( &tk_tmp, p_psm, tk[i].i_id, p_pkt ) != VLC_SUCCESS )
             continue;
@@ -701,7 +703,7 @@ static inline int ps_psm_fill( ps_psm_t *p_psm, block_t *p_pkt,
         es_out_Del( out, tk[i].es );
         es_format_Clean( &tk[i].fmt );
 
-        tk_tmp.b_seen = true;
+        tk_tmp.b_configured = true;
         tk[i] = tk_tmp;
         tk[i].es = es_out_Add( out, &tk[i].fmt );
     }



More information about the vlc-commits mailing list