diff options
author | wm4 <wm4@nowhere> | 2016-09-16 14:23:54 +0200 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2016-09-16 14:37:48 +0200 |
commit | b8ade7c99b830ee9870040bcfc1f2c3d3a64d172 (patch) | |
tree | 48df8031d90be4e6e1f9c9c4045a72e21c33862c /video | |
parent | f845f64c2abe4361084b4bc07f5f1ea5dd43ec9f (diff) | |
download | mpv-b8ade7c99b830ee9870040bcfc1f2c3d3a64d172.tar.bz2 mpv-b8ade7c99b830ee9870040bcfc1f2c3d3a64d172.tar.xz |
player, ao, vo: don't call mp_input_wakeup() directly
Currently, calling mp_input_wakeup() will wake up the core thread (also
called the playloop). This seems odd, but currently the core indeed
calls mp_input_wait() when it has nothing more to do. It's done this way
because MPlayer used input_ctx as central "mainloop".
This is probably going to change. Remove direct calls to this function,
and replace it with mp_wakeup_core() calls. ao and vo are changed to use
opaque callbacks and not use input_ctx for this purpose. Other code
already uses opaque callbacks, or has legitimate reasons to use
input_ctx directly (such as sending actual user input).
Diffstat (limited to 'video')
-rw-r--r-- | video/out/vo.c | 20 | ||||
-rw-r--r-- | video/out/vo.h | 2 |
2 files changed, 16 insertions, 6 deletions
diff --git a/video/out/vo.c b/video/out/vo.c index 8c66b0dab3..b9d9bcd4f2 100644 --- a/video/out/vo.c +++ b/video/out/vo.c @@ -213,6 +213,8 @@ static void dealloc_vo(struct vo *vo) static struct vo *vo_create(bool probing, struct mpv_global *global, struct vo_extra *ex, char *name, char **args) { + assert(ex->wakeup_cb); + struct mp_log *log = mp_log_new(NULL, global->log, "vo"); struct m_obj_desc desc; if (!m_obj_list_find(&desc, &vo_obj_list, bstr0(name))) { @@ -313,6 +315,12 @@ void vo_destroy(struct vo *vo) dealloc_vo(vo); } +// Wakeup the playloop to queue new video frames etc. +static void wakeup_core(struct vo *vo) +{ + vo->extra.wakeup_cb(vo->extra.wakeup_ctx); +} + // Drop timing information on discontinuities like seeking. // Always called locked. static void reset_vsync_timings(struct vo *vo) @@ -477,7 +485,7 @@ static void update_display_fps(struct vo *vo) // make sure to update the player in->queued_events |= VO_EVENT_WIN_STATE; - mp_input_wakeup(vo->input_ctx); + wakeup_core(vo); } in->nominal_vsync_interval = in->display_fps > 0 ? 1e6 / in->display_fps : 0; @@ -795,7 +803,7 @@ static bool render_frame(struct vo *vo) in->hasframe_rendered = true; int64_t prev_drop_count = vo->in->drop_count; pthread_mutex_unlock(&in->lock); - mp_input_wakeup(vo->input_ctx); // core can queue new video now + wakeup_core(vo); // core can queue new video now MP_STATS(vo, "start video"); @@ -826,7 +834,7 @@ static bool render_frame(struct vo *vo) } pthread_cond_broadcast(&in->wakeup); // for vo_wait_frame() - mp_input_wakeup(vo->input_ctx); + wakeup_core(vo); got_frame = true; @@ -906,12 +914,12 @@ static void *vo_thread(void *ptr) wait_until = MPMIN(wait_until, in->wakeup_pts); } else { in->wakeup_pts = 0; - mp_input_wakeup(vo->input_ctx); + wakeup_core(vo); } } if (vo->want_redraw && !in->want_redraw) { in->want_redraw = true; - mp_input_wakeup(vo->input_ctx); + wakeup_core(vo); } bool redraw = in->request_redraw; bool send_reset = in->send_reset; @@ -1159,7 +1167,7 @@ void vo_event(struct vo *vo, int event) struct vo_internal *in = vo->in; pthread_mutex_lock(&in->lock); if ((in->queued_events & event & VO_EVENTS_USER) != (event & VO_EVENTS_USER)) - mp_input_wakeup(vo->input_ctx); + wakeup_core(vo); if (event) wakeup_locked(vo); in->queued_events |= event; diff --git a/video/out/vo.h b/video/out/vo.h index c40367d406..e35085c49b 100644 --- a/video/out/vo.h +++ b/video/out/vo.h @@ -169,6 +169,8 @@ struct vo_extra { struct osd_state *osd; struct encode_lavc_context *encode_lavc_ctx; struct mpv_opengl_cb_context *opengl_cb_context; + void (*wakeup_cb)(void *ctx); + void *wakeup_ctx; }; struct vo_frame { |