[vlc-commits] stream: merge stream_CommonDelete() and stream_Delete()

Rémi Denis-Courmont git at videolan.org
Tue Aug 25 20:33:17 CEST 2015


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Sun Jul 26 11:55:25 2015 +0300| [33eb0cd1df39303f07168c9231eaea2f9cfd24cf] | committer: Rémi Denis-Courmont

stream: merge stream_CommonDelete() and stream_Delete()

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

 src/input/stream.c        |   26 ++++++++++++++------------
 src/input/stream.h        |    1 -
 src/input/stream_access.c |    3 +--
 src/input/stream_demux.c  |    8 +++-----
 src/input/stream_filter.c |    6 ++----
 src/input/stream_memory.c |    4 +---
 6 files changed, 21 insertions(+), 27 deletions(-)

diff --git a/src/input/stream.c b/src/input/stream.c
index a9d5ac2..beb8817 100644
--- a/src/input/stream.c
+++ b/src/input/stream.c
@@ -64,7 +64,15 @@ stream_t *stream_CommonNew(vlc_object_t *parent)
 
     stream_t *s = &priv->stream;
 
+    s->b_error = false;
+    s->p_module = NULL;
     s->psz_url = NULL;
+    s->p_source = NULL;
+    s->pf_read = NULL;
+    s->pf_readdir = NULL;
+    s->pf_control = NULL;
+    s->pf_destroy = NULL;
+    s->p_input = NULL;
     priv->peek = NULL;
 
     /* UTF16 and UTF32 text file conversion */
@@ -76,20 +84,22 @@ stream_t *stream_CommonNew(vlc_object_t *parent)
 }
 
 /**
- * Destroys a VLC stream object
+ * Destroy a stream
  */
-void stream_CommonDelete( stream_t *s )
+void stream_Delete(stream_t *s)
 {
     stream_priv_t *priv = (stream_priv_t *)s;
 
     if (priv->text.conv != (vlc_iconv_t)(-1))
         vlc_iconv_close(priv->text.conv);
-
     if (priv->peek != NULL)
         block_Release(priv->peek);
 
+    if (s->pf_destroy != NULL)
+        s->pf_destroy(s);
+
     free(s->psz_url);
-    vlc_object_release( s );
+    vlc_object_release(s);
 }
 
 #undef stream_UrlNew
@@ -513,14 +523,6 @@ int stream_vaControl(stream_t *s, int cmd, va_list args)
     return s->pf_control(s, cmd, args);
 }
 
-/**
- * Destroy a stream
- */
-void stream_Delete( stream_t *s )
-{
-    s->pf_destroy( s );
-}
-
 int stream_Control( stream_t *s, int i_query, ... )
 {
     va_list args;
diff --git a/src/input/stream.h b/src/input/stream.h
index 6588337..d886f21 100644
--- a/src/input/stream.h
+++ b/src/input/stream.h
@@ -30,7 +30,6 @@
 
 /* */
 stream_t *stream_CommonNew( vlc_object_t * );
-void stream_CommonDelete( stream_t * );
 
 /**
  * This function creates a stream_t with an access_t back-end.
diff --git a/src/input/stream_access.c b/src/input/stream_access.c
index 4cba97b..7a6b97b 100644
--- a/src/input/stream_access.c
+++ b/src/input/stream_access.c
@@ -230,7 +230,6 @@ static void AStreamDestroy(stream_t *s)
 {
     stream_sys_t *sys = s->p_sys;
 
-    stream_CommonDelete(s);
     if (sys->block != NULL)
         block_Release(sys->block);
     vlc_access_Delete(sys->access);
@@ -269,6 +268,6 @@ stream_t *stream_AccessNew(vlc_object_t *parent, input_thread_t *input,
     return s;
 error:
     free(sys);
-    stream_CommonDelete(s);
+    stream_Delete(s);
     return NULL;
 }
diff --git a/src/input/stream_demux.c b/src/input/stream_demux.c
index 22ee8ff..0d9a406 100644
--- a/src/input/stream_demux.c
+++ b/src/input/stream_demux.c
@@ -81,8 +81,7 @@ stream_t *stream_DemuxNew( demux_t *p_demux, const char *psz_demux, es_out_t *ou
     s->p_sys = p_sys = malloc( sizeof( *p_sys) );
     if( !s->p_sys )
     {
-        free( p_sys );
-        stream_CommonDelete( s );
+        stream_Delete( s );
         return NULL;
     }
 
@@ -97,7 +96,7 @@ stream_t *stream_DemuxNew( demux_t *p_demux, const char *psz_demux, es_out_t *ou
     /* decoder fifo */
     if( ( p_sys->p_fifo = block_FifoNew() ) == NULL )
     {
-        stream_CommonDelete( s );
+        stream_Delete( s );
         free( p_sys->psz_name );
         free( p_sys );
         return NULL;
@@ -110,7 +109,7 @@ stream_t *stream_DemuxNew( demux_t *p_demux, const char *psz_demux, es_out_t *ou
     {
         vlc_mutex_destroy( &p_sys->lock );
         block_FifoRelease( p_sys->p_fifo );
-        stream_CommonDelete( s );
+        stream_Delete( s );
         free( p_sys->psz_name );
         free( p_sys );
         return NULL;
@@ -169,7 +168,6 @@ static void DStreamDelete( stream_t *s )
     block_FifoRelease( p_sys->p_fifo );
     free( p_sys->psz_name );
     free( p_sys );
-    stream_CommonDelete( s );
 }
 
 
diff --git a/src/input/stream_filter.c b/src/input/stream_filter.c
index 4bd9854..0027c9f 100644
--- a/src/input/stream_filter.c
+++ b/src/input/stream_filter.c
@@ -53,7 +53,7 @@ stream_t *stream_FilterNew( stream_t *p_source,
         s->psz_url = strdup( p_source->psz_url );
         if( unlikely(s->psz_url == NULL) )
         {
-            stream_CommonDelete( s );
+            stream_Delete( s );
             return NULL;
         }
     }
@@ -64,7 +64,7 @@ stream_t *stream_FilterNew( stream_t *p_source,
 
     if( !s->p_module )
     {
-        stream_CommonDelete( s );
+        stream_Delete( s );
         return NULL;
     }
 
@@ -118,8 +118,6 @@ static void StreamDelete( stream_t *s )
 
     if( s->p_source )
         stream_Delete( s->p_source );
-
-    stream_CommonDelete( s );
 }
 
 input_item_t *stream_FilterDefaultReadDir( stream_t *s )
diff --git a/src/input/stream_memory.c b/src/input/stream_memory.c
index 77d8937..789c7e1 100644
--- a/src/input/stream_memory.c
+++ b/src/input/stream_memory.c
@@ -62,8 +62,7 @@ stream_t *stream_MemoryNew( vlc_object_t *p_this, uint8_t *p_buffer,
     s->p_sys = p_sys = malloc( sizeof( stream_sys_t ) );
     if( !s->p_sys )
     {
-        stream_CommonDelete( s );
-        free( p_sys );
+        stream_Delete( s );
         return NULL;
     }
     p_sys->i_pos = 0;
@@ -83,7 +82,6 @@ static void Delete( stream_t *s )
 {
     if( !s->p_sys->i_preserve_memory ) free( s->p_sys->p_buffer );
     free( s->p_sys );
-    stream_CommonDelete( s );
 }
 
 /****************************************************************************



More information about the vlc-commits mailing list