diff options
author | wm4 <wm4@nowhere> | 2014-12-31 20:32:35 +0100 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2014-12-31 20:50:06 +0100 |
commit | 84fe12fab557a066cfa1d8770eef81330816435e (patch) | |
tree | 933e0ec85a784c624e446f16a9babe38e572a1d0 /player/client.c | |
parent | a850bf786e3bea2ce9969d6794835a0724f29b0d (diff) | |
download | mpv-84fe12fab557a066cfa1d8770eef81330816435e.tar.bz2 mpv-84fe12fab557a066cfa1d8770eef81330816435e.tar.xz |
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.
Diffstat (limited to 'player/client.c')
-rw-r--r-- | player/client.c | 14 |
1 files changed, 14 insertions, 0 deletions
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; |