[vlc-commits] es: copy va_list only when needed

Rémi Denis-Courmont git at videolan.org
Mon Sep 2 22:47:07 CEST 2013


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Mon Sep  2 23:34:06 2013 +0300| [7e12de500ae41b1d62cd08ee503424cbf9ca977f] | committer: Rémi Denis-Courmont

es: copy va_list only when needed

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

 modules/demux/mpeg/es.c |   23 ++++++++++-------------
 1 file changed, 10 insertions(+), 13 deletions(-)

diff --git a/modules/demux/mpeg/es.c b/modules/demux/mpeg/es.c
index 8b4b7d2..5f10f69 100644
--- a/modules/demux/mpeg/es.c
+++ b/modules/demux/mpeg/es.c
@@ -332,28 +332,28 @@ static int Control( demux_t *p_demux, int i_query, va_list args )
     int64_t *pi64;
     bool *pb_bool;
     int i_ret;
-    va_list args_save;
-
-    va_copy ( args_save, args );
 
     switch( i_query )
     {
         case DEMUX_HAS_UNSUPPORTED_META:
             pb_bool = (bool*)va_arg( args, bool* );
             *pb_bool = true;
-            va_end( args_save );
             return VLC_SUCCESS;
 
         case DEMUX_GET_TIME:
             pi64 = (int64_t*)va_arg( args, int64_t * );
             *pi64 = p_sys->i_pts + p_sys->i_time_offset;
-            va_end( args_save );
             return VLC_SUCCESS;
 
         case DEMUX_GET_LENGTH:
-            i_ret = demux_vaControlHelper( p_demux->s, p_sys->i_stream_offset, -1,
-                                            p_sys->i_bitrate_avg, 1, i_query,
-                                            args );
+        {
+            va_list ap;
+
+            va_copy ( ap, args );
+            i_ret = demux_vaControlHelper( p_demux->s, p_sys->i_stream_offset,
+                                    -1, p_sys->i_bitrate_avg, 1, i_query, ap );
+            va_end( ap );
+
             /* No bitrate, we can't have it precisely, but we can compute
              * a raw approximation with time/position */
             if( i_ret && !p_sys->i_bitrate_avg )
@@ -365,17 +365,15 @@ static int Control( demux_t *p_demux, int i_query, va_list args )
                 if( f_pos < 0.01 ||
                     (p_sys->i_pts + p_sys->i_time_offset) < 8000000 )
                 {
-                    va_end( args_save );
                     return VLC_EGENERIC;
                 }
 
-                pi64 = (int64_t *)va_arg( args_save, int64_t * );
+                pi64 = (int64_t *)va_arg( args, int64_t * );
                 *pi64 = (p_sys->i_pts + p_sys->i_time_offset) / f_pos;
-                va_end( args_save );
                 return VLC_SUCCESS;
             }
-            va_end( args_save );
             return i_ret;
+        }
 
         case DEMUX_SET_TIME:
             /* FIXME TODO: implement a high precision seek (with mp3 parsing)
@@ -384,7 +382,6 @@ static int Control( demux_t *p_demux, int i_query, va_list args )
             i_ret = demux_vaControlHelper( p_demux->s, p_sys->i_stream_offset, -1,
                                             p_sys->i_bitrate_avg, 1, i_query,
                                             args );
-            va_end( args_save );
             if( !i_ret && p_sys->i_bitrate_avg > 0 &&
                 (i_query == DEMUX_SET_POSITION || i_query == DEMUX_SET_TIME) )
             {



More information about the vlc-commits mailing list