[vlc-devel] commit: Removed the need of input_EsOutGetFromID. (Laurent Aimar )

git version control git at videolan.org
Tue Nov 4 23:56:12 CET 2008


vlc | branch: master | Laurent Aimar <fenrir at videolan.org> | Sun Nov  2 16:55:02 2008 +0100| [719d408b1e213ad512344f97a4abdc0eace2482d] | committer: Laurent Aimar 

Removed the need of input_EsOutGetFromID.

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

 src/input/es_out.c |   53 +++++++++++++++++++++++++++++++++++----------------
 src/input/es_out.h |    5 +++-
 src/input/input.c  |   16 ++++----------
 3 files changed, 45 insertions(+), 29 deletions(-)

diff --git a/src/input/es_out.c b/src/input/es_out.c
index 34f2ffc..e15f314 100644
--- a/src/input/es_out.c
+++ b/src/input/es_out.c
@@ -310,23 +310,6 @@ es_out_t *input_EsOutNew( input_thread_t *p_input, int i_rate )
     return out;
 }
 
-es_out_id_t *input_EsOutGetFromID( es_out_t *out, int i_id )
-{
-    int i;
-    if( i_id < 0 )
-    {
-        /* Special HACK, -i_id is the cat of the stream */
-        return (es_out_id_t*)((uint8_t*)NULL-i_id);
-    }
-
-    for( i = 0; i < out->p_sys->i_es; i++ )
-    {
-        if( out->p_sys->es[i]->i_id == i_id )
-            return out->p_sys->es[i];
-    }
-    return NULL;
-}
-
 void input_EsOutChangeRate( es_out_t *out, int i_rate )
 {
     es_out_sys_t      *p_sys = out->p_sys;
@@ -670,6 +653,22 @@ static mtime_t EsOutGetWakeup( es_out_t *out )
     return input_clock_GetWakeup( p_sys->p_pgrm->p_clock );
 }
 
+static es_out_id_t *EsOutGetFromID( es_out_t *out, int i_id )
+{
+    int i;
+    if( i_id < 0 )
+    {
+        /* Special HACK, -i_id is the cat of the stream */
+        return (es_out_id_t*)((uint8_t*)NULL-i_id);
+    }
+
+    for( i = 0; i < out->p_sys->i_es; i++ )
+    {
+        if( out->p_sys->es[i]->i_id == i_id )
+            return out->p_sys->es[i];
+    }
+    return NULL;
+}
 
 static void EsOutDecodersStopBuffering( es_out_t *out, bool b_forced )
 {
@@ -2290,6 +2289,26 @@ static int EsOutControlLocked( es_out_t *out, int i_query, va_list args )
             return VLC_SUCCESS;
         }
 
+        case ES_OUT_SET_ES_BY_ID:
+        case ES_OUT_RESTART_ES_BY_ID:
+        case ES_OUT_SET_ES_DEFAULT_BY_ID:
+        {
+            const int i_id = (int)va_arg( args, int );
+            es_out_id_t *p_es = EsOutGetFromID( out, i_id );
+            int i_new_query;
+
+            switch( i_query )
+            {
+            case ES_OUT_SET_ES_BY_ID:         i_new_query = ES_OUT_SET_ES; break;
+            case ES_OUT_RESTART_ES_BY_ID:     i_new_query = ES_OUT_RESTART_ES; break;
+            case ES_OUT_SET_ES_DEFAULT_BY_ID: i_new_query = ES_OUT_SET_ES_DEFAULT; break;
+            default:
+              assert(0);
+            }
+            /* TODO if the lock is made non recursive it should be changed */
+            return es_out_Control( out, i_new_query, p_es );
+        }
+
         default:
             msg_Err( p_sys->p_input, "unknown query in es_out_Control" );
             return VLC_EGENERIC;
diff --git a/src/input/es_out.h b/src/input/es_out.h
index f254317..1cca7f7 100644
--- a/src/input/es_out.h
+++ b/src/input/es_out.h
@@ -36,6 +36,10 @@ enum es_out_query_private_e
     /* Get date to wait before demuxing more data */
     ES_OUT_GET_WAKE_UP = ES_OUT_PRIVATE_START,   /* arg1=mtime_t*            res=cannot fail */
 
+    /* Wrapper for some ES command to work with id */
+    ES_OUT_SET_ES_BY_ID,
+    ES_OUT_RESTART_ES_BY_ID,
+    ES_OUT_SET_ES_DEFAULT_BY_ID,
 };
 
 static inline mtime_t es_out_GetWakeup( es_out_t *p_out )
@@ -49,7 +53,6 @@ static inline mtime_t es_out_GetWakeup( es_out_t *p_out )
 
 es_out_t  *input_EsOutNew( input_thread_t *, int i_rate );
 
-es_out_id_t *input_EsOutGetFromID( es_out_t *, int i_id );
 void       input_EsOutSetDelay( es_out_t *, int i_cat, int64_t );
 int        input_EsOutSetRecord( es_out_t *, bool b_record );
 void       input_EsOutChangeRate( es_out_t *, int );
diff --git a/src/input/input.c b/src/input/input.c
index a8729a4..06fe623 100644
--- a/src/input/input.c
+++ b/src/input/input.c
@@ -1811,13 +1811,11 @@ static bool Control( input_thread_t *p_input, int i_type,
 
         case INPUT_CONTROL_SET_ES:
             /* No need to force update, es_out does it if needed */
-            es_out_Control( p_input->p->p_es_out, ES_OUT_SET_ES,
-                            input_EsOutGetFromID( p_input->p->p_es_out, val.i_int ) );
+            es_out_Control( p_input->p->p_es_out, ES_OUT_SET_ES_BY_ID, val.i_int );
             break;
 
         case INPUT_CONTROL_RESTART_ES:
-            es_out_Control( p_input->p->p_es_out, ES_OUT_RESTART_ES,
-                            input_EsOutGetFromID( p_input->p->p_es_out, val.i_int ) );
+            es_out_Control( p_input->p->p_es_out, ES_OUT_RESTART_ES_BY_ID, val.i_int );
             break;
 
         case INPUT_CONTROL_SET_AUDIO_DELAY:
@@ -3107,14 +3105,10 @@ static void SubtitleAdd( input_thread_t *p_input, char *psz_subtitle, bool b_for
 
         if( count.i_int < list.p_list->i_count )
         {
-            int i_id = list.p_list->p_values[count.i_int].i_int;
+            const int i_id = list.p_list->p_values[count.i_int].i_int;
 
-            input_EsOutLock( p_input->p->p_es_out );
-            es_out_id_t *p_es = input_EsOutGetFromID( p_input->p->p_es_out, i_id );
-
-            es_out_Control( p_input->p->p_es_out, ES_OUT_SET_ES_DEFAULT, p_es );
-            es_out_Control( p_input->p->p_es_out, ES_OUT_SET_ES, p_es );
-            input_EsOutUnlock( p_input->p->p_es_out );
+            es_out_Control( p_input->p->p_es_out, ES_OUT_SET_ES_DEFAULT_BY_ID, i_id );
+            es_out_Control( p_input->p->p_es_out, ES_OUT_SET_ES_BY_ID, i_id );
         }
         var_Change( p_input, "spu-es", VLC_VAR_FREELIST, &list, NULL );
     }




More information about the vlc-devel mailing list