Commit Graph

68 Commits

Author SHA1 Message Date
Alaric Senat d9b23d6a12 clock: publicly expose clock's typedefs
This is needed to expose a clock subset to stream outputs. It also
reduce the amount of redundant typedefs to the clock in the core
codebase.
2023-02-03 16:55:34 +00:00
Alaric Senat a1bfd37cb9 clock: rename private header guard
This is an core internal header guard, its naming blocks a publicly
exposed header to have this standard name.
2023-02-03 16:55:34 +00:00
Thomas Guillem 0723d9cb6f clock: continue if logger is NULL 2023-01-19 14:52:55 +00:00
Thomas Guillem 96cc32c529 clock: check master points validity
Check that system and stream are increasing and check that the coeff is
arround 1.0.

In case of invalid update, reset the clock (moving average reset to
1.0) and update starting the current point (that triggered the warning).

We assume that the previous points were bad and not the current.
2022-09-15 03:49:41 +00:00
Rémi Denis-Courmont 815116d80c Use static assertions to check constant predicates
This is more straightforward than #if/#error/#endif.
2022-08-02 13:44:55 +00:00
Thomas Guillem aad924cd2b clock: trace the calculated offset 2022-06-29 08:43:09 +00:00
Thomas Guillem 91f181d119 clock: also trace clock input offset 2022-06-29 08:43:09 +00:00
Thomas Guillem 6144634a17 clock: fill coeff_avg with the initial rate
In order to solve bad convergence of the initial jitter.

This will soften the aout->time_get imprecision at the beginning.

Thanks Denis Charmet for the idea.

Ref #27023
2022-06-04 10:16:40 +00:00
Thomas Guillem 3295489bf0 clock: avg: add AvgResetAndFill
Refs #27023
2022-06-04 10:16:40 +00:00
Thomas Guillem c9eb4194f5 trace: change render arguments order
Use the same order than the clock API (system, then pts).
2022-05-07 07:45:14 +00:00
Alexandre Janniaux 8f208ac330 src: fix typos
Typos found and reworked from codespell.
2022-01-08 15:19:32 +00:00
Nicolas LeQuec f55348fd9b logs: fit trace messages with the new trace API
Use of the previouly created trace API to collect data from demuxer, decoder and video_output.
Fields "type", "id", and "stream" are then used by a script to identify data and name curves to
display.
Here is the link of the script project: https://gitlab.com/videolabs/public/vlc-pa
2021-08-31 12:35:56 +00:00
Nicolas LeQuec 8218c474e7 src/clock: add new field track_str_id
In traces, it's useful to have the str_id of the elementary stream read.
It can be obtained through the clock.
2021-08-31 12:35:56 +00:00
Nicolas LeQuec 0bf5330a6b src/clock: add a tracer field to the main clock 2021-08-31 12:35:56 +00:00
Romain Vimont 8be3b62714 clock: add Wake()
Expose a function to wake up the wait condition. This will allow users
to loop on vlc_clock_Wait() under their own custom conditions.
2021-07-10 18:55:40 +00:00
Romain Vimont 7de5729f28 clock: remove unused Abort() 2021-07-10 18:55:40 +00:00
Romain Vimont ecf0ac6758 clock: compute target deadline on caller-side
The function vlc_clock_Wait() was in charge of converting the stream
timestamp and handling a deadline provided by the caller.

Instead, just pass the deadline, expressed in system time. This will
allow the caller to compute arbitrary deadlines and to wake up the wait
on custom conditions.
2021-07-10 18:55:40 +00:00
Romain Vimont 6c2e92f9e6 clock: remove ConvertArrayToSystem()
Now that clock lock is exposed, a wrapper function to apply several
conversions at once becomes unnecessary: the caller could execute
each conversion successively with lock held.
2021-07-10 18:55:40 +00:00
Romain Vimont a2e2c056d9 clock: expose lock
This is a first step to allow the caller to compute an arbitrary
deadline based on vlc_clock_ConvertToSystemLocked() then wait using
vlc_clock_Wait() without race condition.
2021-07-10 18:55:40 +00:00
Romain Vimont e5d44f6af0 vlc_tick: add MIN and MAX constants
Replace INT64_MIN and INT64_MAX used as vlc_tick_t values by
VLC_TICK_MIN and VLC_TICK_MAX.
2021-07-10 14:26:56 +00:00
Romain Vimont 69b61afbcd clock: do not convert offset to double
The clock offset is a 64-bit integer (vlc_tick_t), so a conversion to
double, which has only 53 bits precision, could produce incorrect
values.
2021-07-06 15:34:17 +00:00
Thomas Guillem c56c3f3fbb clock: check for pcr_delay validity
Don't wait more than CR_MAX_GAP. The CR_MAX_GAP might be too big
(60 seconds). This algorithm, like the one in input_clock.c could be
improved by comparing stream and system date.

This a work around buggy demuxers or corrupted samples/streams. That is
the reason that the new log should draw attention to developers.
2021-06-01 13:08:14 +00:00
Thomas Guillem ef14ac9ae4 clock: expose CR_MAX_GAP internally 2021-06-01 13:08:14 +00:00
Thomas Guillem 07e78801d4 clock: attach a logger 2021-06-01 13:08:14 +00:00
Thomas Guillem dfd4929f22 input_clock: change clock listener attachment
Allow to attach the clock listener after the input clock is created.
2021-05-04 07:39:35 +00:00
Thomas Guillem 910e98c24d clock: add vlc_clock_main_CreateInputMaster()
The input master clock has a higher priority than the ES master clock.
There can be one input master and one es master at a given time. In that
case, the ES master will behave as a slave clock.

