[vlc-devel] [PATCH v2 09/18] video_output: use INT64_MAX for the invalid control pop deadline
Steve Lhomme
robux4 at ycbcr.xyz
Wed Sep 16 13:14:35 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 | 14 ++++++--------
3 files changed, 9 insertions(+), 9 deletions(-)
diff --git a/src/video_output/control.c b/src/video_output/control.c
index 3b7fabb07e9..6cd8e1f8e82 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 != INFINITE_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..044574a3104 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 INFINITE_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 0c193ea233a..28f9201ea40 100644
--- a/src/video_output/video_output.c
+++ b/src/video_output/video_output.c
@@ -1486,7 +1486,7 @@ static int ThreadDisplayPicture(vout_thread_sys_t *vout, vlc_tick_t *deadline)
vlc_mutex_unlock(&sys->filter.lock);
if (deadline)
- *deadline = VLC_TICK_INVALID;
+ *deadline = INFINITE_DEADLINE;
if (first)
if (ThreadDisplayPreparePicture(vout, true, frame_by_frame, &paused)) /* FIXME not sure it is ok */
@@ -1533,10 +1533,8 @@ static int ThreadDisplayPicture(vout_thread_sys_t *vout, vlc_tick_t *deadline)
display_next_frame = true;
}
- if (deadline != NULL) {
- if (*deadline == VLC_TICK_INVALID || date_next < *deadline)
- *deadline = date_next;
- }
+ if (deadline != NULL)
+ *deadline = __MIN(*deadline, date_next);
}
}
@@ -1882,7 +1880,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 = INFINITE_DEADLINE;
bool wait = false;
for (;;) {
@@ -1891,9 +1889,9 @@ static void *Thread(void *object)
if (wait)
{
const vlc_tick_t max_deadline = vlc_tick_now() + VLC_TICK_FROM_MS(100);
- deadline = deadline == VLC_TICK_INVALID ? max_deadline : __MIN(deadline, max_deadline);
+ deadline = __MIN(deadline, max_deadline);
} else {
- deadline = VLC_TICK_INVALID;
+ deadline = INFINITE_DEADLINE;
}
while (!vout_control_Pop(&sys->control, &cmd, deadline)) {
--
2.26.2
More information about the vlc-devel
mailing list