]> git.sesse.net Git - vlc/commitdiff
Allows audio output users to control vout creation.
authorLaurent Aimar <fenrir@videolan.org>
Sun, 23 Nov 2008 12:09:02 +0000 (13:09 +0100)
committerLaurent Aimar <fenrir@videolan.org>
Sun, 23 Nov 2008 12:28:38 +0000 (13:28 +0100)
 The input event vout now warns about every vout creation/destruction
due to a decoder.

include/vlc_aout.h
include/vlc_input.h
src/audio_output/aout_internal.h
src/audio_output/dec.c
src/audio_output/filters.c
src/audio_output/input.c
src/audio_output/intf.c
src/input/decoder.c

index 6101a8dfd7496f5d80fdd2d2105e2a9f23278b1b..98a2a584749596f7c9cc444909fbac4167a1a479 100644 (file)
@@ -222,6 +222,14 @@ struct aout_fifo_t
     audio_date_t            end_date;
 };
 
+/* */
+typedef struct
+{
+    vout_thread_t  *(*pf_request_vout)( void *,
+                                        vout_thread_t *, video_format_t * );
+    void *p_private;
+} aout_request_vout_t;
+
 /** audio output filter */
 typedef struct aout_filter_owner_sys_t aout_filter_owner_sys_t;
 typedef struct aout_filter_sys_t aout_filter_sys_t;
@@ -247,8 +255,7 @@ struct aout_filter_t
 
     /* Vout callback
      * XXX use aout_filter_RequestVout */
-    vout_thread_t          *(*pf_request_vout)( aout_filter_t *,
-                                                vout_thread_t *, video_format_t * );
+    aout_request_vout_t request_vout;
 
     /* Private structure for the owner of the filter */
     aout_filter_owner_sys_t *p_owner;
@@ -305,6 +312,9 @@ struct aout_input_t
     /* */
     bool              b_paused;
     mtime_t           i_pause_date;
+
+    /* */
+    aout_request_vout_t request_vout;
  };
 
 /** an output stream for the audio output */
index 55f39d79e1bad55d882b6cf44e65e237e168ac7d..7386d7841397175277840c3195a4ffd43ec52281 100644 (file)
@@ -439,21 +439,27 @@ struct input_thread_t
  *  - "seekable (if you can seek, it doesn't say if 'bar display' has be shown FIXME rename can-seek
  *    or not, for that check position != 0.0)
  *  - "can-pause"
+ *  - "can-rate"
  *  - "can-rewind"
  *  - "can-record" (if a stream can be recorded while playing)
  *  - "teletext-es" to get the index of spu track that is teletext --1 if no teletext)
+ *  - "signal-quality"
+ *  - "signal-strength"
  *
  * The read-write variables are:
  *  - state (\see input_state_e)
  *  - rate, rate-slower, rate-faster
  *  - position, position-offset
  *  - time, time-offset
- *  - title,title-next,title-prev
- *  - chapter,chapter-next, chapter-prev
+ *  - title, next-title, prev-title
+ *  - chapter, next-chapter, next-chapter-prev
  *  - program, audio-es, video-es, spu-es
  *  - audio-delay, spu-delay
  *  - bookmark
- *  - TODO add special titles variables
+ *  - record
+ *  - frame-next
+ *  - navigation (list of "title %2i")
+ *  - "title %2i"
  *
  * The variable used for event is
  *  - intf-event (\see input_event_type_e)
@@ -539,8 +545,7 @@ typedef enum input_event_type_e
     /* "record" has changed */
     INPUT_EVENT_RECORD,
 
-    /* A vout has been created/deleted by *the input*
-     * FIXME some event are not detected yet (audio visualisation) */
+    /* A vout has been created/deleted by *the input* */
     INPUT_EVENT_VOUT,
 
     /* input_item_t media has changed */
index aa7408d2088e89c2ba3a45ffd2cc5f55a96fb78c..ca2576e9d241c6a9c0aca9f019eba678625a43ad 100644 (file)
@@ -90,8 +90,9 @@ struct aout_filter_owner_sys_t
 /****************************************************************************
  * Prototypes
  *****************************************************************************/
+
 /* From input.c : */
-int aout_InputNew( aout_instance_t * p_aout, aout_input_t * p_input );
+int aout_InputNew( aout_instance_t * p_aout, aout_input_t * p_input, const aout_request_vout_t * );
 int aout_InputDelete( aout_instance_t * p_aout, aout_input_t * p_input );
 int aout_InputPlay( aout_instance_t * p_aout, aout_input_t * p_input,
                     aout_buffer_t * p_buffer, int i_input_rate );
@@ -139,8 +140,10 @@ int aout_VolumeNoneSet( aout_instance_t *, audio_volume_t );
 int aout_VolumeNoneInfos( aout_instance_t *, audio_volume_t * );
 
 /* From dec.c */
