Browse Source

aout: add timing notify

Signed-off-by: Thomas Guillem <thomas@gllm.fr>
pull/85/head
Rémi Denis-Courmont 8 years ago
committed by Thomas Guillem
parent
commit
b602e224bc
  1. 1
      include/vlc_aout.h
  2. 2
      src/audio_output/aout_internal.h
  3. 27
      src/audio_output/dec.c
  4. 7
      src/audio_output/output.c

1
include/vlc_aout.h

@ -112,6 +112,7 @@
#include <vlc_block.h>
struct vlc_audio_output_events {
void (*timing_report)(audio_output_t *, vlc_tick_t system_now, vlc_tick_t pts);
void (*volume_report)(audio_output_t *, float);
void (*mute_report)(audio_output_t *, bool);
void (*policy_report)(audio_output_t *, bool);

2
src/audio_output/aout_internal.h

@ -136,6 +136,8 @@ void aout_DecChangePause(audio_output_t *, bool b_paused, vlc_tick_t i_date);
void aout_DecChangeRate(audio_output_t *aout, float rate);
void aout_DecFlush(audio_output_t *, bool wait);
void aout_RequestRestart (audio_output_t *, unsigned);
void aout_RequestRetiming(audio_output_t *aout, vlc_tick_t system_ts,
vlc_tick_t audio_ts);
static inline void aout_InputRequestRestart(audio_output_t *aout)
{

27
src/audio_output/dec.c

@ -221,9 +221,8 @@ static void aout_DecSilence (audio_output_t *aout, vlc_tick_t length, vlc_tick_t
static void aout_DecSynchronize(audio_output_t *aout, vlc_tick_t dec_pts)
{
aout_owner_t *owner = aout_owner (aout);
const float rate = owner->sync.rate;
vlc_tick_t drift;
vlc_tick_t now = vlc_tick_now();
vlc_tick_t delay;
/**
* Depending on the drift between the actual and intended playback times,
@ -241,9 +240,18 @@ static void aout_DecSynchronize(audio_output_t *aout, vlc_tick_t dec_pts)
* all samples in the buffer will have been played. Then:
* pts = vlc_tick_now() + delay
*/
if (aout->time_get(aout, &drift) != 0)
if (aout->time_get(aout, &delay) != 0)
return; /* nothing can be done if timing is unknown */
drift += vlc_tick_now () - dec_pts;
aout_RequestRetiming(aout, now, dec_pts - delay);
}
void aout_RequestRetiming(audio_output_t *aout, vlc_tick_t system_ts,
vlc_tick_t audio_ts)
{
aout_owner_t *owner = aout_owner (aout);
const float rate = owner->sync.rate;
vlc_tick_t drift = system_ts - audio_ts;
/* Late audio output.
* This can happen due to insufficient caching, scheduling jitter
@ -265,11 +273,8 @@ static void aout_DecSynchronize(audio_output_t *aout, vlc_tick_t dec_pts)
aout_StopResampling (aout);
owner->sync.discontinuity = true;
/* Now the output might be too early... Recheck. */
if (aout->time_get(aout, &drift) != 0)
return; /* nothing can be done if timing is unknown */
drift += vlc_tick_now () - dec_pts;
}
return; /* nothing can be done if timing is unknown */
}
/* Early audio output.
* This is rare except at startup when the buffers are still empty. */
@ -279,7 +284,7 @@ static void aout_DecSynchronize(audio_output_t *aout, vlc_tick_t dec_pts)
if (!owner->sync.discontinuity)
msg_Warn (aout, "playback way too early (%"PRId64"): "
"playing silence", drift);
aout_DecSilence (aout, -drift, dec_pts);
aout_DecSilence (aout, -drift, audio_ts);
aout_StopResampling (aout);
owner->sync.discontinuity = true;

7
src/audio_output/output.c

@ -70,6 +70,12 @@ static int var_CopyDevice (vlc_object_t *src, const char *name,
return var_Set (dst, "audio-device", value);
}
static void aout_TimingNotify(audio_output_t *aout, vlc_tick_t system_ts,
vlc_tick_t audio_ts)
{
aout_RequestRetiming(aout, system_ts, audio_ts);
}
/**
* Supply or update the current custom ("hardware") volume.
* @param volume current custom volume
@ -159,6 +165,7 @@ static int aout_GainNotify (audio_output_t *aout, float gain)
}
static const struct vlc_audio_output_events aout_events = {
aout_TimingNotify,
aout_VolumeNotify,
aout_MuteNotify,
aout_PolicyNotify,

Loading…
Cancel
Save