diff options
author | wm4 <wm4@nowhere> | 2014-03-01 15:46:39 +0100 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2014-03-01 15:46:39 +0100 |
commit | 4de22d1cbc1ff8201f66629ca75de32e7e7ed223 (patch) | |
tree | bdec969f2172ff28587b7cf5ce6813149aba5e21 | |
parent | b684ea55a513eddf73744527cd9ce1605fce148c (diff) | |
download | mpv-4de22d1cbc1ff8201f66629ca75de32e7e7ed223.tar.bz2 mpv-4de22d1cbc1ff8201f66629ca75de32e7e7ed223.tar.xz |
client API: fix playloop thread wakeup
The playloop usually waits in select(), using a timeout needed for
refilling audio and video buffers. This means the client API needs
a separate mechanism to interrupt the select() call. This mechanism
exists, but I forgot to use it. This commit fixes it.
If it works, this will make the client API react faster, epsecially
in audio-only mode. If video is enabled, the reaction time is capped
to 50ms (or somewhat faster if the framerate is >20 fps), because
the playloop stops reacting to anything in order to render and time
the next video frame. (This will be fixed later by moving the VO
to its own thread.)
-rw-r--r-- | player/main.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/player/main.c b/player/main.c index e510081d5b..bf97a39a3a 100644 --- a/player/main.c +++ b/player/main.c @@ -143,6 +143,7 @@ void mp_destroy(struct MPContext *mpctx) command_uninit(mpctx); + mp_dispatch_set_wakeup_fn(mpctx->dispatch, NULL, NULL); mp_input_uninit(mpctx->input); osd_free(mpctx->osd); @@ -353,6 +354,12 @@ struct MPContext *mp_create(void) return mpctx; } +static void wakeup_playloop(void *ctx) +{ + struct MPContext *mpctx = ctx; + mp_input_wakeup(mpctx->input); +} + // Finish mpctx initialization. This must be done after setting up all options. // Some of the initializations depend on the options, and can't be changed or // undone later. @@ -372,6 +379,8 @@ int mp_initialize(struct MPContext *mpctx) mpctx->input = mp_input_init(mpctx->global); stream_set_interrupt_callback(mp_input_check_interrupt, mpctx->input); + mp_dispatch_set_wakeup_fn(mpctx->dispatch, wakeup_playloop, mpctx); + #if HAVE_ENCODING if (opts->encode_output.file && *opts->encode_output.file) { mpctx->encode_lavc_ctx = encode_lavc_init(&opts->encode_output, |