From 31adc87bde5d7d671b9b52cd912875d037501a1c Mon Sep 17 00:00:00 2001 From: wm4 Date: Fri, 15 Jan 2016 22:49:10 +0100 Subject: global: add client API pointer to library handle Makes the next commit simpler. It's probably a bad idea to add more fields to the global state, but on the other hand the client API state is pretty much per-instance anyway. It also will help with things like the proposed libmpv custom stream API. --- common/global.h | 1 + player/client.c | 7 +++++++ player/client.h | 1 + player/misc.c | 1 + 4 files changed, 10 insertions(+) diff --git a/common/global.h b/common/global.h index 546c585294..fb70b4ff01 100644 --- a/common/global.h +++ b/common/global.h @@ -7,6 +7,7 @@ struct mpv_global { struct MPOpts *opts; struct mp_log *log; + struct mp_client_api *client_api; }; #endif diff --git a/player/client.c b/player/client.c index f4758f653c..3abc8d8086 100644 --- a/player/client.c +++ b/player/client.c @@ -21,6 +21,7 @@ #include #include "common/common.h" +#include "common/global.h" #include "common/msg.h" #include "common/msg_control.h" #include "input/input.h" @@ -137,6 +138,7 @@ void mp_clients_init(struct MPContext *mpctx) *mpctx->clients = (struct mp_client_api) { .mpctx = mpctx, }; + mpctx->global->client_api = mpctx->clients; pthread_mutex_init(&mpctx->clients->lock, NULL); } @@ -264,6 +266,11 @@ struct MPContext *mp_client_get_core(struct mpv_handle *ctx) return ctx->mpctx; } +struct MPContext *mp_client_api_get_core(struct mp_client_api *api) +{ + return api->mpctx; +} + static void wakeup_client(struct mpv_handle *ctx) { pthread_mutex_lock(&ctx->wakeup_lock); diff --git a/player/client.h b/player/client.h index 5bc3c770eb..a9d6cbde52 100644 --- a/player/client.h +++ b/player/client.h @@ -31,6 +31,7 @@ void mp_client_property_change(struct MPContext *mpctx, const char *name); struct mpv_handle *mp_new_client(struct mp_client_api *clients, const char *name); struct mp_log *mp_client_get_log(struct mpv_handle *ctx); struct MPContext *mp_client_get_core(struct mpv_handle *ctx); +struct MPContext *mp_client_api_get_core(struct mp_client_api *api); void mp_resume_all(struct mpv_handle *ctx); diff --git a/player/misc.c b/player/misc.c index 58dd6af4f9..3729d7a42c 100644 --- a/player/misc.c +++ b/player/misc.c @@ -250,6 +250,7 @@ struct mpv_global *create_sub_global(struct MPContext *mpctx) *new = (struct mpv_global){ .log = mpctx->global->log, .opts = new_config->optstruct, + .client_api = mpctx->clients, }; return new; } -- cgit v1.2.3