From 2c05fe2a13f4860a541ec14aec5536837502f463 Mon Sep 17 00:00:00 2001 From: Alexandre Janniaux Date: Mon, 1 Nov 2021 14:28:38 +0900 Subject: [PATCH] vout: use vout_DisplayStarted to check started state vout_Stop() is stopping the display, but it wasn't accounted the same way and a decoder video format update could actually try to stop the display a second time. --- include/vlc_vout.h | 1 + src/input/resource.c | 6 +++--- src/video_output/video_output.c | 8 ++++++++ 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/include/vlc_vout.h b/include/vlc_vout.h index b94502cc4f..8d513ea186 100644 --- a/include/vlc_vout.h +++ b/include/vlc_vout.h @@ -126,6 +126,7 @@ vout_CaptionsToDisplay(vout_thread_t *vout, const void *p_cc, size_t i_cc) * \param vout the vout to close */ VLC_API void vout_Close(vout_thread_t *vout); +VLC_API bool vout_DisplayStarted(vout_thread_t *vout); /** * This function will handle a snapshot request. diff --git a/src/input/resource.c b/src/input/resource.c index 3640029187..ff96e9a5f0 100644 --- a/src/input/resource.c +++ b/src/input/resource.c @@ -370,9 +370,9 @@ static void input_resource_PutVoutLocked(input_resource_t *p_resource, assert(vout_rsc != NULL); if (has_stopped != NULL) - *has_stopped = vout_rsc->started; + *has_stopped = vout_DisplayStarted(vout_rsc->vout); - if (vout_rsc->started) + if (vout_DisplayStarted(vout_rsc->vout)) { vout_StopDisplay(vout_rsc->vout); vout_rsc->started = false; @@ -500,7 +500,7 @@ vout_thread_t *input_resource_RequestVout(input_resource_t *p_resource, return dcfg.vout; } - if (vout_rsc->started) + if (vout_DisplayStarted(dcfg.vout)) { assert(cfg->vout != NULL); int ret = vout_ChangeSource(dcfg.vout, dcfg.fmt); diff --git a/src/video_output/video_output.c b/src/video_output/video_output.c index 93f806168a..6ffb2dae72 100644 --- a/src/video_output/video_output.c +++ b/src/video_output/video_output.c @@ -2351,6 +2351,14 @@ static void vout_DisableWindow(vout_thread_sys_t *sys) vlc_mutex_unlock(&sys->window_lock); } +bool vout_DisplayStarted(vout_thread_t *vout) +{ + vout_thread_sys_t *sys = VOUT_THREAD_TO_SYS(vout); + assert(!sys->dummy); + + return sys->display != NULL; +} + void vout_Stop(vout_thread_t *vout) { vout_thread_sys_t *sys = VOUT_THREAD_TO_SYS(vout);