Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • videolan/vlc
  • chouquette/vlc
  • bakiewicz.marek122/vlc
  • devnexen/vlc
  • rohanrajpal/vlc
  • blurrrb/vlc
  • gsoc/gsoc2019/darkapex/vlc
  • b1ue/vlc
  • fkuehne/vlc
  • magsoft/vlc
  • chub/vlc
  • cramiro9/vlc
  • robUx4/vlc
  • rom1v/vlc
  • akshayaky/vlc
  • tmk907/vlc
  • akymaster/vlc
  • govind.sharma/vlc
  • psilokos/vlc
  • xjbeta/vlc
  • jahan/vlc
  • 1480c1/vlc
  • amanchande/vlc
  • aaqib/vlc
  • rist/vlc
  • apol/vlc
  • mindfreeze/vlc
  • alexandre-janniaux/vlc
  • sandsmark/vlc
  • jagannatharjun/vlc
  • gsoc/gsoc2020/matiaslgonzalez/vlc
  • gsoc/gsoc2020/jagannatharjun/vlc
  • mstorsjo/vlc
  • gsoc/gsoc2020/vedenta/vlc
  • gsoc/gsoc2020/arnav-ishaan/vlc
  • gsoc/gsoc2020/andreduong/vlc
  • fuzun/vlc
  • gsoc/gsoc2020/vatsin/vlc
  • gsoc/gsoc2020/sagid/vlc
  • yaron/vlc
  • Phoenix/vlc
  • Garf/vlc
  • ePiratWorkarounds/vlc
  • tguillem/vlc
  • jnqnfe/vlc
  • mdc/vlc
  • Vedaa/vlc
  • rasa/vlc
  • quink/vlc
  • yealo/vlc
  • aleksey_ak/vlc
  • ePirat/vlc
  • ilya.yanok/vlc
  • asenat/vlc
  • m/vlc
  • bunjee/vlc
  • BLumia/vlc
  • sagudev/vlc
  • hamedmonji30/vlc
  • nullgemm/vlc
  • DivyamAhuja/vlc
  • thesamesam/vlc
  • dag7/vlc
  • snehil101/vlc
  • haasn/vlc
  • jbk/vlc
  • ValZapod/vlc
  • mfkl/vlc
  • WangChuan/vlc
  • core1024/vlc
  • GhostVaibhav/vlc
  • dfuhrmann/vlc
  • davide.prade/vlc
  • tmatth/vlc
  • Courmisch/vlc
  • zouya/vlc
  • hpi/vlc
  • EwoutH/vlc
  • aleung27/vlc
  • hengwu0/vlc
  • saladin/vlc
  • ashuio/vlc
  • richselwood/vlc
  • verma16Ayush/vlc
  • chemicalflash/vlc
  • PoignardAzur/vlc
  • huangjieNT/vlc
  • Blake-Haydon/vlc
  • AnuthaDev/vlc
  • gsoc/gsoc2021/mpd/vlc
  • nicolas_lequec/vlc
  • sambassaly/vlc
  • thresh/vlc
  • bonniegong/vlc
  • myaashish/vlc
  • stavros.vagionitis/vlc
  • ileoo/vlc
  • louis-santucci/vlc
  • cchristiansen/vlc
  • sabyasachi07/vlc
  • AbduAmeen/vlc
  • ashishb0410/vlc
  • urbanhusky/vlc
  • davidepietrasanta/vlc
  • riksleutelstad/vlc
  • jeremyVignelles/vlc
  • komh/vlc
  • iamjithinjohn/vlc
  • JohannesKauffmann/vlc2
  • kunglao/vlc
  • natzberg/vlc
  • jill/vlc
  • cwendling/vlc
  • adufou/vlc
  • ErwanAirone/vlc
  • HasinduDilshan10/vlc
  • vagrantc/vlc
  • rafiv/macos-bigsur-icon
  • Aymeriic/vlc
  • saranshg20/vlc
  • metzlove24/vlc
  • linkfanel/vlc
  • Ds886/vlc
  • metehan-arslan/vlc
  • Skantes/vlc
  • kgsandundananjaya96/vlc
  • mitchcapper/vlc
  • advaitgupta/vlc
  • StefanBruens/vlc
  • ratajs/vlc
  • T.M.F.B.3761/vlc
  • m222059/vlc
  • casemerrick/vlc
  • joshuaword2alt/vlc
  • sjwaddy/vlc
  • dima/vlc
  • Ybalrid/vlc
  • umxprime/vlc
  • eschmidt/vlc
  • vannieuwenhuysenmichelle/vlc
  • badcf00d/vlc
  • wesinator/vlc
  • louis/vlc
  • xqq/vlc
  • EmperorYP7/vlc
  • NicoLiam/vlc
  • loveleen/vlc
  • rofferom/vlc
  • rbultje/vlc
  • TheUnamed/vlc
  • pratiksharma341/vlc
  • Saurab17/vlc
  • purist.coder/vlc
  • Shuicheng/vlc
  • mdrrubel292/vlc
  • silverbleu00/vlc
  • metif12/vlc
  • asher-m/vlc
  • jeffk/vlc
  • Brandonbr1/vlc
  • beautyyuyanli/vlc
  • rego21/vlc
  • muyangren907/vlc
  • collectionbylawrencejason/vlc
  • evelez/vlc
  • GSMgeeth/vlc
  • Oneric/vlc
  • TJ5/vlc
  • XuanTung95/vlc
  • darrenjenny21/vlc
  • Trenly/vlc
  • RockyTDR/vlc
  • mjakubowski/vlc
  • caprica/vlc
  • ForteFrankie/vlc
  • seannamiller19/vlc
  • junlon2006/vlc
  • kiwiren6666/vlc
  • iuseiphonexs/vlc
  • fenngtun/vlc
  • Rajdutt999/vlc
  • typx/vlc
  • leon.vitanos/vlc
  • robertogarci0938/vlc
  • gsoc/gsoc2022/luc65r/vlc-mpd
  • skeller/vlc
  • MCJack123/vlc
  • luc65r/vlc-mpd
  • popov895/vlc
  • claucambra/vlc
  • brad/vlc
  • matthewmurua88/vlc
  • Tomas8874/vlc
  • philenotfound/vlc
  • makita-do3/vlc
  • LZXCorp/vlc
  • mar0x/vlc
  • senojetkennedy0102/vlc
  • shaneb243/vlc
  • ahmadbader/vlc
  • rajduttcse26/vlc-audio-filters
  • Juniorzito8415/vlc
  • achernyakov/vlc
  • lucasjetgroup/vlc
  • pupdoggy666/vlc
  • gmde9363/vlc
  • alexnwayne/vlc
  • bahareebrahimi781/vlc
  • hamad633666/vlc
  • umghof3112/vlc
  • joe0199771874/vlc
  • Octocats66666666/vlc
  • jjm_223/vlc
  • btech10110.19/vlc
  • sunnykfc028/vlc-audio-filters
  • loic/vlc
  • nguyenminhducmx1/vlc
  • JanekKrueger/vlc
  • bstubbington2/vlc
  • rcombs/vlc
  • Ordissimo/vlc
  • king7532/vlc
  • noobsauce101/vlc
  • schong0525/vlc
  • myQwil/vlc
  • apisbg91/vlc
  • geeboy0101017/vlc
  • kim.faughey/vlc
  • nurupo/vlc
  • yyusea/vlc
  • 0711235879.khco/vlc
  • ialo/vlc
  • iloveyeye2/vlc
  • gdtdftdqtd/vlc
  • leandroconsiglio/vlc
  • AndyHTML2012/vlc
  • ncz/vlc
  • lucenticus/vlc
  • knr1931/vlc
  • kjoonlee/vlc
  • chandrakant100/vlc-qt
  • johge42/vlc
  • polter/vlc
  • hexchain/vlc
  • Tushwrld/vlc
  • mztea928/vlc
  • jbelloncastro/vlc
  • alvinhochun/vlc
  • ghostpiratecrow/vlc
  • ujjwaltwitx/vlc
  • alexsonarin06/vlc
  • adrianbon76/vlc
  • altsod/vlc
  • damien.lucas44/vlc
  • dmytrivtaisa/vlc
  • utk202/vlc
  • aaxhrj/vlc
  • thomas.hermes/vlc
  • structurenewworldorder/vlc
  • slomo/vlc
  • wantlamy/vlc
  • musc.o3cminc/vlc
  • thebarshablog/vlc
  • kerrick/vlc
  • kratos142518/vlc
  • leogps/vlc
  • vacantron/vlc
  • luna_koly/vlc
  • Ratio2/vlc
  • anuoshemohammad/vlc
  • apsun/vlc
  • aaa1115910/vlc
  • alimotmoyo/vlc
  • Ambossmann/vlc
  • Sam-LearnsToCode/vlc
  • Chilledheart/vlc
  • Labnann/vlc
  • ktcoooot1/vlc
  • mohit-marathe/vlc
  • johnddx/vlc
  • manstabuk/vlc
  • Omar-ahmed314/vlc
  • vineethkm/vlc
  • 9Enemi86/vlc
  • radoslav.m.panteleev/vlc
  • ashishami2002/vlc
  • Corbax/vlc
  • firnasahmed/vlc
  • pelayarmalam4/vlc
  • c0ff330k/vlc
  • shikhindahikar/vlc
  • l342723951/vlc
  • christianschwandner/vlc
  • douniwan5788/vlc
  • 7damian7/vlc
  • ferdnyc/vlc
  • f.ales1/vlc
  • pandagby/vlc
  • BaaBaa/vlc
  • jewe37/vlc
  • w00drow/vlc
  • russelltg/vlc
  • ironicallygod/vlc
  • soumyaDghosh/vlc
  • linzihao1999/vlc
  • deyayush6/vlc
  • mibi88/vlc
  • newabdallah10/vlc
  • jhorbincolombia/vlc
  • rimvihaqueshupto/vlc
  • andrewkhon98/vlc
  • fab78/vlc
  • lapaz17/vlc
  • amanna13/vlc
  • mdakram28/vlc
  • 07jw1980/vlc
  • sohamgupta/vlc
  • Eson-Jia1/vlc
  • Sumou/vlc
  • vikram-kangotra/vlc
  • chalice191/vlc
  • olivercalder/vlc
  • aaasg4001/vlc
  • zipdox/vlc
  • kwizart/vlc
  • Dragon-S/vlc
  • jdemeule/vlc
  • gabriel_lt/vlc
  • locutusofborg/vlc
  • sammirata/vlc-librist
  • another/vlc
  • Benjamin_Loison/vlc
  • ahmedmoselhi/vlc
  • petergaal/vlc
  • huynhsontung/vlc
  • dariusmihut/vlc
  • tvermaashutosh/vlc
  • buti/vlc
  • Niram7777/vlc
  • rohan-here/vlc
  • balaji-sivasakthi/vlc
  • rlindner81/vlc
  • Kakadus/vlc
  • djain/vlc
  • ABBurmeister/vlc
  • craighuggins/vlc
  • orbea/vlc
  • maxos/vlc
  • aakarshmj/vlc
  • kblaschke/vlc
  • ankitm/vlc
  • advait-0/vlc
  • mohak2003/vlc
  • yselkowitz/vlc
  • AZM999/vlc-azm
  • andrey.turkin/vlc
  • Disha-Baghel/vlc
  • nowrep/vlc
  • Apeng/vlc
  • Choucroute_melba/vlc
  • autra/vlc
  • eclipseo/vlc
  • fhuber/vlc
  • olafhering/vlc
  • sdasda7777/vlc
  • 1div0/vlc
  • skosnits/vlc-extended-playlist-support
  • dnicolson/vlc
  • Timshel/vlc
  • octopols/vlc
  • MangalK/vlc
  • nima64/vlc
  • misawai/vlc
  • Alexander-Wilms/vlc
  • Maxime2/vlc-fork-for-visualizer
  • ww/vlc
  • jeske/vlc
  • sgross-emlix/vlc
  • morenonatural/vlc
  • freakingLovesVLC/vlc
  • borisgolovnev/vlc
  • mpromonet/vlc
  • diogo.simao-marques/vlc
  • masstock/vlc
  • pratikpatel8982/vlc
  • hugok79/vlc
  • longervision/vlc
  • abhiudaysurya/vlc
  • rishabhgarg/vlc
  • tumic/vlc
  • cart/vlc
  • shubham442/vlc
  • Aditya692005/vlc
  • sammirata/vlc4
  • syrykh/vlc
  • Vvorcun/macos-new-icon
  • AyaanshC/vlc
  • nasso/vlc
  • Quark/vlc
  • sebastinas/vlc
  • rhstone/vlc
  • talregev/vlc
  • Managor/vlc
