summaryrefslogtreecommitdiffstats
path: root/misc
diff options
context:
space:
mode:
Diffstat (limited to 'misc')
-rw-r--r--misc/dispatch.c17
1 files changed, 16 insertions, 1 deletions
diff --git a/misc/dispatch.c b/misc/dispatch.c
index 69192e8514..07f8995628 100644
--- a/misc/dispatch.c
+++ b/misc/dispatch.c
@@ -202,8 +202,15 @@ void mp_dispatch_suspend(struct mp_dispatch_queue *queue)
{
pthread_mutex_lock(&queue->lock);
queue->suspend_requested++;
- while (!queue->suspended)
+ while (!queue->suspended) {
+ pthread_mutex_unlock(&queue->lock);
+ if (queue->wakeup_fn)
+ queue->wakeup_fn(queue->wakeup_ctx);
+ pthread_mutex_lock(&queue->lock);
+ if (queue->suspended)
+ break;
pthread_cond_wait(&queue->cond, &queue->lock);
+ }
pthread_mutex_unlock(&queue->lock);
}
@@ -233,6 +240,14 @@ void mp_dispatch_lock(struct mp_dispatch_queue *queue)
queue->locked = true;
break;
}
+ if (!queue->suspended) {
+ pthread_mutex_unlock(&queue->lock);
+ if (queue->wakeup_fn)
+ queue->wakeup_fn(queue->wakeup_ctx);
+ pthread_mutex_lock(&queue->lock);
+ if (queue->suspended)
+ continue;
+ }
pthread_cond_wait(&queue->cond, &queue->lock);
}
pthread_mutex_unlock(&queue->lock);