Commit 94b75f19 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

aout: move sync date from input to aout structure

parent da5f53e5
...@@ -85,9 +85,6 @@ struct aout_input_t ...@@ -85,9 +85,6 @@ struct aout_input_t
/* */ /* */
bool b_recycle_vout; bool b_recycle_vout;
aout_request_vout_t request_vout; aout_request_vout_t request_vout;
/* */
date_t date;
}; };
typedef struct typedef struct
...@@ -96,6 +93,11 @@ typedef struct ...@@ -96,6 +93,11 @@ typedef struct
module_t *module; /**< Output plugin (or NULL if inactive) */ module_t *module; /**< Output plugin (or NULL if inactive) */
aout_input_t *input; aout_input_t *input;
struct
{
date_t date;
} sync;
struct struct
{ {
vlc_mutex_t lock; vlc_mutex_t lock;
...@@ -131,7 +133,7 @@ static inline aout_owner_t *aout_owner (audio_output_t *aout) ...@@ -131,7 +133,7 @@ static inline aout_owner_t *aout_owner (audio_output_t *aout)
int aout_InputNew( audio_output_t * p_aout, aout_input_t * p_input, const aout_request_vout_t * ); int aout_InputNew( audio_output_t * p_aout, aout_input_t * p_input, const aout_request_vout_t * );
int aout_InputDelete( audio_output_t * p_aout, aout_input_t * p_input ); int aout_InputDelete( audio_output_t * p_aout, aout_input_t * p_input );
block_t *aout_InputPlay( audio_output_t *p_aout, aout_input_t *p_input, block_t *aout_InputPlay( audio_output_t *p_aout, aout_input_t *p_input,
block_t *p_buffer, int i_input_rate ); block_t *p_buffer, int i_input_rate, date_t * );
void aout_InputCheckAndRestart( audio_output_t * p_aout, aout_input_t * p_input ); void aout_InputCheckAndRestart( audio_output_t * p_aout, aout_input_t * p_input );
/* From filters.c : */ /* From filters.c : */
......
...@@ -109,6 +109,9 @@ int aout_DecNew( audio_output_t *p_aout, ...@@ -109,6 +109,9 @@ int aout_DecNew( audio_output_t *p_aout,
goto error; goto error;
} }
date_Init (&owner->sync.date, owner->mixer_format.i_rate, 1);
date_Set (&owner->sync.date, VLC_TS_INVALID);
owner->input = p_input; owner->input = p_input;
aout_InputNew( p_aout, p_input, p_request_vout ); aout_InputNew( p_aout, p_input, p_request_vout );
aout_unlock( p_aout ); aout_unlock( p_aout );
...@@ -244,10 +247,12 @@ int aout_DecPlay (audio_output_t *p_aout, block_t *p_buffer, int i_input_rate) ...@@ -244,10 +247,12 @@ int aout_DecPlay (audio_output_t *p_aout, block_t *p_buffer, int i_input_rate)
aout_InputCheckAndRestart( p_aout, p_input ); aout_InputCheckAndRestart( p_aout, p_input );
/* Input */ /* Input */
p_buffer = aout_InputPlay( p_aout, p_input, p_buffer, i_input_rate ); p_buffer = aout_InputPlay (p_aout, p_input, p_buffer, i_input_rate,
&owner->sync.date);
if( p_buffer != NULL ) if( p_buffer != NULL )
{ {
date_Increment (&owner->sync.date, p_buffer->i_nb_samples);
/* Mixer */ /* Mixer */
float amp = owner->volume.multiplier * p_input->multiplier; float amp = owner->volume.multiplier * p_input->multiplier;
aout_MixerRun (owner->volume.mixer, p_buffer, amp); aout_MixerRun (owner->volume.mixer, p_buffer, amp);
...@@ -277,12 +282,10 @@ int aout_DecGetResetLost (audio_output_t *aout) ...@@ -277,12 +282,10 @@ int aout_DecGetResetLost (audio_output_t *aout)
void aout_DecChangePause (audio_output_t *aout, bool paused, mtime_t date) void aout_DecChangePause (audio_output_t *aout, bool paused, mtime_t date)
{ {
aout_owner_t *owner = aout_owner (aout); aout_owner_t *owner = aout_owner (aout);
aout_input_t *p_input = owner->input;
aout_lock (aout); aout_lock (aout);
/* XXX: Should the date be offset by the pause duration instead? */
/* XXX: Should the input date be offset by the pause duration instead? */ date_Set (&owner->sync.date, VLC_TS_INVALID);
date_Set (&p_input->date, VLC_TS_INVALID);
aout_OutputPause (aout, paused, date); aout_OutputPause (aout, paused, date);
aout_unlock (aout); aout_unlock (aout);
} }
...@@ -290,10 +293,9 @@ void aout_DecChangePause (audio_output_t *aout, bool paused, mtime_t date) ...@@ -290,10 +293,9 @@ void aout_DecChangePause (audio_output_t *aout, bool paused, mtime_t date)
void aout_DecFlush (audio_output_t *aout) void aout_DecFlush (audio_output_t *aout)
{ {
aout_owner_t *owner = aout_owner (aout); aout_owner_t *owner = aout_owner (aout);
aout_input_t *input = owner->input;
aout_lock (aout); aout_lock (aout);
date_Set (&input->date, VLC_TS_INVALID); date_Set (&owner->sync.date, VLC_TS_INVALID);
aout_OutputFlush (aout, false); aout_OutputFlush (aout, false);
aout_unlock (aout); aout_unlock (aout);
} }
...@@ -301,12 +303,11 @@ void aout_DecFlush (audio_output_t *aout) ...@@ -301,12 +303,11 @@ void aout_DecFlush (audio_output_t *aout)
bool aout_DecIsEmpty (audio_output_t *aout) bool aout_DecIsEmpty (audio_output_t *aout)
{ {
aout_owner_t *owner = aout_owner (aout); aout_owner_t *owner = aout_owner (aout);
aout_input_t *input = owner->input;
mtime_t end_date; mtime_t end_date;
aout_lock (aout); aout_lock (aout);
/* FIXME: tell output to drain */ /* FIXME: tell output to drain */
end_date = date_Get (&input->date); end_date = date_Get (&owner->sync.date);
aout_unlock (aout); aout_unlock (aout);
return end_date == VLC_TS_INVALID || end_date <= mdate(); return end_date == VLC_TS_INVALID || end_date <= mdate();
} }
...@@ -79,9 +79,6 @@ int aout_InputNew( audio_output_t * p_aout, aout_input_t * p_input, const aout_r ...@@ -79,9 +79,6 @@ int aout_InputNew( audio_output_t * p_aout, aout_input_t * p_input, const aout_r
p_input->i_nb_resamplers = p_input->i_nb_filters = 0; p_input->i_nb_resamplers = p_input->i_nb_filters = 0;
date_Init (&p_input->date, owner->mixer_format.i_rate, 1);
date_Set (&p_input->date, VLC_TS_INVALID);
/* */ /* */
if( p_request_vout ) if( p_request_vout )
{ {
...@@ -461,13 +458,9 @@ void aout_InputCheckAndRestart( audio_output_t * p_aout, aout_input_t * p_input ...@@ -461,13 +458,9 @@ void aout_InputCheckAndRestart( audio_output_t * p_aout, aout_input_t * p_input
if( !p_input->b_restart ) if( !p_input->b_restart )
return; return;
/* A little trick to avoid loosing our input properties */
date_t date = p_input->date;
aout_InputDelete( p_aout, p_input ); aout_InputDelete( p_aout, p_input );
aout_InputNew( p_aout, p_input, &p_input->request_vout ); aout_InputNew( p_aout, p_input, &p_input->request_vout );
p_input->date = date;
p_input->b_restart = false; p_input->b_restart = false;
} }
/***************************************************************************** /*****************************************************************************
...@@ -477,8 +470,8 @@ void aout_InputCheckAndRestart( audio_output_t * p_aout, aout_input_t * p_input ...@@ -477,8 +470,8 @@ void aout_InputCheckAndRestart( audio_output_t * p_aout, aout_input_t * p_input
*****************************************************************************/ *****************************************************************************/
/* XXX Do not activate it !! */ /* XXX Do not activate it !! */
//#define AOUT_PROCESS_BEFORE_CHEKS //#define AOUT_PROCESS_BEFORE_CHEKS
block_t *aout_InputPlay( audio_output_t *p_aout, aout_input_t *p_input, block_t *aout_InputPlay(audio_output_t *p_aout, aout_input_t *p_input,
block_t *p_buffer, int i_input_rate ) block_t *p_buffer, int i_input_rate, date_t *date )
{ {
mtime_t start_date; mtime_t start_date;
...@@ -531,7 +524,7 @@ block_t *aout_InputPlay( audio_output_t *p_aout, aout_input_t *p_input, ...@@ -531,7 +524,7 @@ block_t *aout_InputPlay( audio_output_t *p_aout, aout_input_t *p_input,
/* We don't care if someone changes the start date behind our back after /* We don't care if someone changes the start date behind our back after
* this. We'll deal with that when pushing the buffer, and compensate * this. We'll deal with that when pushing the buffer, and compensate
* with the next incoming buffer. */ * with the next incoming buffer. */
start_date = date_Get (&p_input->date); start_date = date_Get (date);
if ( start_date != VLC_TS_INVALID && start_date < now ) if ( start_date != VLC_TS_INVALID && start_date < now )
{ {
...@@ -564,7 +557,7 @@ block_t *aout_InputPlay( audio_output_t *p_aout, aout_input_t *p_input, ...@@ -564,7 +557,7 @@ block_t *aout_InputPlay( audio_output_t *p_aout, aout_input_t *p_input,
if( start_date == VLC_TS_INVALID ) if( start_date == VLC_TS_INVALID )
{ {
start_date = p_buffer->i_pts; start_date = p_buffer->i_pts;
date_Set (&p_input->date, start_date); date_Set (date, start_date);
} }
mtime_t drift = start_date - p_buffer->i_pts; mtime_t drift = start_date - p_buffer->i_pts;
...@@ -579,7 +572,7 @@ block_t *aout_InputPlay( audio_output_t *p_aout, aout_input_t *p_input, ...@@ -579,7 +572,7 @@ block_t *aout_InputPlay( audio_output_t *p_aout, aout_input_t *p_input,
inputResamplingStop( p_input ); inputResamplingStop( p_input );
p_buffer->i_flags |= BLOCK_FLAG_DISCONTINUITY; p_buffer->i_flags |= BLOCK_FLAG_DISCONTINUITY;
start_date = p_buffer->i_pts; start_date = p_buffer->i_pts;
date_Set (&p_input->date, start_date); date_Set (date, start_date);
drift = 0; drift = 0;
} }
else else
...@@ -686,7 +679,6 @@ block_t *aout_InputPlay( audio_output_t *p_aout, aout_input_t *p_input, ...@@ -686,7 +679,6 @@ block_t *aout_InputPlay( audio_output_t *p_aout, aout_input_t *p_input,
#endif #endif
p_buffer->i_pts = start_date; p_buffer->i_pts = start_date;
date_Increment (&p_input->date, p_buffer->i_nb_samples);
return p_buffer; return p_buffer;
} }
......
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