403 results
Show changes
Commits on Source (9)
  • Alexandre Janniaux's avatar
    input: es_out: move clocks to sub-structure · 1ffb6b62
    Alexandre Janniaux authored and Jean-Baptiste Kempf's avatar Jean-Baptiste Kempf committed
    1ffb6b62
  • Alexandre Janniaux's avatar
    input_clock: remove extra spacing · e623cd10
    Alexandre Janniaux authored and Jean-Baptiste Kempf's avatar Jean-Baptiste Kempf committed
    The header felt weird with this extra spacing to separate the type, and
    the spacing wasn't even the same for every function.
    e623cd10
  • Alexandre Janniaux's avatar
    input_clock: early return on UpdateListener · c2afd2ef
    Alexandre Janniaux authored and Jean-Baptiste Kempf's avatar Jean-Baptiste Kempf committed
    If we don't have listener, there's nothing to update anyway, so save an
    indentation level and early return at the beginning instead.
    c2afd2ef
  • Alexandre Janniaux's avatar
    input_clock: export clock listener · 79ccc8a6
    Alexandre Janniaux authored and Jean-Baptiste Kempf's avatar Jean-Baptiste Kempf committed
    Use a generic clock listener instead of the vlc_clock_t based-one so
    that we can attach a different listener to the input clock, in
    particular in the case of tests.
    
    The change moves some code back to the es_out.c file, which we try to
    simplify, but the creation of the clock and buffering handling as a
    whole might be moved somewhere else someday.
    79ccc8a6
  • Alexandre Janniaux's avatar
    input_clock: reset cl->last on input_clock_Reset · adc05ec0
    Alexandre Janniaux authored and Jean-Baptiste Kempf's avatar Jean-Baptiste Kempf committed
    cl->last points to the last point tracked by the clock, ensure it is set
    to an invalid point like cl->ref when resetting the clock.
    
    The assignment is not needed per se but since we were setting ref, this
    allows for easier debugging and tracing.
    adc05ec0
  • Alexandre Janniaux's avatar
    input_clock: expose drift in update callback · 87439bb1
    Alexandre Janniaux authored and Jean-Baptiste Kempf's avatar Jean-Baptiste Kempf committed
    input_clock_Update() is returning a value representing whether too much
    buffer has been consumed or not, but it doesn't use any external value
    to compute it.
    
    After the update, the input_clock is running UpdateListener() to update
    any code that would use the value reported by the input buffering, and
    specifically the vlc_clock_t when running inside the es_out. This was
    triggering a vlc_clock_Update().
    
    vlc_clock_Update() returns the drift of the updated clock compared to
    the current playback time. It wasn't used for the input clock because
    this drift is always zero when the updated clock is driving the clock
    bus ("master clock") and the vlc_clock_t was not added as a listener
    when the input clock was not driving the clock bus.
    
    The drift value will be reported from the clock update to the input
    clock. It currently has no usage except tracing, but the usage will
    replace the i_late computation in the es_out.c in the end.
    87439bb1
  • Alexandre Janniaux's avatar
    es_out: always create an input vlc_clock_t · c5e72f07
    Alexandre Janniaux authored and Jean-Baptiste Kempf's avatar Jean-Baptiste Kempf committed
    When the input is not selected to drive the clock bus, no vlc_clock_t
    was assigned to track the drift of the input when compared to the audio
    clock or other clocks, meaning that there was no way to inspect the
    behaviour of the input buffering when not master.
    
    This commit refactors the input vlc_clock_t creation to always have a
    vlc_clock_t and always update it.
    c5e72f07
  • Alexandre Janniaux's avatar
    vlc_tracer: move TraceRender to clock.c · d57c3156
    Alexandre Janniaux authored and Jean-Baptiste Kempf's avatar Jean-Baptiste Kempf committed
    The function is specific to clock and not used anywhere else.
    d57c3156
  • Alexandre Janniaux's avatar
    clock: trace the reported drift value · 1901c5de
    Alexandre Janniaux authored and Jean-Baptiste Kempf's avatar Jean-Baptiste Kempf committed
    Drift includes information relative to how much the given clock is
    out-of-sync with the main source of time for the current playback, and
    tracing its value highlight some particular behaviour regarding the
    output and how the input buffering is handled.
    1901c5de
