[vlc-devel] commit: Allows requesting active aout/ vout from an input with associated events. (Laurent Aimar )

git version control git at videolan.org
Mon Jan 5 21:26:45 CET 2009


vlc | branch: master | Laurent Aimar <fenrir at videolan.org> | Sat Dec 27 12:25:18 2008 +0100| [ba2c2b69c950f4dad5103149e9250225320bc204] | committer: Laurent Aimar 

Allows requesting active aout/vout from an input with associated events.

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

 include/vlc_input.h   |   16 ++++++++++++----
 src/input/control.c   |   23 +++++++++++++++++++++++
 src/input/decoder.c   |    5 ++++-
 src/input/event.c     |    5 +++++
 src/input/event.h     |    1 +
 src/input/ressource.c |   46 ++++++++++++++++++++++++++++++++++++++++++++++
 src/input/ressource.h |   16 +++++++++++++++-
 7 files changed, 106 insertions(+), 6 deletions(-)

diff --git a/include/vlc_input.h b/include/vlc_input.h
index 143481b..e31aed4 100644
--- a/include/vlc_input.h
+++ b/include/vlc_input.h
@@ -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  ) );
diff --git a/src/input/control.c b/src/input/control.c
index a5a1b9f..a17a470 100644
--- a/src/input/control.c
+++ b/src/input/control.c
@@ -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;
diff --git a/src/input/decoder.c b/src/input/decoder.c
index f0663c0..27c6c82 100644
--- a/src/input/decoder.c
+++ b/src/input/decoder.c
@@ -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" );
diff --git a/src/input/event.c b/src/input/event.c
index 8c10dd5..8f97340 100644
--- a/src/input/event.c
+++ b/src/input/event.c
@@ -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
  *****************************************************************************/
diff --git a/src/input/event.h b/src/input/event.h
index a6b8fcc..5192390 100644
--- a/src/input/event.h
+++ b/src/input/event.h
@@ -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
diff --git a/src/input/ressource.c b/src/input/ressource.c
index 0de570b..d7b8e06 100644
--- a/src/input/ressource.c
+++ b/src/input/ressource.c
@@ -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 )
 {
diff --git a/src/input/ressource.h b/src/input/ressource.h
index ec49c2a..4409a88 100644
--- a/src/input/ressource.h
+++ b/src/input/ressource.h
@@ -51,16 +51,30 @@ 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
 




More information about the vlc-devel mailing list