[vlc-commits] input: always keep a valid master source

Thomas Guillem git at videolan.org
Fri Feb 28 20:46:05 CET 2020


vlc | branch: master | Thomas Guillem <thomas at gllm.fr> | Thu Feb 27 18:17:19 2020 +0100| [941f28fb4ba26f86b5a3b2a075d7bdc57c873fe7] | committer: Thomas Guillem

input: always keep a valid master source

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=941f28fb4ba26f86b5a3b2a075d7bdc57c873fe7
---

 src/input/input.c | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/src/input/input.c b/src/input/input.c
index dc129174b3..ff83b6caec 100644
--- a/src/input/input.c
+++ b/src/input/input.c
@@ -270,6 +270,13 @@ static input_thread_t *Create( vlc_object_t *p_parent,
     if( unlikely(priv == NULL) )
         return NULL;
 
+    priv->master = InputSourceNew();
+    if( !priv->master )
+    {
+        free( priv );
+        return NULL;
+    }
+
     input_thread_t *p_input = &priv->input;
 
     char * psz_name = input_item_GetName( p_item );
@@ -328,7 +335,6 @@ static input_thread_t *Create( vlc_object_t *p_parent,
     priv->p_item = p_item;
 
     /* Init Input fields */
-    priv->master = NULL;
     vlc_mutex_lock( &p_item->lock );
 
     if( !p_item->p_stats )
@@ -432,6 +438,7 @@ static void Destroy(input_thread_t *input)
     if (priv->p_resource != NULL)
         input_resource_Release(priv->p_resource);
 
+    input_source_Release(priv->master);
     input_item_Release(priv->p_item);
 
     if (priv->stats != NULL)
@@ -1269,7 +1276,7 @@ static int Init( input_thread_t * p_input )
         goto error;
 
     /* */
-    priv->master = master = InputSourceNew();
+    master = priv->master;
     if( master == NULL )
         goto error;
     int ret = InputSourceInit( master, p_input, priv->p_item->psz_uri,
@@ -1277,7 +1284,6 @@ static int Init( input_thread_t * p_input )
     if( ret != VLC_SUCCESS )
     {
         InputSourceDestroy( master );
-        input_source_Release( master );
         goto error;
     }
 
@@ -1394,7 +1400,6 @@ static void End( input_thread_t * p_input )
 
     /* Clean up master */
     InputSourceDestroy( priv->master );
-    input_source_Release( priv->master );
     priv->i_title_offset = 0;
     priv->i_seekpoint_offset = 0;
 



More information about the vlc-commits mailing list