......@@ -258,31 +258,6 @@ static inline void vlc_tracer_TraceStreamDTS(struct vlc_tracer *tracer, const ch
VLC_TRACE_END);
}
static inline void vlc_tracer_TraceRender(struct vlc_tracer *tracer, const char *type,
const char *id, vlc_tick_t now, vlc_tick_t pts)
{
if (now != VLC_TICK_MAX && now != VLC_TICK_INVALID)
{
vlc_tracer_TraceWithTs(tracer, vlc_tick_now(),
VLC_TRACE("type", type),
VLC_TRACE("id", id),
VLC_TRACE_TICK_NS("pts", pts),
VLC_TRACE_TICK_NS("render_ts", now),
VLC_TRACE_END);
vlc_tracer_TraceWithTs(tracer, now,
VLC_TRACE("type", type),
VLC_TRACE("id", id),
VLC_TRACE_TICK_NS("render_pts", pts),
VLC_TRACE_END);
}
else
vlc_tracer_Trace(tracer, VLC_TRACE("type", type),
VLC_TRACE("id", id),
VLC_TRACE_TICK_NS("pts", pts),
VLC_TRACE_END);
}
static inline void vlc_tracer_TraceEvent(struct vlc_tracer *tracer, const char *type,
const char *id, const char *event)
{
......
......@@ -145,6 +145,34 @@ int vlc_clock_RegisterEvents(vlc_clock_t *clock,
event->cbs->on_##event(event->data); \
}
static inline void TraceRender(struct vlc_tracer *tracer, const char *type,
const char *id, vlc_tick_t now, vlc_tick_t pts,
vlc_tick_t drift)
{
if (now != VLC_TICK_MAX && now != VLC_TICK_INVALID)
{
vlc_tracer_TraceWithTs(tracer, vlc_tick_now(),
VLC_TRACE("type", type),
VLC_TRACE("id", id),
VLC_TRACE_TICK_NS("pts", pts),
VLC_TRACE_TICK_NS("render_ts", now),
VLC_TRACE_TICK_NS("drift", drift),
VLC_TRACE_END);
vlc_tracer_TraceWithTs(tracer, now,
VLC_TRACE("type", type),
VLC_TRACE("id", id),
VLC_TRACE_TICK_NS("render_pts", pts),
VLC_TRACE_TICK_NS("drift", drift),
VLC_TRACE_END);
}
else
vlc_tracer_Trace(tracer, VLC_TRACE("type", type),
VLC_TRACE("id", id),
VLC_TRACE_TICK_NS("pts", pts),
VLC_TRACE_END);
}
static vlc_tick_t main_stream_to_system(vlc_clock_main_t *main_clock,
vlc_tick_t ts)
{
......@@ -169,7 +197,9 @@ static void vlc_clock_main_reset(vlc_clock_main_t *main_clock)
static inline void vlc_clock_on_update(vlc_clock_t *clock,
vlc_tick_t system_now,
vlc_tick_t ts, double rate,
vlc_tick_t ts,
vlc_tick_t drift,
double rate,
unsigned frame_rate,
unsigned frame_rate_base)
{
......@@ -178,9 +208,10 @@ static inline void vlc_clock_on_update(vlc_clock_t *clock,
clock->cbs->on_update(system_now, ts, rate, frame_rate, frame_rate_base,
clock->cbs_data);
if (main_clock->tracer != NULL && clock->track_str_id != NULL)
vlc_tracer_TraceRender(main_clock->tracer, "RENDER", clock->track_str_id,
system_now, ts);
if (main_clock->tracer != NULL && clock->track_str_id != NULL &&
system_now != VLC_TICK_INVALID && system_now != VLC_TICK_MAX)
TraceRender(main_clock->tracer, "RENDER", clock->track_str_id,
system_now, ts, drift);
}
static vlc_tick_t vlc_clock_master_update(vlc_clock_t *clock,
......@@ -281,9 +312,10 @@ static vlc_tick_t vlc_clock_master_update(vlc_clock_t *clock,
if (clock->delay > 0 && main_clock->delay < 0 && ts > -main_clock->delay)
ts += main_clock->delay;
vlc_clock_on_update(clock, system_now, ts,
vlc_tick_t drift = VLC_TICK_INVALID;
vlc_clock_on_update(clock, system_now, ts, drift,
rate, frame_rate, frame_rate_base);
return VLC_TICK_INVALID;
return drift;
}
static void vlc_clock_master_reset(vlc_clock_t *clock)
......@@ -316,7 +348,7 @@ static void vlc_clock_master_reset(vlc_clock_t *clock)
vlc_mutex_unlock(&main_clock->lock);
vlc_clock_on_update(clock, VLC_TICK_INVALID, VLC_TICK_INVALID, 1.f, 0, 0);
vlc_clock_on_update(clock, VLC_TICK_INVALID, VLC_TICK_INVALID, VLC_TICK_INVALID, 1.f, 0, 0);
}
static vlc_tick_t vlc_clock_master_set_delay(vlc_clock_t *clock, vlc_tick_t delay)
......@@ -427,8 +459,8 @@ static vlc_tick_t vlc_clock_slave_update(vlc_clock_t *clock,
{
/* If system_now is VLC_TICK_MAX, the update is forced, don't modify
* anything but only notify the new clock point. */
vlc_clock_on_update(clock, VLC_TICK_MAX, ts, rate, frame_rate,
frame_rate_base);
vlc_clock_on_update(clock, VLC_TICK_MAX, ts, VLC_TICK_INVALID,
rate, frame_rate, frame_rate_base);
return VLC_TICK_MAX;
}
......@@ -438,8 +470,10 @@ static vlc_tick_t vlc_clock_slave_update(vlc_clock_t *clock,
vlc_mutex_unlock(&main_clock->lock);
vlc_clock_on_update(clock, computed, ts, rate, frame_rate, frame_rate_base);
return computed - system_now;
vlc_tick_t drift = computed - system_now;
vlc_clock_on_update(clock, computed, ts, drift, rate,
frame_rate, frame_rate_base);
return drift;
}
static void vlc_clock_slave_reset(vlc_clock_t *clock)
......@@ -452,7 +486,8 @@ static void vlc_clock_slave_reset(vlc_clock_t *clock)
vlc_mutex_unlock(&main_clock->lock);
vlc_clock_on_update(clock, VLC_TICK_INVALID, VLC_TICK_INVALID, 1.0f, 0, 0);
vlc_clock_on_update(clock, VLC_TICK_INVALID, VLC_TICK_INVALID,
VLC_TICK_INVALID, 1.0f, 0, 0);
}
static vlc_tick_t vlc_clock_slave_set_delay(vlc_clock_t *clock, vlc_tick_t delay)
......
......@@ -101,7 +101,10 @@
/* */
struct input_clock_t
{
vlc_clock_t *clock_listener;
struct {
const struct vlc_input_clock_cbs *cbs;
void *opaque;
} listener;
/* Last point
* It is used to detect unexpected stream discontinuities */
......@@ -143,14 +146,17 @@ static vlc_tick_t ClockGetTsOffset( input_clock_t * );
static void UpdateListener( input_clock_t *cl )
{
if( cl->clock_listener )
{
const vlc_tick_t system_expected =
ClockStreamToSystem( cl, cl->last.stream + AvgGet( &cl->drift ) ) +
cl->i_pts_delay + ClockGetTsOffset( cl );
if (cl->listener.cbs == NULL)
return;
vlc_clock_Update( cl->clock_listener, system_expected, cl->last.stream, cl->rate );
}
const vlc_tick_t system_expected =
ClockStreamToSystem( cl, cl->last.stream + AvgGet( &cl->drift ) ) +
cl->i_pts_delay + ClockGetTsOffset( cl );
/* The returned drift value is ignored for now since a different
* value is computed by the input_clock. */
cl->listener.cbs->update(cl->listener.opaque, system_expected,
cl->last.stream, cl->rate);
}
/*****************************************************************************
......@@ -161,7 +167,8 @@ input_clock_t *input_clock_New( float rate )
input_clock_t *cl = malloc( sizeof(*cl) );
if( !cl )
return NULL;
cl->clock_listener = NULL;
cl->listener.cbs = NULL;
cl->listener.opaque = NULL;
cl->b_has_reference = false;
cl->ref = clock_point_Create( VLC_TICK_INVALID, VLC_TICK_INVALID );
......@@ -192,17 +199,18 @@ input_clock_t *input_clock_New( float rate )
void input_clock_Delete( input_clock_t *cl )
{
AvgClean( &cl->drift );
if( cl->clock_listener )
vlc_clock_Delete( cl->clock_listener );
free( cl );
}
void input_clock_AttachListener( input_clock_t *cl, vlc_clock_t *clock_listener )
void input_clock_AttachListener(input_clock_t *cl,
const struct vlc_input_clock_cbs *cbs,
void *opaque)
{
assert( clock_listener && cl->clock_listener == NULL );
assert(cbs && cl->listener.cbs == NULL);
assert( !cl->b_has_reference );
cl->clock_listener = clock_listener;
cl->listener.cbs = cbs;
cl->listener.opaque = opaque;
}
/*****************************************************************************
......@@ -304,11 +312,12 @@ vlc_tick_t input_clock_Update( input_clock_t *cl, vlc_object_t *p_log,
void input_clock_Reset( input_clock_t *cl )
{
cl->b_has_reference = false;
cl->ref = clock_point_Create( VLC_TICK_INVALID, VLC_TICK_INVALID );
cl->ref = cl->last
= clock_point_Create( VLC_TICK_INVALID, VLC_TICK_INVALID );
cl->b_has_external_clock = false;
if( cl->clock_listener )
vlc_clock_Reset( cl->clock_listener );
if (cl->listener.cbs != NULL && cl->listener.cbs->reset != NULL)
cl->listener.cbs->reset(cl->listener.opaque);
}
/*****************************************************************************
......
......@@ -35,6 +35,36 @@
*/
typedef struct input_clock_t input_clock_t;
/**
* Callbacks for the input_clock_t listener.
*
* \see input_clock_AttachListener
*/
struct vlc_input_clock_cbs {
/**
* Notify the listener that the buffering made progress.
*
* \param opaque listener private data set from
* \ref input_clock_AttachListener
* \param ck_system time reference for the buffering progress
* \param ck_stream progress of the buffering in tick
* \param rate current playback rate for the buffering
*
* \return how much time the playback has drifted from
* the main clock
*/
vlc_tick_t (*update)(void *opaque, vlc_tick_t ck_system,
vlc_tick_t ck_stream, double rate);
/**
* Notify the listener that the buffering needed a reset.
*
* \param opaque listener private data set from
* \ref input_clock_AttachListener
*/
void (*reset)(void *opaque);
};
/**
* This function creates a new input_clock_t.
*
......@@ -49,16 +79,18 @@ input_clock_t *input_clock_New( float rate );
* (input_clock_Update()).
*
* \param clock the input clock to attach the listener to
* \param clock_listener clock created with vlc_clock_main_CreateInputMaster().
* The input_clock_t will take ownership of this clock and drive the main
* clock.
* \param listener an input clock listener virtual table
* \param opaque an opaque pointer forwarded to the listener
*
*/
void input_clock_AttachListener( input_clock_t *clock, vlc_clock_t *clock_listener );
void input_clock_AttachListener(input_clock_t *clock,
const struct vlc_input_clock_cbs *clock_listener,
void *opaque);
/**
* This function destroys a input_clock_t created by input_clock_New.
*/
void input_clock_Delete( input_clock_t * );
void input_clock_Delete(input_clock_t *);
/**
* This function will update a input_clock_t with a new clock reference point.
......@@ -82,7 +114,7 @@ vlc_tick_t input_clock_Update( input_clock_t *clock, vlc_object_t *p_log,
*
* The actual jitter estimation will not be reset by it.
*/
void input_clock_Reset( input_clock_t * );
void input_clock_Reset( input_clock_t * );
/**
* This functions will return a deadline used to control the reading speed.
......@@ -92,12 +124,12 @@ vlc_tick_t input_clock_GetWakeup( input_clock_t * );
/**
* This functions allows changing the actual reading speed.
*/
void input_clock_ChangeRate( input_clock_t *, float rate );
void input_clock_ChangeRate(input_clock_t *, float rate);
/**
* This function allows changing the pause status.
*/
void input_clock_ChangePause( input_clock_t *, bool b_paused, vlc_tick_t i_date );
void input_clock_ChangePause(input_clock_t *, bool b_paused, vlc_tick_t i_date);
/**
* This function allows rebasing the original system value date (a valid
......@@ -105,7 +137,7 @@ void input_clock_ChangePause( input_clock_t *, bool b_paused, vlc_tick_t i_da
* When using the absolute mode, it will create a discontinuity unless
* called immediately after a input_clock_Update.
*/
void input_clock_ChangeSystemOrigin( input_clock_t *, bool b_absolute, vlc_tick_t i_system );
void input_clock_ChangeSystemOrigin(input_clock_t *, bool b_absolute, vlc_tick_t i_system);
/**
* This function returns the current rate.
......
......@@ -78,7 +78,11 @@ typedef struct
/* Clock for this program */
input_clock_t *p_input_clock;
vlc_clock_main_t *p_main_clock;
struct {
vlc_clock_main_t *main;
vlc_clock_t *input;
} clocks;
/* Weak reference to the master ES clock */
const vlc_clock_t *p_master_es_clock;
enum vlc_clock_master_source active_clock_source;
......@@ -591,7 +595,9 @@ static void EsOutDelete( es_out_t *out )
static void ProgramDelete( es_out_pgrm_t *p_pgrm )
{
input_clock_Delete( p_pgrm->p_input_clock );
vlc_clock_main_Delete( p_pgrm->p_main_clock );
if (p_pgrm->clocks.input)
vlc_clock_Delete(p_pgrm->clocks.input);
vlc_clock_main_Delete(p_pgrm->clocks.main);
if( p_pgrm->p_meta )
vlc_meta_Delete( p_pgrm->p_meta );
input_source_Release( p_pgrm->source );
......@@ -1041,11 +1047,11 @@ static void EsOutDecodersStopBuffering( es_out_t *out, bool b_forced )
* frames and not from EsOutChangePosition(), like the input clock. Indeed,
* flush is asynchronous and the output used by the decoder may still need
* a valid reference of the clock to output their last frames. */
vlc_clock_main_Reset( p_sys->p_pgrm->p_main_clock );
vlc_clock_main_Reset(p_sys->p_pgrm->clocks.main);
/* Send the first PCR to the output clock. This will be used as a reference
* point for the sync point. */
vlc_clock_main_SetFirstPcr(p_sys->p_pgrm->p_main_clock, update,
vlc_clock_main_SetFirstPcr(p_sys->p_pgrm->clocks.main, update,
i_stream_start);
foreach_es_then_es_slaves(p_es)
......@@ -1106,7 +1112,7 @@ static void EsOutProgramChangePause( es_out_t *out, bool b_paused, vlc_tick_t i_
vlc_list_foreach(pgrm, &p_sys->programs, node)
{
input_clock_ChangePause(pgrm->p_input_clock, b_paused, i_date);
vlc_clock_main_ChangePause(pgrm->p_main_clock, i_date, b_paused);
vlc_clock_main_ChangePause(pgrm->clocks.main, i_date, b_paused);
}
}
......@@ -1245,6 +1251,22 @@ static void EsOutSendEsEvent(es_out_t *out, es_out_id_t *es, int action,
});
}
static vlc_tick_t
ClockListenerUpdate(void *opaque, vlc_tick_t ck_system,
vlc_tick_t ck_stream, double rate)
{
es_out_pgrm_t *pgrm = opaque;
return vlc_clock_Update(pgrm->clocks.input, ck_system, ck_stream, rate);
}
static void
ClockListenerReset(void *opaque)
{
es_out_pgrm_t *pgrm = opaque;
vlc_clock_Reset(pgrm->clocks.input);
}
static void EsOutProgramHandleClockSource( es_out_t *out, es_out_pgrm_t *p_pgrm )
{
es_out_sys_t *p_sys = container_of(out, es_out_sys_t, out);
......@@ -1257,6 +1279,13 @@ static void EsOutProgramHandleClockSource( es_out_t *out, es_out_pgrm_t *p_pgrm
* handle clock source selection when the first PCR is sent (from
* ES_OUT_SET_PCR). */
static const struct vlc_input_clock_cbs clock_cbs =
{
.update = ClockListenerUpdate,
.reset = ClockListenerReset,
};
switch( p_sys->user_clock_source )
{
case VLC_CLOCK_MASTER_AUTO:
......@@ -1275,11 +1304,12 @@ static void EsOutProgramHandleClockSource( es_out_t *out, es_out_pgrm_t *p_pgrm
/* Fall-through */
case VLC_CLOCK_MASTER_INPUT:
{
vlc_clock_t *p_master_clock =
vlc_clock_main_CreateInputMaster( p_pgrm->p_main_clock );
p_pgrm->clocks.input =
vlc_clock_main_CreateInputMaster(p_pgrm->clocks.main);
if( p_master_clock != NULL )
input_clock_AttachListener( p_pgrm->p_input_clock, p_master_clock );
if (p_pgrm->clocks.input == NULL)
break;
input_clock_AttachListener(p_pgrm->p_input_clock, &clock_cbs, p_pgrm);
p_pgrm->active_clock_source = VLC_CLOCK_MASTER_INPUT;
break;
}
......@@ -1300,6 +1330,18 @@ static void EsOutProgramHandleClockSource( es_out_t *out, es_out_pgrm_t *p_pgrm
vlc_assert_unreachable();
}
if (p_pgrm->active_clock_source != VLC_CLOCK_MASTER_INPUT)
{
p_pgrm->clocks.input = vlc_clock_main_CreateSlave(
p_pgrm->clocks.main, "pcr", UNKNOWN_ES, NULL, NULL);
if (p_pgrm->clocks.input != NULL)
{
input_clock_AttachListener(p_pgrm->p_input_clock, &clock_cbs,
p_pgrm);
}
}
msg_Dbg( p_input, "program(%d): using clock source: '%s'",
p_pgrm->i_id, clock_source_str );
}
......@@ -1445,8 +1487,9 @@ static es_out_pgrm_t *EsOutProgramAdd( es_out_t *out, input_source_t *source, in
p_pgrm->active_clock_source = VLC_CLOCK_MASTER_AUTO;
struct vlc_tracer *tracer = vlc_object_get_tracer( &p_input->obj );
p_pgrm->p_main_clock = vlc_clock_main_New( p_input->obj.logger, tracer );
if( !p_pgrm->p_main_clock )
p_pgrm->clocks.input = NULL;
p_pgrm->clocks.main = vlc_clock_main_New(p_input->obj.logger, tracer);
if (p_pgrm->clocks.main == NULL)
{
free( p_pgrm );
return NULL;
......@@ -1455,7 +1498,7 @@ static es_out_pgrm_t *EsOutProgramAdd( es_out_t *out, input_source_t *source, in
p_pgrm->p_input_clock = input_clock_New( p_sys->rate );
if( !p_pgrm->p_input_clock )
{
vlc_clock_main_Delete( p_pgrm->p_main_clock );
vlc_clock_main_Delete(p_pgrm->clocks.main);
free( p_pgrm );
return NULL;
}
......@@ -1465,13 +1508,13 @@ static es_out_pgrm_t *EsOutProgramAdd( es_out_t *out, input_source_t *source, in
const vlc_tick_t pts_delay = p_sys->i_pts_delay + p_sys->i_pts_jitter
+ p_sys->i_tracks_pts_delay;
input_clock_SetJitter( p_pgrm->p_input_clock, pts_delay, p_sys->i_cr_average );
vlc_clock_main_SetInputDejitter( p_pgrm->p_main_clock, pts_delay );
vlc_clock_main_SetInputDejitter(p_pgrm->clocks.main, pts_delay );
/* In case of low delay: don't use any output dejitter. This may result on
* some audio/video glitches when starting, but low-delay is more important
* than the visual quality if the user chose this option. */
if (input_priv(p_input)->b_low_delay)
vlc_clock_main_SetDejitter(p_pgrm->p_main_clock, 0);
vlc_clock_main_SetDejitter(p_pgrm->clocks.main, 0);
/* Append it */
vlc_list_append(&p_pgrm->node, &p_sys->programs);
......@@ -2235,17 +2278,17 @@ static void EsOutCreateDecoder( es_out_t *out, es_out_id_t *p_es )
{
p_es->master = true;
p_es->p_pgrm->p_master_es_clock = p_es->p_clock =
vlc_clock_main_CreateMaster( p_es->p_pgrm->p_main_clock,
p_es->id.str_id,
&clock_cbs, p_es );
vlc_clock_main_CreateMaster(p_es->p_pgrm->clocks.main,
p_es->id.str_id,
&clock_cbs, p_es);
}
else
{
p_es->master = false;
p_es->p_clock = vlc_clock_main_CreateSlave( p_es->p_pgrm->p_main_clock,
p_es->id.str_id,
p_es->fmt.i_cat,
&clock_cbs, p_es );
p_es->p_clock = vlc_clock_main_CreateSlave(p_es->p_pgrm->clocks.main,
p_es->id.str_id,
p_es->fmt.i_cat,
&clock_cbs, p_es);
}
if( !p_es->p_clock )
......@@ -3886,7 +3929,7 @@ static int EsOutVaPrivControlLocked( es_out_t *out, input_source_t *source,
{
input_clock_SetJitter(pgrm->p_input_clock,
i_pts_delay, i_cr_average);
vlc_clock_main_SetInputDejitter(pgrm->p_main_clock, i_pts_delay);
vlc_clock_main_SetInputDejitter(pgrm->clocks.main, i_pts_delay);
}
return VLC_SUCCESS;
}
......