[vlc-devel] [PATCH 1/5] input: simplify private resource handling
Thomas Guillem
thomas at gllm.fr
Thu Jun 27 10:14:50 CEST 2019
Release() (instead of Terminate()) from the closing thread. Don't hold twice
the ref count for private resources.
This will not change anything when the resource is provided to the
input_thread_t. The Release() call will just decrement the ref count.
This will also not change anything when the input_thread_t create its own
resource. The Release() will actually terminate the resource like before, and
from the closing thread.
---
src/input/input.c | 24 +++++++++++-------------
src/input/input_internal.h | 1 -
2 files changed, 11 insertions(+), 14 deletions(-)
diff --git a/src/input/input.c b/src/input/input.c
index e8cddfb196..d4639de45c 100644
--- a/src/input/input.c
+++ b/src/input/input.c
@@ -391,15 +391,9 @@ static input_thread_t *Create( vlc_object_t *p_parent,
/* */
if( p_resource )
- {
- priv->p_resource_private = NULL;
priv->p_resource = input_resource_Hold( p_resource );
- }
else
- {
- priv->p_resource_private = input_resource_New( VLC_OBJECT( p_input ) );
- priv->p_resource = input_resource_Hold( priv->p_resource_private );
- }
+ priv->p_resource = input_resource_New( VLC_OBJECT( p_input ) );
input_resource_SetInput( priv->p_resource, p_input );
/* Init control buffer */
@@ -444,8 +438,6 @@ static void Destroy(input_thread_t *input)
if (priv->p_resource != NULL)
input_resource_Release(priv->p_resource);
- if (priv->p_resource_private != NULL)
- input_resource_Release(priv->p_resource_private);
input_item_Release(priv->p_item);
@@ -1359,8 +1351,11 @@ error:
input_resource_RequestSout( input_priv(p_input)->p_resource,
input_priv(p_input)->p_sout, NULL );
input_resource_SetInput( input_priv(p_input)->p_resource, NULL );
- if( input_priv(p_input)->p_resource_private )
- input_resource_Terminate( input_priv(p_input)->p_resource_private );
+ if( input_priv(p_input)->p_resource )
+ {
+ input_resource_Release( input_priv(p_input)->p_resource );
+ input_priv(p_input)->p_resource = NULL;
+ }
}
/* Mark them deleted */
@@ -1423,8 +1418,11 @@ static void End( input_thread_t * p_input )
input_resource_RequestSout( input_priv(p_input)->p_resource,
input_priv(p_input)->p_sout, NULL );
input_resource_SetInput( input_priv(p_input)->p_resource, NULL );
- if( input_priv(p_input)->p_resource_private )
- input_resource_Terminate( input_priv(p_input)->p_resource_private );
+ if( input_priv(p_input)->p_resource )
+ {
+ input_resource_Release( input_priv(p_input)->p_resource );
+ input_priv(p_input)->p_resource = NULL;
+ }
}
/*****************************************************************************
diff --git a/src/input/input_internal.h b/src/input/input_internal.h
index 949cff27c5..b9e27810fc 100644
--- a/src/input/input_internal.h
+++ b/src/input/input_internal.h
@@ -486,7 +486,6 @@ typedef struct input_thread_private_t
/* Resources */
input_resource_t *p_resource;
- input_resource_t *p_resource_private;
/* Stats counters */
struct input_stats *stats;
--
2.20.1
More information about the vlc-devel
mailing list