From 51834592fc59325d6276feb4f35a373985fc7fdd Mon Sep 17 00:00:00 2001 From: wm4 Date: Sun, 8 Jun 2014 16:11:11 +0200 Subject: 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. --- player/client.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'player') 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]; } -- cgit v1.2.3