diff options
author | Dudemanguy <random342@airmail.cc> | 2023-01-13 22:03:00 -0600 |
---|---|---|
committer | Dudemanguy <random342@airmail.cc> | 2023-01-13 22:23:49 -0600 |
commit | f32c5586d65e85e488e24007d24ee6d75611b756 (patch) | |
tree | 2ba49240e52d31d64a5914075810db73b95e627a /video/out | |
parent | 73581d8fe68054103e2913bbac5f1629b1b0ce0c (diff) | |
download | mpv-f32c5586d65e85e488e24007d24ee6d75611b756.tar.bz2 mpv-f32c5586d65e85e488e24007d24ee6d75611b756.tar.xz |
Revert "wayland: dispatch and wait for compositor events in uninit"
This ended up being a bad idea. The problem is that it introduces
ordering when destroying events (something we weren't worried about
before) and Lynne pointed out a problem with the callback not also being
destroyed before the surface in IRC. Just undo this and go with a
different approach (next commit). P.S. the wayland_dispatch_events name
change is kept though because I like that better.
This reverts commit aa8ddfcdf30c4ffb38f3ec5d6663bbabf0b7b4df.
Diffstat (limited to 'video/out')
-rw-r--r-- | video/out/wayland_common.c | 48 | ||||
-rw-r--r-- | video/out/wayland_common.h | 1 |
2 files changed, 27 insertions, 22 deletions
diff --git a/video/out/wayland_common.c b/video/out/wayland_common.c index 41f6ade83a..e1712389c7 100644 --- a/video/out/wayland_common.c +++ b/video/out/wayland_common.c @@ -1022,8 +1022,13 @@ static void feedback_presented(void *data, struct wp_presentation_feedback *fbac { struct vo_wayland_state *wl = data; - if (fback) + // NULL is needed to prevent a dangling pointer since presentation_feedback + // is created in the frame_callback and not in any of the actual presentation + // events. + if (fback) { wp_presentation_feedback_destroy(fback); + wl->feedback = NULL; + } wl->refresh_interval = (int64_t)refresh_nsec / 1000; @@ -1044,8 +1049,13 @@ static void feedback_presented(void *data, struct wp_presentation_feedback *fbac static void feedback_discarded(void *data, struct wp_presentation_feedback *fback) { - if (fback) + struct vo_wayland_state *wl = data; + + // Same logic in feedback_presented applies here. + if (fback) { wp_presentation_feedback_destroy(fback); + wl->feedback = NULL; + } } static const struct wp_presentation_feedback_listener feedback_listener = { @@ -1063,15 +1073,12 @@ static void frame_callback(void *data, struct wl_callback *callback, uint32_t ti if (callback) wl_callback_destroy(callback); - if (!wl->surface) - return; - wl->frame_callback = wl_surface_frame(wl->surface); wl_callback_add_listener(wl->frame_callback, &frame_listener, wl); if (wl->use_present) { - struct wp_presentation_feedback *fback = wp_presentation_feedback(wl->presentation, wl->surface); - wp_presentation_feedback_add_listener(fback, &feedback_listener, wl); + wl->feedback = wp_presentation_feedback(wl->presentation, wl->surface); + wp_presentation_feedback_add_listener(wl->feedback, &feedback_listener, wl); } wl->frame_wait = false; @@ -2124,21 +2131,6 @@ void vo_wayland_uninit(struct vo *vo) if (!wl) return; - // Destroy wl_surface and its roles first - // to trigger any discard events. - if (wl->xdg_toplevel) - xdg_toplevel_destroy(wl->xdg_toplevel); - - if (wl->xdg_surface) - xdg_surface_destroy(wl->xdg_surface); - - if (wl->surface) - wl_surface_destroy(wl->surface); - - // Process any final events. - if (wl->display && wl_display_roundtrip(wl->display)) - wayland_dispatch_events(wl, 1, 50); //TODO: make timeout 0 - mp_input_put_key(wl->vo->input_ctx, MP_INPUT_RELEASE_ALL); if (wl->compositor) @@ -2173,6 +2165,9 @@ void vo_wayland_uninit(struct vo *vo) if (wl->dnd_offer) wl_data_offer_destroy(wl->dnd_offer); + if (wl->feedback) + wp_presentation_feedback_destroy(wl->feedback); + if (wl->frame_callback) wl_callback_destroy(wl->frame_callback); @@ -2222,6 +2217,9 @@ void vo_wayland_uninit(struct vo *vo) wp_single_pixel_buffer_manager_v1_destroy(wl->single_pixel_manager); #endif + if (wl->surface) + wl_surface_destroy(wl->surface); + if (wl->video_surface) wl_surface_destroy(wl->video_surface); @@ -2234,9 +2232,15 @@ void vo_wayland_uninit(struct vo *vo) if (wl->xdg_decoration_manager) zxdg_decoration_manager_v1_destroy(wl->xdg_decoration_manager); + if (wl->xdg_toplevel) + xdg_toplevel_destroy(wl->xdg_toplevel); + if (wl->xdg_toplevel_decoration) zxdg_toplevel_decoration_v1_destroy(wl->xdg_toplevel_decoration); + if (wl->xdg_surface) + xdg_surface_destroy(wl->xdg_surface); + if (wl->xkb_context) xkb_context_unref(wl->xkb_context); diff --git a/video/out/wayland_common.h b/video/out/wayland_common.h index 94a8f2c96a..78fbc6158b 100644 --- a/video/out/wayland_common.h +++ b/video/out/wayland_common.h @@ -97,6 +97,7 @@ struct vo_wayland_state { /* presentation-time */ struct wp_presentation *presentation; + struct wp_presentation_feedback *feedback; struct mp_present *present; int64_t refresh_interval; bool use_present; |