From 453fea87fa8e048b0b49eb7996c929792d7bfb40 Mon Sep 17 00:00:00 2001 From: wm4 Date: Thu, 1 Sep 2016 21:55:21 +0200 Subject: client API: create core thread at an earlier time Create the core thread right in mpv_create(), and reduce what mpv_initialize() does further. This is simpler, and allows the API user to do more before calling mpv_initialize(). The latter is not the real goal, rather we'd like mpv_intialize() reduced to do almost nothing. It still does a lot, but nothing truly special anymore that is absolutely required for basic mpv workings. One thing we want the user to be able to do is changing properties before mpv_initialize() to reduce the special status of mpv_set_option(). --- player/main.c | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) (limited to 'player/main.c') diff --git a/player/main.c b/player/main.c index 3faa25ecd5..6acb617520 100644 --- a/player/main.c +++ b/player/main.c @@ -323,6 +323,12 @@ static int cfg_include(void *ctx, char *filename, int flags) return r; } +void wakeup_playloop(void *ctx) +{ + struct MPContext *mpctx = ctx; + mp_input_wakeup(mpctx->input); +} + struct MPContext *mp_create(void) { mp_time_init(); @@ -366,18 +372,16 @@ struct MPContext *mp_create(void) command_init(mpctx); init_libav(mpctx->global); mp_clients_init(mpctx); + mpctx->osd = osd_create(mpctx->global); #if HAVE_COCOA cocoa_set_input_context(mpctx->input); #endif - return mpctx; -} + mp_input_set_cancel(mpctx->input, mpctx->playback_abort); + mp_dispatch_set_wakeup_fn(mpctx->dispatch, wakeup_playloop, mpctx); -void wakeup_playloop(void *ctx) -{ - struct MPContext *mpctx = ctx; - mp_input_wakeup(mpctx->input); + return mpctx; } // Finish mpctx initialization. This must be done after setting up all options. @@ -442,9 +446,6 @@ int mp_initialize(struct MPContext *mpctx, char **options) return -3; mp_input_load(mpctx->input); - mp_input_set_cancel(mpctx->input, mpctx->playback_abort); - - mp_dispatch_set_wakeup_fn(mpctx->dispatch, wakeup_playloop, mpctx); #if HAVE_ENCODING if (opts->encode_opts->file && opts->encode_opts->file[0]) { @@ -464,8 +465,6 @@ int mp_initialize(struct MPContext *mpctx, char **options) MP_WARN(mpctx, "There will be no OSD and no text subtitles.\n"); #endif - mpctx->osd = osd_create(mpctx->global); - // From this point on, all mpctx members are initialized. mpctx->initialized = true; -- cgit v1.2.3