This will allow to be more flexible from the es_out.c when creating
input and ES clocks.
2021-05-04 07:39:35 +00:00
Thomas Guillem 66646d81a4 core: add the "auto" clock source
The "--clock-master=auto" option will select the input as the clock
source when the input can't pace (live content), and will fallback to
the "audio" source otherwise (most common case).
2021-04-12 09:19:23 +02:00
Thomas Guillem 2200210d93 core: add the "input" clock source
The "--clock-master=input" option (disabled by default) allow to setup
the input_clock_t as the master clock. This will restore the VLC 3.0
behavior and use PCR update points as the clock source. Therefore, audio
and video tracks will be altered to catch-up with the input.
2021-04-12 09:18:56 +02:00
Thomas Guillem abd8991d8e input_clock: add the ability to drive the main_clock 2021-04-12 09:17:51 +02:00
Thomas Guillem e0930c2b65 input_clock: remove useless mutex
It is now always accessed from es_out.c and protected with the es_out
mutex.
2021-01-29 12:34:41 +01:00
Hugo Beauzée-Luyssen ea6bd41a70 clock_internal.h: Protect against double inclusion 2020-12-04 11:08:32 +01:00
Thomas Guillem 940092fdba clock: assert that there is only one master
If a second master was created, the first one was automatically
downgraded without notifying the owner.

This was never the case since es_out.c, the only clock client (for now)
is always ensuring that only one master is created.
2020-09-21 14:10:26 +02:00
Thomas Guillem 7f1c214eff clock: remove unused vlc_clock_main_SetMaster()
The es_out is never changing the clock type for now. If it is needed in
the future, delete() + new() could be a good solution.
2020-09-21 14:10:26 +02:00
Steve Lhomme 5851986b6f clock: don't return an error in vlc_clock_Wait()
Callers never use it and probably won't do much about it.
2020-08-17 16:13:47 +02:00
Steve Lhomme 3713d3c276 input_clock: set the final i_late version early 2020-08-17 16:13:46 +02:00
Steve Lhomme cc0cec27dc input_clock: remove unused input_clock_ConvertTS
Also remove internal i_ts_max which is always VLC_TICK_INVALID, and yet was
used as a valid value.
2020-08-17 16:13:46 +02:00
Steve Lhomme 3b6de5fc01 clock: handle the INT64_MAX slave update early
Don't lock the main clock when we don't need to.
2020-08-17 16:13:46 +02:00
Zhao Zhili fa1d0ea16d clock: check condition before calculation
Signed-off-by: Thomas Guillem <thomas@gllm.fr>
2020-05-22 08:57:03 +02:00
Rémi Denis-Courmont a18c4d6570 thread: remove vlc_cond_destroy() 2020-02-21 19:17:53 +02:00
Rémi Denis-Courmont a3226cf890 thread: remove vlc_mutex_destroy() 2020-02-21 19:16:09 +02:00
Thomas Guillem d689a8c37f clock: move SetDejitter to the main clock
This function was unused, was only working for the master clock and impacted
the main_clock.
2019-12-09 12:11:36 +01:00
Francois Cartegnie 6324cfa6f1 input: return/debug clock update delay 2019-10-15 17:05:18 +02:00
Thomas Guillem 491b48a6ca clock: fix false start with some SPU tracks
Reminder of the design: Any calls to vlc_clock_ConvertToSystem() or
vlc_clock_Update() will create the reference point (wait_sync_ref) if it is the
first call of all sub clocks. This point will be used as a reference by all
clocks until the master does its first vlc_clock_Update().

Creating a reference point from vlc_clock_ConvertToSystem() can be discussed.
You don't expect to modify the main_clock from a function with such name
("convert"). The pro of this design is that vlc_clock_ConvertToSystem() can't
fail and will always return a valid point. Returning a valid point is
mandatory for the actual design, let's see how the audio output is using it:

The aout will first call vlc_clock_ConvertToSystem(ts) to get the first system
date of the ts, this first system date will take into account the output
dejitter, the input dejitter and the pcr_delay int and will be very likely in
the future. Enough in the future to wait for any other tracks. When this system
date is reached by the aout plugin, the aout will call the first update() and
will drive all other clocks.

Now the problem: any outputs can create the first reference point, but when it
is the SPU output, it can lead to very high imprecision. For example, with the
following .srt file:

"""
1
00:00:00,00 --> 00:00:42,00
SRT
"""

If you seek to 20seconds, the SPU output will convert its first point, that is
00:00:00,00, this could lead to the creation of the reference point. This
reference point will be delayed by 20seconds and will cause all other outputs to
wait for 20seconds (approximately) before doing their first rendering.

To fix this issue, this commit adds a priority system. The clock with higher
priority will always be able to override an old reference point. The SPU clock
will always have the lowest priority.
2019-10-14 11:22:00 +02:00
Thomas Guillem 09d76e173a clock: remove unused variable 2019-09-30 09:07:15 +02:00
Thomas Guillem ac1ad06d2d clock: re-indent after last commit
No functional changes.
2019-09-23 13:30:30 +02:00
Thomas Guillem dd18346e52 clock: handle forced points
This won't have any effect on the clock but this will forward the forced update
point via the callback.
2019-09-23 13:30:30 +02:00
Thomas Guillem 6f50e9fea5 clock: add vlc_clock_UpdateVideo()
Used to send the fps of the current point.
2019-09-23 13:30:30 +02:00
Thomas Guillem b44d83d072 clock: forward clock update points 2019-09-23 13:30:30 +02:00
Thomas Guillem 5d3df74c8d clock: rework/document pause handling
Also return INT64_MAX from vlc_clock_Update() when paused.
2019-09-23 13:30:30 +02:00
Thomas Guillem ee4afd6821 remove unused #include <vlc_input.h> 2019-06-03 16:15:55 +02:00