From 84fe12fab557a066cfa1d8770eef81330816435e Mon Sep 17 00:00:00 2001 From: wm4 Date: Wed, 31 Dec 2014 20:32:35 +0100 Subject: client API: add function to create new mpv_handles from existing ones This may or may not be useful for client API users. Fold this API extension into the previous API bump. The previous bump was only yesterday, so it's ok. --- player/client.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'player') diff --git a/player/client.c b/player/client.c index 7d75b22256..facac7174a 100644 --- a/player/client.c +++ b/player/client.c @@ -201,6 +201,8 @@ struct mpv_handle *mp_new_client(struct mp_client_api *clients, const char *name { char nname[MAX_CLIENT_NAME]; for (int n = 1; n < 1000; n++) { + if (!name) + name = "client"; snprintf(nname, sizeof(nname) - 3, "%s", name); // - space for number for (int i = 0; nname[i]; i++) nname[i] = mp_isalnum(nname[i]) ? nname[i] : '_'; @@ -463,6 +465,18 @@ mpv_handle *mpv_create(void) return ctx; } +mpv_handle *mpv_create_client(mpv_handle *ctx, const char *name) +{ + if (!ctx) + return mpv_create(); + if (!ctx->mpctx->initialized) + return NULL; + mpv_handle *new = mp_new_client(ctx->mpctx->clients, name); + if (new) + mpv_wait_event(new, 0); // set fuzzy_initialized + return new; +} + static void *playback_thread(void *p) { struct MPContext *mpctx = p; -- cgit v1.2.3