]> git.sesse.net Git - vlc/commitdiff
Allows requesting active aout/vout from an input with associated events.
authorLaurent Aimar <fenrir@videolan.org>
Sat, 27 Dec 2008 11:25:18 +0000 (12:25 +0100)
committerLaurent Aimar <fenrir@videolan.org>
Mon, 5 Jan 2009 19:49:15 +0000 (20:49 +0100)
include/vlc_input.h
src/input/control.c
src/input/decoder.c
src/input/event.c
src/input/event.h
src/input/ressource.c
src/input/ressource.h

index 143481bbca45a2f2a2d2cc123d90ce28ad47e785..e31aed43598bf8b70361b9ebeb963903590b4171 100644 (file)
@@ -545,9 +545,6 @@ typedef enum input_event_type_e
     /* "record" has changed */
     INPUT_EVENT_RECORD,
 
-    /* A vout has been created/deleted by *the input* */
-    INPUT_EVENT_VOUT,
-
     /* input_item_t media has changed */
     INPUT_EVENT_ITEM_META,
     /* input_item_t info has changed */
@@ -571,6 +568,11 @@ typedef enum input_event_type_e
     /* cache" has changed */
     INPUT_EVENT_CACHE,
 
+    /* A aout_instance_t object has been created/deleted by *the input* */
+    INPUT_EVENT_AOUT,
+    /* A vout_thread_t object has been created/deleted by *the input* */
+    INPUT_EVENT_VOUT,
+
 } input_event_type_e;
 
 /** @}*/
@@ -584,12 +586,13 @@ typedef enum input_event_type_e
 #define input_CreateThread(a,b) __input_CreateThread(VLC_OBJECT(a),b)
 VLC_EXPORT( input_thread_t *, __input_CreateThread, ( vlc_object_t *, input_item_t * ) );
 
+VLC_EXPORT( void,             input_StopThread,     ( input_thread_t * ) );
+
 #define input_Preparse(a,b) __input_Preparse(VLC_OBJECT(a),b)
 VLC_EXPORT( int, __input_Preparse, ( vlc_object_t *, input_item_t * ) );
 
 #define input_Read(a,b,c) __input_Read(VLC_OBJECT(a),b, c)
 VLC_EXPORT( int, __input_Read, ( vlc_object_t *, input_item_t *, bool ) );
-VLC_EXPORT( void,             input_StopThread,     ( input_thread_t * ) );
 
 enum input_query_e
 {
@@ -653,6 +656,11 @@ enum input_query_e
 
     /* ES */
     INPUT_RESTART_ES,       /* arg1=int (-AUDIO/VIDEO/SPU_ES for the whole category) */
+
+    /* Input ressources
+     * XXX You must call vlc_object_release as soon as possible */
+    INPUT_GET_AOUT,         /* arg1=aout_instance_t **              res=can fail */
+    INPUT_GET_VOUTS,        /* arg1=vout_thread_t ***, int *        res=can fail */
 };
 
 VLC_EXPORT( int, input_vaControl,( input_thread_t *, int i_query, va_list  ) );
index a5a1b9f6cf44a09f0830f0b7beac0858e1fb162c..a17a47092f8fa0413437dcd10539fb476decff5e 100644 (file)
@@ -32,6 +32,7 @@
 
 #include "input_internal.h"
 #include "event.h"
+#include "ressource.h"
 
 
 static void UpdateBookmarksOption( input_thread_t * );
@@ -412,6 +413,28 @@ int input_vaControl( input_thread_t *p_input, int i_query, va_list args )
             input_ControlPush( p_input, INPUT_CONTROL_RESTART_ES, &val );
             return VLC_SUCCESS;
 
+        case INPUT_GET_AOUT:
+        {
+            aout_instance_t *p_aout = input_ressource_HoldAout( p_input->p->p_ressource );
+            if( !p_aout )
+                return VLC_EGENERIC;
+
+            aout_instance_t **pp_aout = (aout_instance_t**)va_arg( args, aout_instance_t** );
+            *pp_aout = p_aout;
+            return VLC_SUCCESS;
+        }
+
+        case INPUT_GET_VOUTS:
+        {
+            vout_thread_t ***ppp_vout = (vout_thread_t***)va_arg( args, vout_thread_t*** );
+            int           *pi_vout = (int*)va_arg( args, int* );
+
+            input_ressource_HoldVouts( p_input->p->p_ressource, ppp_vout, pi_vout );
+            if( *pi_vout <= 0 )
+                return VLC_EGENERIC;
+            return VLC_SUCCESS;
+        }
+
         default:
             msg_Err( p_input, "unknown query in input_vaControl" );
             return VLC_EGENERIC;
index f0663c03204ab9735bd242365db5ce5296dfbec4..27c6c82859eccc2dadff75318639aeb76a06c32f 100644 (file)
@@ -2032,6 +2032,7 @@ static void DeleteDecoder( decoder_t * p_dec )
     {
         input_ressource_RequestAout( p_owner->p_input->p->p_ressource,
                                      p_owner->p_aout );
+        input_SendEventAout( p_owner->p_input );
         p_owner->p_aout = NULL;
     }
     if( p_owner->p_vout )
@@ -2039,7 +2040,7 @@ static void DeleteDecoder( decoder_t * p_dec )
         /* Hack to make sure all the the pictures are freed by the decoder */
         vout_FixLeaks( p_owner->p_vout, true );
 
-        /* We are about to die. Reattach video output to p_vlc. */
+        /* */
         input_ressource_RequestVout( p_owner->p_input->p->p_ressource, p_owner->p_vout, NULL );
         input_SendEventVout( p_owner->p_input );
     }
