Commit 7f9b60fa authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

aout: rewrite synchronization code

This commit will kill your kitten if left without supervision.
parent c19df783
...@@ -54,9 +54,10 @@ typedef struct ...@@ -54,9 +54,10 @@ typedef struct
struct struct
{ {
date_t date; mtime_t end; /**< Last seen PTS */
int resamp_type; unsigned resamp_start_drift; /**< Resampler drift absolute value */
int resamp_start_drift; int resamp_type; /**< Resampler mode (FIXME: redundant / resampling) */
bool discontinuity;
} sync; } sync;
audio_sample_format_t input_format; audio_sample_format_t input_format;
...@@ -124,7 +125,8 @@ void aout_Destroy (audio_output_t *); ...@@ -124,7 +125,8 @@ void aout_Destroy (audio_output_t *);
int aout_OutputNew( audio_output_t * p_aout, int aout_OutputNew( audio_output_t * p_aout,
const audio_sample_format_t * p_format ); const audio_sample_format_t * p_format );
void aout_OutputPlay( audio_output_t * p_aout, block_t * p_buffer ); int aout_OutputTimeGet(audio_output_t *, mtime_t *);
void aout_OutputPlay(audio_output_t *, block_t *);
void aout_OutputPause( audio_output_t * p_aout, bool, mtime_t ); void aout_OutputPause( audio_output_t * p_aout, bool, mtime_t );
void aout_OutputFlush( audio_output_t * p_aout, bool ); void aout_OutputFlush( audio_output_t * p_aout, bool );
void aout_OutputDelete( audio_output_t * p_aout ); void aout_OutputDelete( audio_output_t * p_aout );
......
This diff is collapsed.
...@@ -432,6 +432,15 @@ void aout_OutputDelete (audio_output_t *aout) ...@@ -432,6 +432,15 @@ void aout_OutputDelete (audio_output_t *aout)
aout_FiltersPipelineDestroy (owner->converters, owner->nb_converters); aout_FiltersPipelineDestroy (owner->converters, owner->nb_converters);
} }
int aout_OutputTimeGet (audio_output_t *aout, mtime_t *pts)
{
aout_assert_locked (aout);
if (aout->time_get == NULL)
return -1;
return aout->time_get (aout, pts);
}
/** /**
* Plays a decoded audio buffer. * Plays a decoded audio buffer.
* \note This can only be called after a succesful aout_OutputNew(). * \note This can only be called after a succesful aout_OutputNew().
...@@ -440,7 +449,6 @@ void aout_OutputDelete (audio_output_t *aout) ...@@ -440,7 +449,6 @@ void aout_OutputDelete (audio_output_t *aout)
void aout_OutputPlay (audio_output_t *aout, block_t *block) void aout_OutputPlay (audio_output_t *aout, block_t *block)
{ {
aout_owner_t *owner = aout_owner (aout); aout_owner_t *owner = aout_owner (aout);
mtime_t drift;
aout_assert_locked (aout); aout_assert_locked (aout);
...@@ -454,31 +462,7 @@ void aout_OutputPlay (audio_output_t *aout, block_t *block) ...@@ -454,31 +462,7 @@ void aout_OutputPlay (audio_output_t *aout, block_t *block)
return; return;
} }
if (aout->time_get != NULL && aout->time_get (aout, &drift) == 0)
drift -= block->i_pts;
else
drift = 0;
aout->play (aout, block); aout->play (aout, block);
/**
* Notifies the audio input of the drift from the requested audio
* playback timestamp (@ref block_t.i_pts) to the anticipated playback time
* as reported by the audio output hardware.
* Depending on the drift amplitude, the input core may ignore the drift
* trigger upsampling or downsampling, or even discard samples.
* Future VLC versions may instead adjust the input decoding speed.
*
* The audio output plugin is responsible for estimating the time. Typically,
* the audio output can estimate the total buffer delay. Then:
* pts = mdate() + delay
*/
if (drift < -AOUT_MAX_PTS_ADVANCE || +AOUT_MAX_PTS_DELAY < drift)
{
msg_Warn (aout, "not synchronized (%"PRId64" us), resampling",
drift);
if (date_Get (&owner->sync.date) != VLC_TS_INVALID)
date_Move (&owner->sync.date, drift);
}
} }
/** /**
......
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