[vlc-commits] Revert "video_output:control: merge the two wait conditions"
Steve Lhomme
git at videolan.org
Thu Jan 21 13:21:25 UTC 2021
vlc | branch: master | Steve Lhomme <robux4 at ycbcr.xyz> | Wed Jan 20 12:26:48 2021 +0100| [872b90865add883675b37c31d3e10ac4986900bf] | committer: Steve Lhomme
Revert "video_output:control: merge the two wait conditions"
This reverts commit 6d31fe007b20dbe07eba5420de8ec84653c7c7c9.
The waiting and signaling of the same condition variable in the same thread
seems to be a no-no. And because of this commit some playback tests failed
as well as tsan checks.
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=872b90865add883675b37c31d3e10ac4986900bf
---
src/video_output/control.c | 25 +++++++++++--------------
src/video_output/control.h | 4 +++-
2 files changed, 14 insertions(+), 15 deletions(-)
diff --git a/src/video_output/control.c b/src/video_output/control.c
index eb6fea7681..5d72caf60e 100644
--- a/src/video_output/control.c
+++ b/src/video_output/control.c
@@ -33,9 +33,11 @@
void vout_control_Init(vout_control_t *ctrl)
{
vlc_mutex_init(&ctrl->lock);
+ vlc_cond_init(&ctrl->wait_request);
vlc_cond_init(&ctrl->wait_available);
ctrl->is_held = false;
+ ctrl->is_waiting = false;
ctrl->forced_awake = false;
ARRAY_INIT(ctrl->cmd);
}
@@ -50,7 +52,7 @@ void vout_control_PushMouse(vout_control_t *ctrl, const vlc_mouse_t *video_mouse
{
vlc_mutex_lock(&ctrl->lock);
ARRAY_APPEND(ctrl->cmd, *video_mouse);
- vlc_cond_signal(&ctrl->wait_available);
+ vlc_cond_signal(&ctrl->wait_request);
vlc_mutex_unlock(&ctrl->lock);
}
@@ -58,14 +60,14 @@ void vout_control_Wake(vout_control_t *ctrl)
{
vlc_mutex_lock(&ctrl->lock);
ctrl->forced_awake = true;
- vlc_cond_signal(&ctrl->wait_available);
+ vlc_cond_signal(&ctrl->wait_request);
vlc_mutex_unlock(&ctrl->lock);
}
void vout_control_Hold(vout_control_t *ctrl)
{
vlc_mutex_lock(&ctrl->lock);
- while (ctrl->is_held)
+ while (ctrl->is_held || !ctrl->is_waiting)
vlc_cond_wait(&ctrl->wait_available, &ctrl->lock);
ctrl->is_held = true;
vlc_mutex_unlock(&ctrl->lock);
@@ -85,24 +87,19 @@ int vout_control_Pop(vout_control_t *ctrl, vlc_mouse_t *mouse, vlc_tick_t deadli
bool has_cmd = false;
vlc_mutex_lock(&ctrl->lock);
- while (ctrl->is_held)
- // wait until code outside the vout thread loop has finished doing things
- vlc_cond_wait(&ctrl->wait_available, &ctrl->lock);
-
if (ctrl->cmd.i_size <= 0) {
/* Spurious wakeups are perfectly fine */
if (deadline != VLC_TICK_INVALID && !ctrl->forced_awake) {
- ctrl->is_held = true;
- // wait for something to happen while blocking vout_control_Hold
- // - new mouse state received
- // - control_Wake called: new picture arrived or terminating vout
- vlc_cond_timedwait(&ctrl->wait_available, &ctrl->lock, deadline);
- // allow vout_control_Hold again
- ctrl->is_held = false;
+ ctrl->is_waiting = true;
vlc_cond_signal(&ctrl->wait_available);
+ vlc_cond_timedwait(&ctrl->wait_request, &ctrl->lock, deadline);
+ ctrl->is_waiting = false;
}
}
+ while (ctrl->is_held)
+ vlc_cond_wait(&ctrl->wait_available, &ctrl->lock);
+
if (ctrl->cmd.i_size > 0) {
has_cmd = true;
*mouse = ARRAY_VAL(ctrl->cmd, 0);
diff --git a/src/video_output/control.h b/src/video_output/control.h
index ce46454ebe..e85af59236 100644
--- a/src/video_output/control.h
+++ b/src/video_output/control.h
@@ -28,11 +28,13 @@
/* */
typedef struct {
vlc_mutex_t lock;
+ vlc_cond_t wait_request;
vlc_cond_t wait_available;
/* */
bool forced_awake;
- bool is_held; // control FIFO held outside of the vout thread
+ bool is_waiting;
+ bool is_held;
DECL_ARRAY(vlc_mouse_t) cmd;
} vout_control_t;
More information about the vlc-commits
mailing list