[vlc-devel] [PATCH V2 04/17] resource: reduce lock scope when starting the vout
Thomas Guillem
thomas at gllm.fr
Tue Apr 16 16:25:14 CEST 2019
vout_Request() is now called without lock. The vout creation and array
operations is done previously with the lock held.
---
src/input/resource.c | 36 +++++++++++++++++++++++-------------
1 file changed, 23 insertions(+), 13 deletions(-)
diff --git a/src/input/resource.c b/src/input/resource.c
index 6751950ef3..6db68a6835 100644
--- a/src/input/resource.c
+++ b/src/input/resource.c
@@ -334,17 +334,29 @@ vout_thread_t *input_resource_GetVout(input_resource_t *p_resource,
if (cfg_buf.vout == NULL) {
cfg_buf.vout = vout = vout_Create(p_resource->p_parent);
if (vout == NULL)
- goto out;
+ {
+ vlc_mutex_unlock( &p_resource->lock );
+ return NULL;
+ }
} else
msg_Dbg(p_resource->p_parent, "trying to reuse free vout");
- } else if (cfg->vout != NULL) {
- assert(cfg->vout != p_resource->p_vout_free);
- TAB_REMOVE(p_resource->i_vout, p_resource->pp_vout, cfg->vout);
+ TAB_APPEND(p_resource->i_vout, p_resource->pp_vout, cfg->vout);
+ } else {
+#ifndef NDEBUG
+ assert(cfg->vout != NULL && cfg->vout != p_resource->p_vout_free);
+ int index;
+ TAB_FIND(p_resource->i_vout, p_resource->pp_vout, cfg->vout, index);
+ assert(index >= 0);
+#endif
}
- if (vout_Request(cfg, p_resource->p_input)) {
- vlc_mutex_unlock(&p_resource->lock);
+ input_thread_t *input =
+ p_resource->p_input ? input_Hold( p_resource->p_input ) : NULL;
+
+ vlc_mutex_unlock( &p_resource->lock );
+
+ if (vout_Request(cfg, input)) {
input_resource_PutVout(p_resource, cfg->vout);
return NULL;
}
@@ -353,14 +365,12 @@ vout_thread_t *input_resource_GetVout(input_resource_t *p_resource,
DisplayVoutTitle(p_resource, vout);
/* Send original viewpoint to the input in order to update other ESes */
- if (p_resource->p_input != NULL)
- input_Control(p_resource->p_input, INPUT_SET_INITIAL_VIEWPOINT,
- &cfg->fmt->pose);
-
- TAB_APPEND(p_resource->i_vout, p_resource->pp_vout, vout);
+ if (input != NULL)
+ {
+ input_Control(input, INPUT_SET_INITIAL_VIEWPOINT, &cfg->fmt->pose);
+ input_Release(input);
+ }
-out:
- vlc_mutex_unlock( &p_resource->lock );
return vout;
}
--
2.20.1
More information about the vlc-devel
mailing list