[vlc-devel] [PATCH v5 16/24] video_output: use INT64_MAX for the invalid control pop deadline
Steve Lhomme
robux4 at ycbcr.xyz
Mon Aug 24 09:41:57 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 3b7fabb07e9..190792a472a 100644
--- a/src/video_output/control.c
+++ b/src/video_output/control.c
@@ -114,7 +114,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 5d84db34d13..78a41502c5d 100644
--- a/src/video_output/control.h
+++ b/src/video_output/control.h
@@ -69,6 +69,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 fa913522311..975e16198cb 100644
--- a/src/video_output/video_output.c
+++ b/src/video_output/video_output.c
@@ -1447,7 +1447,7 @@ static int ThreadDisplayPicture(vout_thread_sys_t *vout, vlc_tick_t *next_render
vlc_mutex_unlock(&sys->filter.lock);
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 */
@@ -1492,10 +1492,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;
@@ -1828,7 +1826,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 (;;) {
@@ -1836,16 +1834,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