[vlc-commits] resource: split RequestVout in GetVout and PutVout
Rémi Denis-Courmont
git at videolan.org
Fri Jan 18 22:12:59 CET 2019
vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Fri Jan 18 21:50:19 2019 +0200| [861c13e75ca97001b52abde23d8c8f7c32c33592] | committer: Rémi Denis-Courmont
resource: split RequestVout in GetVout and PutVout
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=861c13e75ca97001b52abde23d8c8f7c32c33592
---
src/input/decoder.c | 5 ++---
src/input/resource.c | 36 +++++++++++++++++++++---------------
src/input/resource.h | 8 +++-----
3 files changed, 26 insertions(+), 23 deletions(-)
diff --git a/src/input/decoder.c b/src/input/decoder.c
index 312799289c..1f5baf4c75 100644
--- a/src/input/decoder.c
+++ b/src/input/decoder.c
@@ -567,7 +567,7 @@ static int vout_update_format( decoder_t *p_dec )
dpb_size = 2;
break;
}
- p_vout = input_resource_RequestVout( p_owner->p_resource,
+ p_vout = input_resource_GetVout( p_owner->p_resource,
&(vout_configuration_t) {
.vout = p_vout, .fmt = &fmt,
.dpb_size = dpb_size + p_dec->i_extra_picture_buffers + 1,
@@ -2015,8 +2015,7 @@ static void DeleteDecoder( decoder_t * p_dec )
* thread */
vout_Cancel( p_owner->p_vout, false );
- input_resource_RequestVout( p_owner->p_resource,
- &(vout_configuration_t) { .vout = p_owner->p_vout } );
+ input_resource_PutVout( p_owner->p_resource, p_owner->p_vout );
}
break;
case SPU_ES:
diff --git a/src/input/resource.c b/src/input/resource.c
index 16d58c90f1..bafa7582b2 100644
--- a/src/input/resource.c
+++ b/src/input/resource.c
@@ -369,15 +369,15 @@ void input_resource_SetInput( input_resource_t *p_resource, input_thread_t *p_in
vlc_mutex_unlock( &p_resource->lock );
}
-vout_thread_t *input_resource_RequestVout( input_resource_t *p_resource,
- const vout_configuration_t *cfg )
+vout_thread_t *input_resource_GetVout(input_resource_t *p_resource,
+ const vout_configuration_t *cfg)
{
vout_thread_t *vout;
assert(cfg != NULL);
+ assert(cfg->fmt != NULL);
vlc_mutex_lock( &p_resource->lock );
- if (cfg->fmt != NULL) {
vout_configuration_t cfg_buf;
if (cfg->vout == NULL && p_resource->p_vout_free != NULL) {
@@ -416,11 +416,19 @@ vout_thread_t *input_resource_RequestVout( input_resource_t *p_resource,
.vout = vout,
});
}
- } else {
- assert(cfg->vout != NULL);
+
+ vlc_mutex_unlock( &p_resource->lock );
+ return vout;
+}
+
+void input_resource_PutVout(input_resource_t *p_resource,
+ vout_thread_t *vout)
+{
+ assert(vout != NULL);
+ vlc_mutex_lock( &p_resource->lock );
vlc_mutex_lock(&p_resource->lock_hold);
- TAB_REMOVE(p_resource->i_vout, p_resource->pp_vout, cfg->vout);
+ TAB_REMOVE(p_resource->i_vout, p_resource->pp_vout, vout);
const int active_vouts = p_resource->i_vout;
vlc_mutex_unlock(&p_resource->lock_hold);
@@ -429,25 +437,23 @@ vout_thread_t *input_resource_RequestVout( input_resource_t *p_resource,
input_SendEventVout(p_resource->p_input,
&(struct vlc_input_event_vout) {
.action = VLC_INPUT_EVENT_VOUT_DELETED,
- .vout = cfg->vout,
+ .vout = vout,
});
if (p_resource->p_vout_free != NULL || active_vouts > 0) {
msg_Dbg(p_resource->p_parent, "destroying vout (already one saved or active)");
- vout_CloseAndRelease(cfg->vout);
+ vout_CloseAndRelease(vout);
} else {
+ vout_configuration_t cfg = { .vout = vout };
+
msg_Dbg(p_resource->p_parent, "saving a free vout");
- vout_FlushAll(cfg->vout);
- vout_FlushSubpictureChannel(cfg->vout, -1);
+ vout_FlushAll(vout);
+ vout_FlushSubpictureChannel(vout, -1);
- p_resource->p_vout_free = vout_Request(p_resource->p_parent, cfg,
+ p_resource->p_vout_free = vout_Request(p_resource->p_parent, &cfg,
NULL);
}
- vout = NULL;
- }
vlc_mutex_unlock( &p_resource->lock );
-
- return vout;
}
vout_thread_t *input_resource_HoldVout( input_resource_t *p_resource )
diff --git a/src/input/resource.h b/src/input/resource.h
index e695694950..0bcd7160fb 100644
--- a/src/input/resource.h
+++ b/src/input/resource.h
@@ -37,11 +37,9 @@ void input_resource_SetInput( input_resource_t *, input_thread_t * );
*/
sout_instance_t *input_resource_RequestSout( input_resource_t *, sout_instance_t *, const char *psz_sout );
-/**
- * This function handles vout request.
- */
-vout_thread_t *input_resource_RequestVout( input_resource_t *,
- const vout_configuration_t * );
+vout_thread_t *input_resource_GetVout(input_resource_t *,
+ const vout_configuration_t *);
+void input_resource_PutVout(input_resource_t *, vout_thread_t *);
/**
* This function returns one of the current vout if any.
More information about the vlc-commits
mailing list