summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2014-06-08 16:11:11 +0200
committerwm4 <wm4@nowhere>2014-06-08 16:11:11 +0200
commit51834592fc59325d6276feb4f35a373985fc7fdd (patch)
tree40c9e64389757e4c3f791fa29bc3dcea55aebe41
parentf118d2af6a132487580160e16035f47072dbbac1 (diff)
downloadmpv-51834592fc59325d6276feb4f35a373985fc7fdd.tar.bz2
mpv-51834592fc59325d6276feb4f35a373985fc7fdd.tar.xz
client API: trigger wakeup when creating wakeup pipe/callback
Since redundant wakeups are avoided now, it's easy to miss a wakeup when creating/setting the pipe/callback after the client API was signalled. If the client API is signalled, need_wakeup is set to true, and wakeup_client skips writing to the pipe or calling the client API. That this can happen is not very obvious to the client API, so trigger a wakeup right on start in order to remove this special case.
-rw-r--r--player/client.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/player/client.c b/player/client.c
index 2f8a092b4e..c375a11d94 100644
--- a/player/client.c
+++ b/player/client.c
@@ -251,6 +251,8 @@ void mpv_set_wakeup_callback(mpv_handle *ctx, void (*cb)(void *d), void *d)
pthread_mutex_lock(&ctx->wakeup_lock);
ctx->wakeup_cb = cb;
ctx->wakeup_cb_ctx = d;
+ if (ctx->wakeup_cb)
+ ctx->wakeup_cb(ctx->wakeup_cb_ctx);
pthread_mutex_unlock(&ctx->wakeup_lock);
}
@@ -1324,8 +1326,10 @@ int mpv_request_log_messages(mpv_handle *ctx, const char *min_level)
int mpv_get_wakeup_pipe(mpv_handle *ctx)
{
pthread_mutex_lock(&ctx->wakeup_lock);
- if (ctx->wakeup_pipe[0] == -1)
+ if (ctx->wakeup_pipe[0] == -1) {
mp_make_wakeup_pipe(ctx->wakeup_pipe);
+ write(ctx->wakeup_pipe[1], &(char){0}, 1);
+ }
pthread_mutex_unlock(&ctx->wakeup_lock);
return ctx->wakeup_pipe[0];
}