]> git.sesse.net Git - vlc/blobdiff - src/input/demux.c
Fix threaded function declaration.
[vlc] / src / input / demux.c
index 8b17db8c6f189918f5482becdb10760e22e9a6d0..8b571fad6a0fa7443bba0defc2f8f184c7b08540 100644 (file)
@@ -25,7 +25,7 @@
 # include "config.h"
 #endif
 
-#include <vlc/vlc.h>
+#include <vlc_common.h>
 
 #include "input_internal.h"
 
@@ -41,7 +41,9 @@ demux_t *__demux_New( vlc_object_t *p_obj,
                        const char *psz_path,
                        stream_t *s, es_out_t *out, bool b_quick )
 {
-    demux_t *p_demux = vlc_object_create( p_obj, VLC_OBJECT_DEMUX );
+    static const char typename[] = "demux";
+    demux_t *p_demux = vlc_custom_create( p_obj, sizeof( *p_demux ),
+                                          VLC_OBJECT_GENERIC, typename );
     const char *psz_module;
 
     if( p_demux == NULL ) return NULL;
@@ -52,7 +54,7 @@ demux_t *__demux_New( vlc_object_t *p_obj,
     p_demux->psz_path   = strdup( psz_path );
 
     /* Take into account "demux" to be able to do :demux=dump */
-    if( *p_demux->psz_demux == '\0' )
+    if( p_demux->psz_demux && *p_demux->psz_demux == '\0' )
     {
         free( p_demux->psz_demux );
         p_demux->psz_demux = var_GetNonEmptyString( p_obj, "demux" );
@@ -307,7 +309,7 @@ typedef struct
 static int DStreamRead   ( stream_t *, void *p_read, int i_read );
 static int DStreamPeek   ( stream_t *, const uint8_t **pp_peek, int i_peek );
 static int DStreamControl( stream_t *, int i_query, va_list );
-static int DStreamThread ( stream_t * );
+static void* DStreamThread ( vlc_object_t * );
 
 
 stream_t *__stream_DemuxNew( vlc_object_t *p_obj, const char *psz_demux,
@@ -320,6 +322,8 @@ stream_t *__stream_DemuxNew( vlc_object_t *p_obj, const char *psz_demux,
     if( psz_demux == NULL || *psz_demux == '\0' ) return NULL;
 
     s = vlc_stream_create( p_obj );
+    if( s == NULL )
+        return NULL;
     s->pf_read   = DStreamRead;
     s->pf_peek   = DStreamPeek;
     s->pf_control= DStreamControl;
@@ -328,6 +332,11 @@ stream_t *__stream_DemuxNew( vlc_object_t *p_obj, const char *psz_demux,
     s->b_little_endian = false;
 
     s->p_sys = malloc( sizeof( d_stream_sys_t) );
+    if( s->p_sys == NULL )
+    {
+        vlc_object_release( s );
+        return NULL;
+    }
     p_sys = (d_stream_sys_t*)s->p_sys;
 
     p_sys->i_pos = 0;
@@ -339,8 +348,8 @@ stream_t *__stream_DemuxNew( vlc_object_t *p_obj, const char *psz_demux,
     /* decoder fifo */
     if( ( p_sys->p_fifo = block_FifoNew() ) == NULL )
     {
-        msg_Err( s, "out of memory" );
         vlc_object_release( s );
+        free( p_sys->psz_name );
         free( p_sys );
         return NULL;
     }
@@ -349,6 +358,7 @@ stream_t *__stream_DemuxNew( vlc_object_t *p_obj, const char *psz_demux,
                            VLC_THREAD_PRIORITY_INPUT, false ) )
     {
         vlc_object_release( s );
+        free( p_sys->psz_name );
         free( p_sys );
         return NULL;
     }
@@ -524,8 +534,9 @@ static int DStreamControl( stream_t *s, int i_query, va_list args )
     }
 }
 
-static int DStreamThread( stream_t *s )
+static void* DStreamThread( vlc_object_t* p_this )
 {
+    stream_t *s = (stream_t *)p_this;
     d_stream_sys_t *p_sys = (d_stream_sys_t*)s->p_sys;
     demux_t *p_demux;
 
@@ -533,7 +544,7 @@ static int DStreamThread( stream_t *s )
     if( !(p_demux = demux_New( s, "", p_sys->psz_name, "", s, p_sys->out,
                                false )) )
     {
-        return VLC_EGENERIC;
+        return NULL;
     }
 
     p_sys->p_demux = p_demux;
@@ -545,7 +556,7 @@ static int DStreamThread( stream_t *s )
     }
 
     vlc_object_kill( p_demux );
-    return VLC_SUCCESS;
+    return NULL;
 }
 
 /****************************************************************************