[vlc-commits] ts mux ActiveKeyCallback: reduce critical section

Rafaël Carré git at videolan.org
Fri Feb 10 00:49:08 CET 2012


vlc | branch: master | Rafaël Carré <funman at videolan.org> | Thu Feb  9 18:47:43 2012 -0500| [928c9fa7b5b9d6ad0d258922c6b45cfdc635c1a6] | committer: Rafaël Carré

ts mux ActiveKeyCallback: reduce critical section

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

 modules/mux/mpeg/ts.c |   23 ++++++++++++++++-------
 1 files changed, 16 insertions(+), 7 deletions(-)

diff --git a/modules/mux/mpeg/ts.c b/modules/mux/mpeg/ts.c
index 54fe84a..98d5f24 100644
--- a/modules/mux/mpeg/ts.c
+++ b/modules/mux/mpeg/ts.c
@@ -899,17 +899,26 @@ static int ActiveKeyCallback( vlc_object_t *p_this, char const *psz_cmd,
     VLC_UNUSED(psz_cmd); VLC_UNUSED(oldval); VLC_UNUSED(p_data);
     sout_mux_t      *p_mux = (sout_mux_t*)p_this;
     sout_mux_sys_t  *p_sys = p_mux->p_sys;
-    int             i_res = VLC_EBADVAR;
+    int             i_res, use_odd = -1;
 
-    vlc_mutex_lock( &p_sys->csa_lock );
-    if( !strcmp(newval.psz_string, "odd" ) || !strcmp(newval.psz_string, "first" ) || !strcmp(newval.psz_string, "1" ) )
+    if( !strcmp(newval.psz_string, "odd" ) ||
+        !strcmp(newval.psz_string, "first" ) ||
+        !strcmp(newval.psz_string, "1" ) )
     {
-        i_res = csa_UseKey( (vlc_object_t*)p_mux, p_sys->csa, 1 );
+        use_odd = 1;
     }
-    else if( !strcmp(newval.psz_string, "even" ) || !strcmp(newval.psz_string, "second" ) || !strcmp(newval.psz_string, "2" ) )
+    else if( !strcmp(newval.psz_string, "even" ) ||
+             !strcmp(newval.psz_string, "second" ) ||
+             !strcmp(newval.psz_string, "2" ) )
     {
-        i_res = csa_UseKey( (vlc_object_t*)p_mux, p_sys->csa, 0 );
+        use_odd = 0;
     }
+
+    if (use_odd < 0)
+        return VLC_EBADVAR;
+
+    vlc_mutex_lock( &p_sys->csa_lock );
+    i_res = csa_UseKey( p_this, p_sys->csa, use_odd );
     vlc_mutex_unlock( &p_sys->csa_lock );
 
     return i_res;
@@ -1159,7 +1168,7 @@ static int AddStream( sout_mux_t *p_mux, sout_input_t *p_input )
                 p_stream->lang[i*3+0] = pl->psz_iso639_2T[0];
                 p_stream->lang[i*3+1] = pl->psz_iso639_2T[1];
                 p_stream->lang[i*3+2] = pl->psz_iso639_2T[2];
- 
+
                 msg_Dbg( p_mux, "    - lang=%c%c%c",
                          p_stream->lang[i*3+0], p_stream->lang[i*3+1],
                          p_stream->lang[i*3+2] );



More information about the vlc-commits mailing list