[vlc-devel] [PATCH 3/7] video_output: use INT64_MAX for the invalid control pop deadline
Steve Lhomme
robux4 at ycbcr.xyz
Thu Aug 13 14:12:44 CEST 2020
This simplifies setting the value.
When reading a control with an invalid deadline, we don't wait for a command
to arrive.
---
src/video_output/control.c | 2 +-
src/video_output/control.h | 2 ++
src/video_output/video_output.c | 22 ++++++++--------------
3 files changed, 11 insertions(+), 15 deletions(-)
diff --git a/src/video_output/control.c b/src/video_output/control.c
index fd0c80fe6eb..9faacb7e815 100644
--- a/src/video_output/control.c
+++ b/src/video_output/control.c
@@ -147,7 +147,7 @@ int vout_control_Pop(vout_control_t *ctrl, vout_control_cmd_t *cmd,
if (ctrl->cmd.i_size <= 0) {
/* Spurious wakeups are perfectly fine */
- if (deadline != VLC_TICK_INVALID && ctrl->can_sleep) {
+ if (deadline != INVALID_DEADLINE && ctrl->can_sleep) {
ctrl->is_waiting = true;
vlc_cond_signal(&ctrl->wait_available);
vlc_cond_timedwait(&ctrl->wait_request, &ctrl->lock, deadline);
diff --git a/src/video_output/control.h b/src/video_output/control.h
index eee86c4ca93..6161c5ba3db 100644
--- a/src/video_output/control.h
+++ b/src/video_output/control.h
@@ -76,6 +76,8 @@ void vout_control_Hold(vout_control_t *);
void vout_control_Release(vout_control_t *);
/* control inside of the vout thread */
+#define INVALID_DEADLINE ((vlc_tick_t) INT64_MAX)
+
int vout_control_Pop(vout_control_t *, vout_control_cmd_t *, vlc_tick_t deadline);
void vout_control_Dead(vout_control_t *);
diff --git a/src/video_output/video_output.c b/src/video_output/video_output.c
index 9c9045b6e67..dacb6a669a7 100644
--- a/src/video_output/video_output.c
+++ b/src/video_output/video_output.c
@@ -1444,7 +1444,7 @@ static int ThreadDisplayPicture(vout_thread_sys_t *vout, vlc_tick_t *next_render
assert(sys->clock);
if (next_render)
- *next_render = VLC_TICK_INVALID;
+ *next_render = INVALID_DEADLINE;
if (first)
if (ThreadDisplayPreparePicture(vout, true, frame_by_frame, &paused)) /* FIXME not sure it is ok */
@@ -1489,10 +1489,8 @@ static int ThreadDisplayPicture(vout_thread_sys_t *vout, vlc_tick_t *next_render
}
else
{
- if (!frame_by_frame) {
- if (*next_render == VLC_TICK_INVALID || *next_render > next_system_pts)
- *next_render = next_system_pts;
- }
+ if (!frame_by_frame)
+ *next_render = __MIN(*next_render, next_system_pts);
if (next_system_pts <= system_now)
drop_next_frame = true;
@@ -1846,7 +1844,7 @@ static void *Thread(void *object)
vout_thread_sys_t *vout = object;
vout_thread_sys_t *sys = vout;
- vlc_tick_t deadline = VLC_TICK_INVALID;
+ vlc_tick_t deadline = INVALID_DEADLINE;
bool wait = false;
for (;;) {
@@ -1854,16 +1852,12 @@ static void *Thread(void *object)
if (wait)
{
- const vlc_tick_t max_deadline = vlc_tick_now() + VLC_TICK_FROM_MS(100);
- if (deadline == VLC_TICK_INVALID)
- deadline = max_deadline;
- else
- {
+ if (deadline != INVALID_DEADLINE)
deadline -= vout_chrono_GetHigh(&sys->render) + VOUT_MWAIT_TOLERANCE;
- deadline = __MIN(deadline, max_deadline);
- }
+ const vlc_tick_t max_deadline = vlc_tick_now() + VLC_TICK_FROM_MS(100);
+ deadline = __MIN(deadline, max_deadline);
} else {
- deadline = VLC_TICK_INVALID;
+ deadline = INVALID_DEADLINE;
}
while (!vout_control_Pop(&sys->control, &cmd, deadline)) {
--
2.26.2
More information about the vlc-devel
mailing list