-#define aout_DecNew(a, b, c, d) __aout_DecNew(VLC_OBJECT(a), b, c, d)
-aout_input_t * __aout_DecNew( vlc_object_t *, aout_instance_t **, audio_sample_format_t *, const audio_replay_gain_t * );
+#define aout_DecNew(a, b, c, d, e) __aout_DecNew(VLC_OBJECT(a), b, c, d, e)
+aout_input_t * __aout_DecNew( vlc_object_t *, aout_instance_t **,
+                              audio_sample_format_t *, const audio_replay_gain_t *,
+                              const aout_request_vout_t * );
 int aout_DecDelete ( aout_instance_t *, aout_input_t * );
 aout_buffer_t * aout_DecNewBuffer( aout_input_t *, size_t );
 void aout_DecDeleteBuffer( aout_instance_t *, aout_input_t *, aout_buffer_t * );
index 3b27992817314fa09c751e5d9af520b1497bf9dd..70af428090af1c0fbc034e197ec45385b6e4bfd6 100644 (file)
@@ -44,7 +44,8 @@
  *****************************************************************************/
 static aout_input_t * DecNew( vlc_object_t * p_this, aout_instance_t * p_aout,
                               audio_sample_format_t *p_format,
-                              const audio_replay_gain_t *p_replay_gain )
+                              const audio_replay_gain_t *p_replay_gain,
+                              const aout_request_vout_t *p_request_vout )
 {
     aout_input_t * p_input;
 
@@ -131,10 +132,12 @@ static aout_input_t * DecNew( vlc_object_t * p_this, aout_instance_t * p_aout,
         /* Create other input streams. */
         for ( i = 0; i < p_aout->i_nb_inputs - 1; i++ )
         {
-            aout_lock_input( p_aout, p_aout->pp_inputs[i] );
-            aout_InputDelete( p_aout, p_aout->pp_inputs[i] );
-            aout_InputNew( p_aout, p_aout->pp_inputs[i] );
-            aout_unlock_input( p_aout, p_aout->pp_inputs[i] );
+            aout_input_t *p_input = p_aout->pp_inputs[i];
+
+            aout_lock_input( p_aout, p_input );
+            aout_InputDelete( p_aout, p_input );
+            aout_InputNew( p_aout, p_input, &p_input->request_vout );
+            aout_unlock_input( p_aout, p_input );
         }
     }
     else
@@ -149,7 +152,7 @@ static aout_input_t * DecNew( vlc_object_t * p_this, aout_instance_t * p_aout,
         goto error;
     }
 
-    aout_InputNew( p_aout, p_input );
+    aout_InputNew( p_aout, p_input, p_request_vout );
     aout_unlock_input_fifos( p_aout );
 
     aout_unlock_mixer( p_aout );
@@ -164,7 +167,8 @@ error:
 aout_input_t * __aout_DecNew( vlc_object_t * p_this,
                               aout_instance_t ** pp_aout,
                               audio_sample_format_t * p_format,
-                              const audio_replay_gain_t *p_replay_gain )
+                              const audio_replay_gain_t *p_replay_gain,
+                              const aout_request_vout_t *p_request_video )
 {
     aout_instance_t *p_aout = *pp_aout;
     if ( p_aout == NULL )
@@ -180,7 +184,7 @@ aout_input_t * __aout_DecNew( vlc_object_t * p_this,
         *pp_aout = p_aout;
     }
 
-    return DecNew( p_this, p_aout, p_format, p_replay_gain );
+    return DecNew( p_this, p_aout, p_format, p_replay_gain, p_request_video );
 }
 
 /*****************************************************************************
index 9bcba0ddf3a842b224e80c8f689806fbcd3827a4..9ffb5f14af0d6a91e33b019068218f15f4b07dc7 100644 (file)
@@ -381,8 +381,8 @@ void aout_FiltersPlay( aout_instance_t * p_aout,
 vout_thread_t *aout_filter_RequestVout( aout_filter_t *p_filter,
                                         vout_thread_t *p_vout, video_format_t *p_fmt )
 {
-    if( !p_filter->pf_request_vout )
+    if( !p_filter->request_vout.pf_request_vout )
         return NULL;
-    return p_filter->pf_request_vout( p_filter, p_vout, p_fmt );
+    return p_filter->request_vout.pf_request_vout( p_filter->request_vout.p_private, p_vout, p_fmt );
 }
 
index 0f1426b647c238e757126ac325e6f908766b5bd1..47ff66bd053bfd1e226f9deff7b7e1c00aa3d51b 100644 (file)
@@ -62,12 +62,12 @@ static int ReplayGainCallback( vlc_object_t *, char const *,
                                vlc_value_t, vlc_value_t, void * );
 static void ReplayGainSelect( aout_instance_t *, aout_input_t * );
 
-static vout_thread_t *RequestVout( aout_filter_t *,
+static vout_thread_t *RequestVout( void *,
                                    vout_thread_t *, video_format_t * );
 /*****************************************************************************
  * aout_InputNew : allocate a new input and rework the filter pipeline
  *****************************************************************************/
