]> git.sesse.net Git - vlc/commitdiff
Added input internal es_out_GetEsObjects to retreives decoder associated objects.
authorLaurent Aimar <fenrir@videolan.org>
Sat, 30 Jan 2010 19:19:38 +0000 (20:19 +0100)
committerLaurent Aimar <fenrir@videolan.org>
Sat, 30 Jan 2010 23:50:28 +0000 (00:50 +0100)
It will allow to removes vlc_object_find(_*) hacks.

src/input/decoder.c
src/input/decoder.h
src/input/es_out.c
src/input/es_out.h
src/input/es_out_timeshift.c

index 8ed5a13eb2cd557ffa6763f00f961a7439a600a6..5a0ef0293ea3bc8b04682eaa0ed443a8c775e827 100644 (file)
@@ -624,6 +624,19 @@ size_t input_DecoderGetFifoSize( decoder_t *p_dec )
     return block_FifoSize( p_owner->p_fifo );
 }
 
+void input_DecoderGetObjects( decoder_t *p_dec,
+                              vout_thread_t **pp_vout, aout_instance_t **pp_aout )
+{
+    decoder_owner_sys_t *p_owner = p_dec->p_owner;
+
+    vlc_mutex_lock( &p_owner->lock );
+    if( pp_vout )
+        *pp_vout = vlc_object_hold( p_owner->p_vout );
+    if( pp_aout )
+        *pp_aout = vlc_object_hold( p_owner->p_aout );
+    vlc_mutex_unlock( &p_owner->lock );
+}
+
 /*****************************************************************************
  * Internal functions
  *****************************************************************************/
index fe99b42e794eec0ccd8ecfdc51ad43b9959f97e2..b113d22fcde4bea0370643a223e6eab478564d4d 100644 (file)
@@ -104,4 +104,11 @@ bool input_DecoderHasFormatChanged( decoder_t *p_dec, es_format_t *p_fmt, vlc_me
  */
 size_t input_DecoderGetFifoSize( decoder_t *p_dec );
 
+/**
+ * This function returns the objects associated to a decoder
+ *
+ * They must be released using vlc_object_release().
+ */
+void input_DecoderGetObjects( decoder_t *, vout_thread_t **, aout_instance_t ** );
+
 #endif
index f2546b5a058dad605c20fc5611a34fe9209a9af6..e42f29a2dd4fc00515666cb77d525bd81d778db8 100644 (file)
@@ -2459,6 +2459,32 @@ static int EsOutControlLocked( es_out_t *out, int i_query, va_list args )
             return i_ret;
         }
 
+        case ES_OUT_GET_ES_OBJECTS_BY_ID:
+        {
+            const int i_id = va_arg( args, int );
+            es_out_id_t *p_es = EsOutGetFromID( out, i_id );
+            if( !p_es )
+                return VLC_EGENERIC;
+
+            vlc_object_t    **pp_decoder = va_arg( args, vlc_object_t ** );
+            vout_thread_t   **pp_vout    = va_arg( args, vout_thread_t ** );
+            aout_instance_t **pp_aout    = va_arg( args, aout_instance_t ** );
+            if( es->p_dec )
+            {
+                if( pp_decoder )
+                    *pp_decoder = vlc_object_hold( es->p_dec );
+                input_DecoderGetObjects( es->p_dec, pp_vout, pp_aout );
+            }
+            else
+            {
+                if( pp_vout )
+                    *pp_vout = NULL;
+                if( pp_aout )
+                    *pp_aout = NULL;
+            }
+            return VLC_SUCCESS;
+        }
+
         case ES_OUT_GET_BUFFERING:
             pb = (bool *)va_arg( args, bool* );
             *pb = p_sys->b_buffering;
index 9dd5d45ab3c3e070eedc6b2d474904c6d524ac97..36cb807097b61dde330c9cf583a5fa9872483474 100644 (file)
@@ -55,6 +55,7 @@ enum es_out_query_private_e
     ES_OUT_SET_ES_BY_ID,
     ES_OUT_RESTART_ES_BY_ID,
     ES_OUT_SET_ES_DEFAULT_BY_ID,
+    ES_OUT_GET_ES_OBJECTS_BY_ID,                    /* arg1=int id, vlc_object_t **dec, vout_thread_t **, aout_instance_t ** res=can fail*/
 
     /* Get buffering state */
     ES_OUT_GET_BUFFERING,                           /* arg1=bool*               res=cannot fail */
@@ -142,6 +143,11 @@ static inline void es_out_SetJitter( es_out_t *p_out, mtime_t i_pts_delay, int i
     int i_ret = es_out_Control( p_out, ES_OUT_SET_JITTER, i_pts_delay, i_cr_average );
     assert( !i_ret );
 }
+static inline int es_out_GetEsObjects( es_out_t *p_out, int i_id,
+                                       vlc_object_t **pp_decoder, vout_thread_t **pp_vout, aout_instance_t **pp_aout )
+{
+    return es_out_Control( p_out, ES_OUT_GET_ES_OBJECTS_BY_ID, i_id, pp_decoder, pp_vout, pp_aout );
+}
 
 es_out_t  *input_EsOutNew( input_thread_t *, int i_rate );
 
index 5981be2902ea0f22626f7bb3aecb1339460957a0..51f38cfbf85e3bbabd3fdbf6ed3e933d3638fb7b 100644 (file)
@@ -581,6 +581,7 @@ static int ControlLocked( es_out_t *p_out, int i_query, va_list args )
     case ES_OUT_SET_ES_BY_ID:
     case ES_OUT_RESTART_ES_BY_ID:
     case ES_OUT_SET_ES_DEFAULT_BY_ID:
+    case ES_OUT_GET_ES_OBJECTS_BY_ID:
     case ES_OUT_SET_DELAY:
     case ES_OUT_SET_RECORD_STATE:
         assert(0);