@@ -2195,6 +2196,8 @@ static aout_buffer_t *aout_new_buffer( decoder_t *p_dec, int i_samples )
 
         vlc_mutex_unlock( &p_owner->lock );
 
+        input_SendEventAout( p_owner->p_input );
+
         if( p_owner->p_aout_input == NULL )
         {
             msg_Err( p_dec, "failed to create audio output" );
index 8c10dd5c722ef2bc22c06dc295b2a8a7ffe77cc5..8f973407bff74426f6f8404ff0cf33dcaa983d31 100644 (file)
@@ -319,6 +319,11 @@ void input_SendEventVout( input_thread_t *p_input )
     Trigger( p_input, INPUT_EVENT_VOUT );
 }
 
+void input_SendEventAout( input_thread_t *p_input )
+{
+    Trigger( p_input, INPUT_EVENT_AOUT );
+}
+
 /*****************************************************************************
  * Event for control.c/input.c
  *****************************************************************************/
index a6b8fccdd3bd939230dd464fe1aa66459a69f189..51923904ddc8e0c8f6f783547b2f13bc71524bc8 100644 (file)
@@ -69,6 +69,7 @@ void input_SendEventTeletext( input_thread_t *p_input, int i_id );
  * Event for decoder.c
  *****************************************************************************/
 void input_SendEventVout( input_thread_t *p_input );
+void input_SendEventAout( input_thread_t *p_input );
 
 /*****************************************************************************
  * Event for control.c/input.c
index 0de570b229077748ae6552ce5baae29cf033fd70..d7b8e067bd1394913a127f8ad3e63e295358fad6 100644 (file)
@@ -189,6 +189,28 @@ static vout_thread_t *HoldVout( input_ressource_t *p_ressource )
 
     return p_vout;
 }
+static void HoldVouts( input_ressource_t *p_ressource, vout_thread_t ***ppp_vout, int *pi_vout )
+{
+    vout_thread_t **pp_vout;
+
+    *pi_vout = 0;
+    *ppp_vout = NULL;
+    if( p_ressource->i_vout <= 0 )
+        return;
+
+    pp_vout = calloc( p_ressource->i_vout, sizeof(*pp_vout) );
+    if( !pp_vout )
+        return;
+
+    *ppp_vout = pp_vout;
+    *pi_vout = p_ressource->i_vout;
+
+    for( int i = 0; i < p_ressource->i_vout; i++ )
+    {
+        pp_vout[i] = p_ressource->pp_vout[i];
+        vlc_object_hold( pp_vout[i] );
+    }
+}
 
 /* */
 static void DestroyAout( input_ressource_t *p_ressource )
@@ -228,7 +250,18 @@ static aout_instance_t *RequestAout( input_ressource_t *p_ressource, aout_instan
         return p_ressource->p_aout;
     }
 }
+static aout_instance_t *HoldAout( input_ressource_t *p_ressource )
+{
+    if( !p_ressource->p_aout )
+        return NULL;
+
+    /* TODO FIXME: p_ressource->pp_vout order is NOT stable */
+    aout_instance_t *p_aout = p_ressource->p_aout;
+
+    vlc_object_hold( p_aout );
 
+    return p_aout;
+}
 /* */
 input_ressource_t *input_ressource_New( void )
 {
@@ -290,6 +323,12 @@ vout_thread_t *input_ressource_HoldVout( input_ressource_t *p_ressource )
 
     return p_ret;
 }
+void input_ressource_HoldVouts( input_ressource_t *p_ressource, vout_thread_t ***ppp_vout, int *pi_vout )
+{
+    vlc_mutex_lock( &p_ressource->lock );
+    HoldVouts( p_ressource, ppp_vout, pi_vout );
+    vlc_mutex_unlock( &p_ressource->lock );
+}
 void input_ressource_TerminateVout( input_ressource_t *p_ressource )
 {
     input_ressource_RequestVout( p_ressource, NULL, NULL );
@@ -304,7 +343,14 @@ aout_instance_t *input_ressource_RequestAout( input_ressource_t *p_ressource, ao
 
     return p_ret;
 }
+aout_instance_t *input_ressource_HoldAout( input_ressource_t *p_ressource )
+{
+    vlc_mutex_lock( &p_ressource->lock );
+    aout_instance_t *p_ret = HoldAout( p_ressource );
+    vlc_mutex_unlock( &p_ressource->lock );
 
+    return p_ret;
+}
 /* */
 sout_instance_t *input_ressource_RequestSout( input_ressource_t *p_ressource, sout_instance_t *p_sout, const char *psz_sout )
 {
index ec49c2ac6f8dd8f574d68667aabaae3ab30e22fc..4409a881cced3aee9be16e3bb51f721a0450d12a 100644 (file)
@@ -50,17 +50,31 @@ sout_instance_t *input_ressource_RequestSout( input_ressource_t *, sout_instance
  */
 aout_instance_t *input_ressource_RequestAout( input_ressource_t *, aout_instance_t * );
 
+/**
+ * This function return the current aout if any.
+ *
+ * You must call vlc_object_release on the value returned (if non NULL).
+ */
+aout_instance_t *input_ressource_HoldAout( input_ressource_t *p_ressource );
+
 /**
  * This function handles vout request.
  */
 vout_thread_t *input_ressource_RequestVout( input_ressource_t *, vout_thread_t *, video_format_t * );
 
 /**
- * This function return the current vout if any.
+ * This function return one of the current vout if any.
  *
  * You must call vlc_object_release on the value returned (if non NULL).
  */
 vout_thread_t *input_ressource_HoldVout( input_ressource_t * );
 
+/**
+ * This function return all current vouts if any.
+ *
+ * You must call vlc_object_release on all values returned (if non NULL).
+ */
+void input_ressource_HoldVouts( input_ressource_t *, vout_thread_t ***, int * );
+
 #endif