[vlc-devel] [PATCH v2 07/13] video_output: use INT64_MAX for the invalid control pop deadline
Steve Lhomme
robux4 at ycbcr.xyz
Mon Aug 17 15:15:26 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 96d598f81ad..90451cc6f91 100644
--- a/src/video_output/control.c
+++ b/src/video_output/control.c
@@ -113,7 +113,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 a6d233c4f53..622ee66dfc6 100644
--- a/src/video_output/control.h
+++ b/src/video_output/control.h
@@ -63,6 +63,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 4872cf89cd6..be7b2185fe8 100644
--- a/src/video_output/video_output.c
+++ b/src/video_output/video_output.c
@@ -1479,7 +1479,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 */
@@ -1524,10 +1524,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;
@@ -1881,7 +1879,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 (;;) {
@@ -1889,16 +1887,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