Commit 5a55a589 authored by Laurent Aimar's avatar Laurent Aimar

Allows audio output users to control vout creation.

 The input event vout now warns about every vout creation/destruction
due to a decoder.
parent debcac6b
...@@ -222,6 +222,14 @@ struct aout_fifo_t ...@@ -222,6 +222,14 @@ struct aout_fifo_t
audio_date_t end_date; 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 */ /** audio output filter */
typedef struct aout_filter_owner_sys_t aout_filter_owner_sys_t; typedef struct aout_filter_owner_sys_t aout_filter_owner_sys_t;
typedef struct aout_filter_sys_t aout_filter_sys_t; typedef struct aout_filter_sys_t aout_filter_sys_t;
...@@ -247,8 +255,7 @@ struct aout_filter_t ...@@ -247,8 +255,7 @@ struct aout_filter_t
/* Vout callback /* Vout callback
* XXX use aout_filter_RequestVout */ * XXX use aout_filter_RequestVout */
vout_thread_t *(*pf_request_vout)( aout_filter_t *, aout_request_vout_t request_vout;
vout_thread_t *, video_format_t * );
/* Private structure for the owner of the filter */ /* Private structure for the owner of the filter */
aout_filter_owner_sys_t *p_owner; aout_filter_owner_sys_t *p_owner;
...@@ -305,6 +312,9 @@ struct aout_input_t ...@@ -305,6 +312,9 @@ struct aout_input_t
/* */ /* */
bool b_paused; bool b_paused;
mtime_t i_pause_date; mtime_t i_pause_date;
/* */
aout_request_vout_t request_vout;
}; };
/** an output stream for the audio output */ /** an output stream for the audio output */
......
...@@ -439,21 +439,27 @@ struct input_thread_t ...@@ -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 * - "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) * or not, for that check position != 0.0)
* - "can-pause" * - "can-pause"
* - "can-rate"
* - "can-rewind" * - "can-rewind"
* - "can-record" (if a stream can be recorded while playing) * - "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) * - "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: * The read-write variables are:
* - state (\see input_state_e) * - state (\see input_state_e)
* - rate, rate-slower, rate-faster * - rate, rate-slower, rate-faster
* - position, position-offset * - position, position-offset
* - time, time-offset * - time, time-offset
* - title,title-next,title-prev * - title, next-title, prev-title
* - chapter,chapter-next, chapter-prev * - chapter, next-chapter, next-chapter-prev
* - program, audio-es, video-es, spu-es * - program, audio-es, video-es, spu-es
* - audio-delay, spu-delay * - audio-delay, spu-delay
* - bookmark * - bookmark
* - TODO add special titles variables * - record
* - frame-next
* - navigation (list of "title %2i")
* - "title %2i"
* *
* The variable used for event is * The variable used for event is
* - intf-event (\see input_event_type_e) * - intf-event (\see input_event_type_e)
...@@ -539,8 +545,7 @@ typedef enum input_event_type_e ...@@ -539,8 +545,7 @@ typedef enum input_event_type_e
/* "record" has changed */ /* "record" has changed */
INPUT_EVENT_RECORD, INPUT_EVENT_RECORD,
/* A vout has been created/deleted by *the input* /* A vout has been created/deleted by *the input* */
* FIXME some event are not detected yet (audio visualisation) */
INPUT_EVENT_VOUT, INPUT_EVENT_VOUT,
/* input_item_t media has changed */ /* input_item_t media has changed */
......
...@@ -90,8 +90,9 @@ struct aout_filter_owner_sys_t ...@@ -90,8 +90,9 @@ struct aout_filter_owner_sys_t
/**************************************************************************** /****************************************************************************
* Prototypes * Prototypes
*****************************************************************************/ *****************************************************************************/
/* From input.c : */ /* 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_InputDelete( aout_instance_t * p_aout, aout_input_t * p_input );
int aout_InputPlay( 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 ); aout_buffer_t * p_buffer, int i_input_rate );
...@@ -139,8 +140,10 @@ int aout_VolumeNoneSet( aout_instance_t *, audio_volume_t ); ...@@ -139,8 +140,10 @@ int aout_VolumeNoneSet( aout_instance_t *, audio_volume_t );
int aout_VolumeNoneInfos( aout_instance_t *, audio_volume_t * ); int aout_VolumeNoneInfos( aout_instance_t *, audio_volume_t * );
/* From dec.c */ /* From dec.c */
#define aout_DecNew(a, b, c, d) __aout_DecNew(VLC_OBJECT(a), b, c, d) #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 * ); 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 * ); int aout_DecDelete ( aout_instance_t *, aout_input_t * );
aout_buffer_t * aout_DecNewBuffer( aout_input_t *, size_t ); aout_buffer_t * aout_DecNewBuffer( aout_input_t *, size_t );
void aout_DecDeleteBuffer( aout_instance_t *, aout_input_t *, aout_buffer_t * ); void aout_DecDeleteBuffer( aout_instance_t *, aout_input_t *, aout_buffer_t * );
......
...@@ -44,7 +44,8 @@ ...@@ -44,7 +44,8 @@
*****************************************************************************/ *****************************************************************************/
static aout_input_t * DecNew( vlc_object_t * p_this, aout_instance_t * p_aout, static aout_input_t * DecNew( vlc_object_t * p_this, aout_instance_t * p_aout,
audio_sample_format_t *p_format, 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; aout_input_t * p_input;
...@@ -131,10 +132,12 @@ static aout_input_t * DecNew( vlc_object_t * p_this, aout_instance_t * p_aout, ...@@ -131,10 +132,12 @@ static aout_input_t * DecNew( vlc_object_t * p_this, aout_instance_t * p_aout,
/* Create other input streams. */ /* Create other input streams. */
for ( i = 0; i < p_aout->i_nb_inputs - 1; i++ ) for ( i = 0; i < p_aout->i_nb_inputs - 1; i++ )
{ {
aout_lock_input( p_aout, p_aout->pp_inputs[i] ); aout_input_t *p_input = p_aout->pp_inputs[i];
aout_InputDelete( p_aout, p_aout->pp_inputs[i] );
aout_InputNew( p_aout, p_aout->pp_inputs[i] ); aout_lock_input( p_aout, p_input );
aout_unlock_input( p_aout, p_aout->pp_inputs[i] ); aout_InputDelete( p_aout, p_input );
aout_InputNew( p_aout, p_input, &p_input->request_vout );
aout_unlock_input( p_aout, p_input );
} }
} }
else else
...@@ -149,7 +152,7 @@ static aout_input_t * DecNew( vlc_object_t * p_this, aout_instance_t * p_aout, ...@@ -149,7 +152,7 @@ static aout_input_t * DecNew( vlc_object_t * p_this, aout_instance_t * p_aout,
goto error; 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_input_fifos( p_aout );
aout_unlock_mixer( p_aout ); aout_unlock_mixer( p_aout );
...@@ -164,7 +167,8 @@ error: ...@@ -164,7 +167,8 @@ error:
aout_input_t * __aout_DecNew( vlc_object_t * p_this, aout_input_t * __aout_DecNew( vlc_object_t * p_this,
aout_instance_t ** pp_aout, aout_instance_t ** pp_aout,
audio_sample_format_t * p_format, 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; aout_instance_t *p_aout = *pp_aout;
if ( p_aout == NULL ) if ( p_aout == NULL )
...@@ -180,7 +184,7 @@ aout_input_t * __aout_DecNew( vlc_object_t * p_this, ...@@ -180,7 +184,7 @@ aout_input_t * __aout_DecNew( vlc_object_t * p_this,
*pp_aout = p_aout; *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 );
} }
/***************************************************************************** /*****************************************************************************
......
...@@ -381,8 +381,8 @@ void aout_FiltersPlay( aout_instance_t * p_aout, ...@@ -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 *aout_filter_RequestVout( aout_filter_t *p_filter,
vout_thread_t *p_vout, video_format_t *p_fmt ) 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 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 );
} }
...@@ -62,12 +62,12 @@ static int ReplayGainCallback( vlc_object_t *, char const *, ...@@ -62,12 +62,12 @@ static int ReplayGainCallback( vlc_object_t *, char const *,
vlc_value_t, vlc_value_t, void * ); vlc_value_t, vlc_value_t, void * );
static void ReplayGainSelect( aout_instance_t *, aout_input_t * ); 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 * ); vout_thread_t *, video_format_t * );
/***************************************************************************** /*****************************************************************************
* aout_InputNew : allocate a new input and rework the filter pipeline * 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_input_format;
audio_sample_format_t chain_output_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 ) ...@@ -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 ); aout_FifoInit( p_aout, &p_input->fifo, p_aout->mixer.mixer.i_rate );
p_input->p_first_byte_to_mix = NULL; 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 */ /* Prepare format structure */
memcpy( &chain_input_format, &p_input->input, memcpy( &chain_input_format, &p_input->input,
sizeof(audio_sample_format_t) ); sizeof(audio_sample_format_t) );
...@@ -273,7 +284,7 @@ int aout_InputNew( aout_instance_t * p_aout, aout_input_t * p_input ) ...@@ -273,7 +284,7 @@ int aout_InputNew( aout_instance_t * p_aout, aout_input_t * p_input )
vlc_object_attach( p_filter , p_aout ); 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 = malloc( sizeof(*p_filter->p_owner) );
p_filter->p_owner->p_aout = p_aout; p_filter->p_owner->p_aout = p_aout;
p_filter->p_owner->p_input = p_input; 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, ...@@ -517,7 +528,7 @@ int aout_InputPlay( aout_instance_t * p_aout, aout_input_t * p_input,
aout_InputDelete( p_aout, 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->p_first_byte_to_mix = p_first_byte_to_mix;
p_input->fifo = fifo; p_input->fifo = fifo;
p_input->b_paused = b_paused; p_input->b_paused = b_paused;
...@@ -793,11 +804,11 @@ static void inputResamplingStop( aout_input_t *p_input ) ...@@ -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 ) vout_thread_t *p_vout, video_format_t *p_fmt )
{ {
/* TODO */ aout_instance_t *p_aout = p_private;
return vout_Request( p_filter, p_vout, p_fmt ); return vout_Request( p_aout, p_vout, p_fmt );
} }
static int ChangeFiltersString( aout_instance_t * p_aout, const char* psz_variable, static int ChangeFiltersString( aout_instance_t * p_aout, const char* psz_variable,
......
...@@ -420,7 +420,7 @@ static int aout_Restart( aout_instance_t * p_aout ) ...@@ -420,7 +420,7 @@ static int aout_Restart( aout_instance_t * p_aout )
for ( i = 0; i < p_aout->i_nb_inputs; i++ ) for ( i = 0; i < p_aout->i_nb_inputs; i++ )
{ {
aout_input_t * p_input = p_aout->pp_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; p_input->b_changed = 1;
aout_unlock_input( p_aout, p_input ); aout_unlock_input( p_aout, p_input );
} }
......
...@@ -2022,6 +2022,17 @@ static void DeleteDecoder( decoder_t * p_dec ) ...@@ -2022,6 +2022,17 @@ static void DeleteDecoder( decoder_t * p_dec )
/***************************************************************************** /*****************************************************************************
* Buffers allocation callbacks for the decoders * 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 ) static aout_buffer_t *aout_new_buffer( decoder_t *p_dec, int i_samples )
{ {
decoder_owner_sys_t *p_owner = p_dec->p_owner; 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 ) ...@@ -2053,6 +2064,7 @@ static aout_buffer_t *aout_new_buffer( decoder_t *p_dec, int i_samples )
audio_sample_format_t format; audio_sample_format_t format;
aout_input_t *p_aout_input; aout_input_t *p_aout_input;
aout_instance_t *p_aout; 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_dec->fmt_out.audio.i_format = p_dec->fmt_out.i_codec;
p_owner->audio = p_dec->fmt_out.audio; 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 ) ...@@ -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 = p_owner->p_aout;
p_aout_input = aout_DecNew( p_dec, &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 ); vlc_mutex_lock( &p_owner->lock );
p_owner->p_aout = p_aout; p_owner->p_aout = p_aout;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment