[vlc-commits] demux: remove redundant calls to vlc_object_alive()

Rémi Denis-Courmont git at videolan.org
Thu Feb 5 21:40:59 CET 2015


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Thu Feb  5 20:41:55 2015 +0200| [a98b6abae93b78d19dbff9ac7c13a2e35b0c1a2e] | committer: Rémi Denis-Courmont

demux: remove redundant calls to vlc_object_alive()

If the input is dead, the source stream (demux_t.s) return an
error. There is no point checking that the demux is dead separately. In
fact, there is even a race where the stream will be dead but the demux
will not.

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

 modules/access/live555.cpp |    7 -------
 modules/demux/asf/asf.c    |    2 --
 modules/demux/avi/avi.c    |   12 ------------
 modules/demux/mpeg/es.c    |    3 ++-
 modules/demux/nuv.c        |    5 +----
 modules/demux/ps.c         |    4 ++--
 modules/demux/ts.c         |   14 +++++++-------
 7 files changed, 12 insertions(+), 35 deletions(-)

diff --git a/modules/access/live555.cpp b/modules/access/live555.cpp
index f84bff1..a6f65c9 100644
--- a/modules/access/live555.cpp
+++ b/modules/access/live555.cpp
@@ -355,13 +355,6 @@ static int  Open ( vlc_object_t *p_this )
         {
             int i_read = stream_Read( p_demux->s, &p_sdp[i_sdp],
                                       i_sdp_max - i_sdp - 1 );
-
-            if( !vlc_object_alive (p_demux) )
-            {
-                free( p_sdp );
-                goto error;
-            }
-
             if( i_read < 0 )
             {
                 msg_Err( p_demux, "failed to read SDP" );
diff --git a/modules/demux/asf/asf.c b/modules/demux/asf/asf.c
index 0622ff8..c8cf441 100644
--- a/modules/demux/asf/asf.c
+++ b/modules/demux/asf/asf.c
@@ -205,8 +205,6 @@ static int Demux( demux_t *p_demux )
         mtime_t i_time_begin = GetMoviePTS( p_sys );
         int i_result;
 
-        if( !vlc_object_alive (p_demux) )
-            break;
 #if 0
         /* FIXME: returns EOF too early for some mms streams */
         if( p_sys->i_data_end >= 0 &&
diff --git a/modules/demux/avi/avi.c b/modules/demux/avi/avi.c
index 10ea01d..0a35b42 100644
--- a/modules/demux/avi/avi.c
+++ b/modules/demux/avi/avi.c
@@ -718,9 +718,6 @@ aviindex:
                           (mtime_t)p_avih->i_microsecperframe /
                           CLOCK_FREQ )
     {
-        if( !vlc_object_alive( p_demux) )
-            goto error;
-
         msg_Warn( p_demux, "broken or missing index, 'seek' will be "
                            "approximative or will exhibit strange behavior" );
         if( (i_do_index == 0 || i_do_index == 3) && !b_index )
@@ -1128,7 +1125,6 @@ static int Demux_Seekable( demux_t *p_demux )
                      * affect the reading speed too much. */
                     if( !(++i_loop_count % 1024) )
                     {
-                        if( !vlc_object_alive (p_demux) ) return -1;
                         msleep( 10000 );
 
                         if( !(i_loop_count % (1024 * 10)) )
@@ -1775,8 +1771,6 @@ static int AVI_StreamChunkFind( demux_t *p_demux, unsigned int i_stream )
 
     for( ;; )
     {
-        if( !vlc_object_alive (p_demux) ) return VLC_EGENERIC;
-
         if( AVI_PacketGetHeader( p_demux, &avi_pk ) )
         {
             msg_Warn( p_demux, "cannot get packet header" );
@@ -1795,7 +1789,6 @@ static int AVI_StreamChunkFind( demux_t *p_demux, unsigned int i_stream )
              * affect the reading speed too much. */
             if( !(++i_loop_count % 1024) )
             {
-                if( !vlc_object_alive (p_demux) ) return VLC_EGENERIC;
                 msleep( 10000 );
 
                 if( !(i_loop_count % (1024 * 10)) )
@@ -2233,8 +2226,6 @@ static int AVI_PacketSearch( demux_t *p_demux )
          * this code is called only on broken files). */
         if( !(++i_count % 1024) )
         {
-            if( !vlc_object_alive (p_demux) ) return VLC_EGENERIC;
-
             msleep( 10000 );
             if( !(i_count % (1024 * 10)) )
                 msg_Warn( p_demux, "trying to resync..." );
@@ -2572,9 +2563,6 @@ static void AVI_IndexCreate( demux_t *p_demux )
     {
         avi_packet_t pk;
 
-        if( !vlc_object_alive (p_demux) )
-            break;
-
         /* Don't update/check dialog too often */
         if( p_dialog && mdate() - i_dialog_update > 100000 )
         {
diff --git a/modules/demux/mpeg/es.c b/modules/demux/mpeg/es.c
index e99659a..d885d63 100644
--- a/modules/demux/mpeg/es.c
+++ b/modules/demux/mpeg/es.c
@@ -239,13 +239,14 @@ static int OpenCommon( demux_t *p_demux,
         }
     }
 
-    while( vlc_object_alive( p_demux ) )
+    for( ;; )
     {
         if( Parse( p_demux, &p_sys->p_packetized_data ) )
             break;
         if( p_sys->p_packetized_data )
             break;
     }
+
     return VLC_SUCCESS;
 }
 static int OpenAudio( vlc_object_t *p_this )
diff --git a/modules/demux/nuv.c b/modules/demux/nuv.c
index cb20acd..be4008d 100644
--- a/modules/demux/nuv.c
+++ b/modules/demux/nuv.c
@@ -364,9 +364,6 @@ static int Demux( demux_t *p_demux )
 
     for( ;; )
     {
-        if( !vlc_object_alive (p_demux) )
-            return -1;
-
         if( FrameHeaderLoad( p_demux, &fh ) )
             return 0;
 
@@ -573,7 +570,7 @@ static int ControlSetPosition( demux_t *p_demux, int64_t i_pos, bool b_guess )
         }
     }
 
-    while( vlc_object_alive (p_demux) )
+    for( ;; )
     {
         frame_header_t fh;
         int64_t i_tell;
diff --git a/modules/demux/ps.c b/modules/demux/ps.c
index 0fc678d..96597f4 100644
--- a/modules/demux/ps.c
+++ b/modules/demux/ps.c
@@ -251,7 +251,7 @@ static void FindLength( demux_t *p_demux )
         /* Check beginning */
         int i = 0;
         i_current_pos = stream_Tell( p_demux->s );
-        while( vlc_object_alive (p_demux) && i < 40 && Demux2( p_demux, false ) > 0 ) i++;
+        while( i < 40 && Demux2( p_demux, false ) > 0 ) i++;
 
         /* Check end */
         i_size = stream_Size( p_demux->s );
@@ -259,7 +259,7 @@ static void FindLength( demux_t *p_demux )
         stream_Seek( p_demux->s, i_size - i_end );
 
         i = 0;
-        while( vlc_object_alive (p_demux) && i < 400 && Demux2( p_demux, true ) > 0 ) i++;
+        while( i < 400 && Demux2( p_demux, true ) > 0 ) i++;
         if( i_current_pos >= 0 ) stream_Seek( p_demux->s, i_current_pos );
     }
 
diff --git a/modules/demux/ts.c b/modules/demux/ts.c
index 5479c3a..1fa6c4e 100644
--- a/modules/demux/ts.c
+++ b/modules/demux/ts.c
@@ -1182,7 +1182,7 @@ static int Open( vlc_object_t *p_this )
         }
     }
 
-    while( p_sys->i_pmt_es <= 0 && vlc_object_alive( p_demux )
+    while( p_sys->i_pmt_es <= 0
            && (!p_sys->pid[0].b_seen && !p_sys->patfix.b_pat_deadline) )
     {
         if( Demux( p_demux ) != 1 )
@@ -1193,7 +1193,7 @@ static int Open( vlc_object_t *p_this )
     if( p_sys->i_pmt_es == 0 && !p_sys->pid[0].b_seen )
         MissingPATPMTFixup( p_demux );
 
-    while( p_sys->i_pmt_es <= 0 && vlc_object_alive( p_demux ) )
+    while( p_sys->i_pmt_es <= 0 )
     {
         if( Demux( p_demux ) != 1 )
             break;
@@ -2397,7 +2397,7 @@ static block_t* ReadTSPacket( demux_t *p_demux )
     {
         msg_Warn( p_demux, "lost synchro" );
         block_Release( p_pkt );
-        while( vlc_object_alive (p_demux) )
+        for( ;; )
         {
             const uint8_t *p_peek;
             int i_peek, i_skip = 0;
@@ -2520,7 +2520,7 @@ static int SeekToPCR( demux_t *p_demux, int64_t i_pos )
     if( stream_Seek( p_sys->stream, i_pos ) )
         return VLC_EGENERIC;
 
-    while( vlc_object_alive( p_demux ) )
+    for( ;; )
     {
         block_t *p_pkt;
 
@@ -2630,7 +2630,7 @@ static void GetFirstPCR( demux_t *p_demux )
     if( stream_Seek( p_sys->stream, 0 ) )
         return;
 
-    while( vlc_object_alive (p_demux) )
+    for( ;; )
     {
         block_t     *p_pkt;
 
@@ -2671,7 +2671,7 @@ static void GetLastPCR( demux_t *p_demux )
     if( i_pos < 0 && i_pos >= i_stream_size )
         return;
 
-    while( vlc_object_alive( p_demux ) )
+    for( ;; )
     {
         if( SeekToPCR( p_demux, i_pos ) )
             break;
@@ -2698,7 +2698,7 @@ static void CheckPCR( demux_t *p_demux )
     p_sys->p_pcrs[0] = p_sys->i_first_pcr;
     p_sys->p_pos[0] = i_initial_pos;
 
-    for( i = 1; i < p_sys->i_pcrs_num && vlc_object_alive( p_demux ); ++i )
+    for( i = 1; i < p_sys->i_pcrs_num; ++i )
     {
         /* Round i_pos to a multiple of p_sys->i_packet_size */
         int64_t i_pos = i_size / p_sys->i_pcrs_num * i;



More information about the vlc-commits mailing list