[vlc-commits] sout: simplify sout_InputNew

Francois Cartegnie git at videolan.org
Fri Jul 7 18:05:47 CEST 2017


vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Fri Jul  7 15:51:35 2017 +0200| [5936f2895938051220369e76707ba888037c6702] | committer: Francois Cartegnie

sout: simplify sout_InputNew

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

 src/stream_output/stream_output.c | 28 +++++++++++-----------------
 1 file changed, 11 insertions(+), 17 deletions(-)

diff --git a/src/stream_output/stream_output.c b/src/stream_output/stream_output.c
index 87f3c7b794..5e4ed47594 100644
--- a/src/stream_output/stream_output.c
+++ b/src/stream_output/stream_output.c
@@ -159,13 +159,14 @@ sout_packetizer_input_t *sout_InputNew( sout_instance_t *p_sout,
     sout_packetizer_input_t *p_input;
 
     /* *** create a packetizer input *** */
-    p_input         = malloc( sizeof( sout_packetizer_input_t ) );
-    if( !p_input )  return NULL;
+    if( !p_fmt->i_codec || !(p_input = malloc(sizeof(sout_packetizer_input_t))) )
+        return NULL;
+
     p_input->p_sout = p_sout;
     p_input->p_fmt  = p_fmt;
 
-    msg_Dbg( p_sout, "adding a new sout input (sout_input: %p)",
-             (void *)p_input );
+    msg_Dbg( p_sout, "adding a new sout input for `%4.4s` (sout_input: %p)",
+             (char*) &p_fmt->i_codec, (void *)p_input );
 
     /* *** add it to the stream chain */
     vlc_mutex_lock( &p_sout->lock );
@@ -174,8 +175,10 @@ sout_packetizer_input_t *sout_InputNew( sout_instance_t *p_sout,
 
     if( p_input->id == NULL )
     {
+        msg_Warn( p_sout, "new sout input failed (sout_input: %p)",
+                 (void *)p_input );
         free( p_input );
-        return NULL;
+        p_input = NULL;
     }
 
     return( p_input );
@@ -191,12 +194,9 @@ int sout_InputDelete( sout_packetizer_input_t *p_input )
     msg_Dbg( p_sout, "removing a sout input (sout_input: %p)",
              (void *)p_input );
 
-    if( p_input->id )
-    {
-        vlc_mutex_lock( &p_sout->lock );
-        p_sout->p_stream->pf_del( p_sout->p_stream, p_input->id );
-        vlc_mutex_unlock( &p_sout->lock );
-    }
+    vlc_mutex_lock( &p_sout->lock );
+    p_sout->p_stream->pf_del( p_sout->p_stream, p_input->id );
+    vlc_mutex_unlock( &p_sout->lock );
 
     free( p_input );
 
@@ -233,12 +233,6 @@ int sout_InputSendBuffer( sout_packetizer_input_t *p_input,
     sout_instance_t     *p_sout = p_input->p_sout;
     int                 i_ret;
 
-    if( p_input->id == NULL )
-    {
-        block_Release( p_buffer );
-        return VLC_SUCCESS;
-    }
-
     vlc_mutex_lock( &p_sout->lock );
     i_ret = p_sout->p_stream->pf_send( p_sout->p_stream,
                                        p_input->id, p_buffer );



More information about the vlc-commits mailing list