[vlc-commits] vout: add mutex to protect the window
Rémi Denis-Courmont
git at videolan.org
Mon Aug 13 18:21:09 CEST 2018
vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Mon Aug 13 13:09:20 2018 +0300| [46f974ed151beb60b34470c93469e7c6d4d92d89] | committer: Rémi Denis-Courmont
vout: add mutex to protect the window
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=46f974ed151beb60b34470c93469e7c6d4d92d89
---
src/video_output/video_output.c | 13 +++++++++++--
src/video_output/vout_internal.h | 1 +
2 files changed, 12 insertions(+), 2 deletions(-)
diff --git a/src/video_output/video_output.c b/src/video_output/video_output.c
index 29c97fa5ad..8c71164362 100644
--- a/src/video_output/video_output.c
+++ b/src/video_output/video_output.c
@@ -152,6 +152,7 @@ static vout_thread_t *VoutCreate(vlc_object_t *object,
/* Initialize locks */
vlc_mutex_init(&vout->p->filter.lock);
vlc_mutex_init(&vout->p->spu_lock);
+ vlc_mutex_init(&vout->p->window_lock);
/* Take care of some "interface/control" related initialisations */
vout_IntfInit(vout);
@@ -279,8 +280,12 @@ void vout_Close(vout_thread_t *vout)
vout_chrono_Clean(&vout->p->render);
- if (vout->p->window != NULL)
+ vlc_mutex_lock(&vout->p->window_lock);
+ if (vout->p->window != NULL) {
vout_display_window_Delete(vout->p->window);
+ vout->p->window = NULL;
+ }
+ vlc_mutex_unlock(&vout->p->window_lock);
vlc_mutex_lock(&vout->p->spu_lock);
spu_Destroy(vout->p->spu);
@@ -299,6 +304,7 @@ static void VoutDestructor(vlc_object_t *object)
free(vout->p->splitter_name);
/* Destroy the locks */
+ vlc_mutex_destroy(&vout->p->window_lock);
vlc_mutex_destroy(&vout->p->spu_lock);
vlc_mutex_destroy(&vout->p->filter.lock);
vout_control_Clean(&vout->p->control);
@@ -643,12 +649,15 @@ static void VoutGetDisplayCfg(vout_thread_t *vout, vout_display_cfg_t *cfg)
void vout_SetDisplayWindowSize(vout_thread_t *vout,
unsigned width, unsigned height)
{
- vout_window_t *window = vout->p->window;
+ vout_window_t *window;
+ vlc_mutex_lock(&vout->p->window_lock);
+ window = vout->p->window;
if (window != NULL)
/* Request a resize of the window. If it fails, there is nothing to do.
* If it succeeds, the window will emit a resize event later. */
vout_window_SetSize(window, width, height);
+ vlc_mutex_unlock(&vout->p->window_lock);
}
/* */
diff --git a/src/video_output/vout_internal.h b/src/video_output/vout_internal.h
index 1c61629886..8eaac0dee9 100644
--- a/src/video_output/vout_internal.h
+++ b/src/video_output/vout_internal.h
@@ -80,6 +80,7 @@ struct vout_thread_sys_t
/* Video output window */
vout_window_t *window;
+ vlc_mutex_t window_lock;
/* Thread & synchronization */
vlc_thread_t thread;
More information about the vlc-commits
mailing list