[vlc-commits] Make SubtitleAdd accept flags instead of a bool

Jean-Baptiste Kempf git at videolan.org
Fri Feb 11 22:54:25 CET 2011


vlc/vlc-1.1 | branch: master | Jean-Baptiste Kempf <jb at videolan.org> | Wed Feb  9 00:15:43 2011 +0100| [0b59ba1bd151b889306550bacbb199d46db971e9] | committer: Jean-Baptiste Kempf

Make SubtitleAdd accept flags instead of a bool

No behaviour change.

Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>
(cherry picked from commit 0ff1ed4ee47869518c00dab4128af8f274a1599a)

Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>

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

 src/input/input.c |   24 ++++++++++++++----------
 1 files changed, 14 insertions(+), 10 deletions(-)

diff --git a/src/input/input.c b/src/input/input.c
index 8dba6a6..1b86f3e 100644
--- a/src/input/input.c
+++ b/src/input/input.c
@@ -106,7 +106,11 @@ static void InputGetExtraFiles( input_thread_t *p_input,
 static void AppendAttachment( int *pi_attachment, input_attachment_t ***ppp_attachment,
                               int i_new, input_attachment_t **pp_new );
 
-static void SubtitleAdd( input_thread_t *p_input, char *psz_subtitle, bool b_forced );
+enum {
+    SUB_NOFLAG = 0x00,
+    SUB_FORCED = 0x01,
+};
+static void SubtitleAdd( input_thread_t *p_input, char *psz_subtitle, unsigned i_flags );
 
 static void input_ChangeState( input_thread_t *p_input, int i_state ); /* TODO fix name */
 
@@ -1011,14 +1015,14 @@ static void LoadSubtitles( input_thread_t *p_input )
         var_SetTime( p_input, "spu-delay", (mtime_t)i_delay * 100000 );
 
     /* Look for and add subtitle files */
-    bool b_forced = true;
+    unsigned i_flags = SUB_FORCED;
 
     char *psz_subtitle = var_GetNonEmptyString( p_input, "sub-file" );
     if( psz_subtitle != NULL )
     {
         msg_Dbg( p_input, "forced subtitle: %s", psz_subtitle );
-        SubtitleAdd( p_input, psz_subtitle, b_forced );
-        b_forced = false;
+        SubtitleAdd( p_input, psz_subtitle, i_flags );
+        i_flags = SUB_NOFLAG;
     }
 
     if( var_GetBool( p_input, "sub-autodetect-file" ) )
@@ -1032,8 +1036,8 @@ static void LoadSubtitles( input_thread_t *p_input )
         {
             if( !psz_subtitle || strcmp( psz_subtitle, ppsz_subs[i] ) )
             {
-                SubtitleAdd( p_input, ppsz_subs[i], b_forced );
-                b_forced = false;
+                SubtitleAdd( p_input, ppsz_subs[i], i_flags );
+                i_flags = SUB_NOFLAG;
             }
 
             free( ppsz_subs[i] );
@@ -1070,9 +1074,9 @@ static void LoadSubtitles( input_thread_t *p_input )
         {
             var_SetString( p_input, "sub-description", a->psz_description ? a->psz_description : "");
 
-            SubtitleAdd( p_input, psz_mrl, b_forced );
+            SubtitleAdd( p_input, psz_mrl, i_flags );
 
-            b_forced = false;
+            i_flags = SUB_NOFLAG;
             free( psz_mrl );
         }
         vlc_input_attachment_Delete( a );
@@ -3179,7 +3183,7 @@ static void MRLSections( input_thread_t *p_input, char *psz_source,
 /*****************************************************************************
  * input_AddSubtitles: add a subtitles file and enable it
  *****************************************************************************/
-static void SubtitleAdd( input_thread_t *p_input, char *psz_subtitle, bool b_forced )
+static void SubtitleAdd( input_thread_t *p_input, char *psz_subtitle, unsigned i_flags )
 {
     input_source_t *sub;
     vlc_value_t count;
@@ -3224,7 +3228,7 @@ static void SubtitleAdd( input_thread_t *p_input, char *psz_subtitle, bool b_for
     TAB_APPEND( p_input->p->i_slave, p_input->p->slave, sub );
 
     /* Select the ES */
-    if( b_forced && !var_Change( p_input, "spu-es", VLC_VAR_GETLIST, &list, NULL ) )
+    if( (i_flags & SUB_FORCED) && !var_Change( p_input, "spu-es", VLC_VAR_GETLIST, &list, NULL ) )
     {
         if( count.i_int == 0 )
             count.i_int++;



More information about the vlc-commits mailing list