-int aout_InputNew( aout_instance_t * p_aout, aout_input_t * p_input )
+int aout_InputNew( aout_instance_t * p_aout, aout_input_t * p_input, const aout_request_vout_t *p_request_vout )
 {
     audio_sample_format_t chain_input_format;
     audio_sample_format_t chain_output_format;
@@ -83,6 +83,17 @@ int aout_InputNew( aout_instance_t * p_aout, aout_input_t * p_input )
     aout_FifoInit( p_aout, &p_input->fifo, p_aout->mixer.mixer.i_rate );
     p_input->p_first_byte_to_mix = NULL;
 
+    /* */
+    if( p_request_vout )
+    {
+        p_input->request_vout = *p_request_vout;
+    }
+    else
+    {
+        p_input->request_vout.pf_request_vout = RequestVout;
+        p_input->request_vout.p_private = p_aout;
+    }
+
     /* Prepare format structure */
     memcpy( &chain_input_format, &p_input->input,
             sizeof(audio_sample_format_t) );
@@ -273,7 +284,7 @@ int aout_InputNew( aout_instance_t * p_aout, aout_input_t * p_input )
 
             vlc_object_attach( p_filter , p_aout );
 
-            p_filter->pf_request_vout = RequestVout;
+            p_filter->request_vout = p_input->request_vout;
             p_filter->p_owner = malloc( sizeof(*p_filter->p_owner) );
             p_filter->p_owner->p_aout  = p_aout;
             p_filter->p_owner->p_input = p_input;
@@ -517,7 +528,7 @@ int aout_InputPlay( aout_instance_t * p_aout, aout_input_t * p_input,
 
         aout_InputDelete( p_aout, p_input );
 
-        aout_InputNew( p_aout, p_input );
+        aout_InputNew( p_aout, p_input, &p_input->request_vout );
         p_input->p_first_byte_to_mix = p_first_byte_to_mix;
         p_input->fifo = fifo;
         p_input->b_paused = b_paused;
@@ -793,11 +804,11 @@ static void inputResamplingStop( aout_input_t *p_input )
     }
 }
 
-static vout_thread_t *RequestVout( aout_filter_t *p_filter,
+static vout_thread_t *RequestVout( void *p_private,
                                    vout_thread_t *p_vout, video_format_t *p_fmt )
 {
-    /* TODO */
-    return vout_Request( p_filter, p_vout, p_fmt );
+    aout_instance_t *p_aout = p_private;
+    return vout_Request( p_aout, p_vout, p_fmt );
 }
 
 static int ChangeFiltersString( aout_instance_t * p_aout, const char* psz_variable,
index 3e652f3caa19c4377123d827d043835766035d1a..64e54a221ee13455b39e92649a271e2f8702cd4a 100644 (file)
@@ -420,7 +420,7 @@ static int aout_Restart( aout_instance_t * p_aout )
     for ( i = 0; i < p_aout->i_nb_inputs; i++ )
     {
         aout_input_t * p_input = p_aout->pp_inputs[i];
-        b_error |= aout_InputNew( p_aout, p_input );
+        b_error |= aout_InputNew( p_aout, p_input, &p_input->request_vout );
         p_input->b_changed = 1;
         aout_unlock_input( p_aout, p_input );
     }
index a81def0bfb9ac71a8091bb80881bc5154c6bfa6d..d9a12618d102a453e4ff0254b2304f461d663530 100644 (file)
@@ -2022,6 +2022,17 @@ static void DeleteDecoder( decoder_t * p_dec )
 /*****************************************************************************
  * Buffers allocation callbacks for the decoders
  *****************************************************************************/
+static vout_thread_t *aout_request_vout( void *p_private,
+                                         vout_thread_t *p_vout, video_format_t *p_fmt )
+{
+    decoder_t *p_dec = p_private;
+
+    p_vout =  vout_Request( p_dec, p_vout, p_fmt );
+    input_SendEventVout( p_dec->p_owner->p_input );
+
+    return p_vout;
+}
+
 static aout_buffer_t *aout_new_buffer( decoder_t *p_dec, int i_samples )
 {
     decoder_owner_sys_t *p_owner = p_dec->p_owner;
@@ -2053,6 +2064,7 @@ static aout_buffer_t *aout_new_buffer( decoder_t *p_dec, int i_samples )
         audio_sample_format_t format;
         aout_input_t *p_aout_input;
         aout_instance_t *p_aout;
+        aout_request_vout_t request_vout;
 
         p_dec->fmt_out.audio.i_format = p_dec->fmt_out.i_codec;
         p_owner->audio = p_dec->fmt_out.audio;
@@ -2074,9 +2086,12 @@ static aout_buffer_t *aout_new_buffer( decoder_t *p_dec, int i_samples )
             }
         }
 
+        request_vout.pf_request_vout = aout_request_vout;
+        request_vout.p_private = p_dec;
+
         p_aout = p_owner->p_aout;
         p_aout_input = aout_DecNew( p_dec, &p_aout,
-                                    &format, &p_dec->fmt_out.audio_replay_gain );
+                                    &format, &p_dec->fmt_out.audio_replay_gain, &request_vout );
 
         vlc_mutex_lock( &p_owner->lock );
         p_owner->p_aout = p_aout;