diff options
author | wm4 <wm4@nowhere> | 2016-09-01 21:55:21 +0200 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2016-09-01 21:55:21 +0200 |
commit | 453fea87fa8e048b0b49eb7996c929792d7bfb40 (patch) | |
tree | ada393bb1ef7fbf3ae7724943f5e22cafe8657a9 /player/main.c | |
parent | 1393d79417278dfa63a7a5c767093eaf3504edce (diff) | |
download | mpv-453fea87fa8e048b0b49eb7996c929792d7bfb40.tar.bz2 mpv-453fea87fa8e048b0b49eb7996c929792d7bfb40.tar.xz |
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().
Diffstat (limited to 'player/main.c')
-rw-r--r-- | player/main.c | 21 |
1 files changed, 10 insertions, 11 deletions
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; |