]> git.sesse.net Git - vlc/blobdiff - src/input/demux.c
Don't clutter REGISTRY on windows...
[vlc] / src / input / demux.c
index 4cd5a3330280668f5aebfb82d127ec617d423797..9aa2105cf7835307ce2d8edec31b61206cb8a342 100644 (file)
@@ -25,7 +25,7 @@
 # include "config.h"
 #endif
 
-#include <vlc/vlc.h>
+#include <vlc_common.h>
 
 #include "input_internal.h"
 
@@ -33,15 +33,17 @@ static bool SkipID3Tag( demux_t * );
 static bool SkipAPETag( demux_t *p_demux );
 
 /*****************************************************************************
- * demux2_New:
+ * demux_New:
  *  if s is NULL then load a access_demux
  *****************************************************************************/
-demux_t *__demux2_New( vlc_object_t *p_obj,
+demux_t *__demux_New( vlc_object_t *p_obj,
                        const char *psz_access, const char *psz_demux,
                        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 *__demux2_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" );
@@ -156,7 +158,7 @@ demux_t *__demux2_New( vlc_object_t *p_obj,
             SkipAPETag( p_demux );
 
         p_demux->p_module =
-            module_Need( p_demux, "demux2", psz_module,
+            module_Need( p_demux, "demux", psz_module,
                          !strcmp( psz_module, p_demux->psz_demux ) ?
                          true : false );
     }
@@ -182,9 +184,9 @@ demux_t *__demux2_New( vlc_object_t *p_obj,
 }
 
 /*****************************************************************************
- * demux2_Delete:
+ * demux_Delete:
  *****************************************************************************/
-void demux2_Delete( demux_t *p_demux )
+void demux_Delete( demux_t *p_demux )
 {
     module_Unneed( p_demux, p_demux->p_module );
     vlc_object_detach( p_demux );
@@ -197,9 +199,9 @@ void demux2_Delete( demux_t *p_demux )
 }
 
 /*****************************************************************************
- * demux2_vaControlHelper:
+ * demux_vaControlHelper:
  *****************************************************************************/
-int demux2_vaControlHelper( stream_t *s,
+int demux_vaControlHelper( stream_t *s,
                             int64_t i_start, int64_t i_end,
                             int i_bitrate, int i_align,
                             int i_query, va_list args )
@@ -219,7 +221,7 @@ int demux2_vaControlHelper( stream_t *s,
             pi64 = (int64_t*)va_arg( args, int64_t * );
             if( i_bitrate > 0 && i_end > i_start )
             {
-                *pi64 = I64C(8000000) * (i_end - i_start) / i_bitrate;
+                *pi64 = INT64_C(8000000) * (i_end - i_start) / i_bitrate;
                 return VLC_SUCCESS;
             }
             return VLC_EGENERIC;
@@ -228,7 +230,7 @@ int demux2_vaControlHelper( stream_t *s,
             pi64 = (int64_t*)va_arg( args, int64_t * );
             if( i_bitrate > 0 && i_end > i_start )
             {
-                *pi64 = I64C(8000000) * (i_tell - i_start) / i_bitrate;
+                *pi64 = INT64_C(8000000) * (i_tell - i_start) / i_bitrate;
                 return VLC_SUCCESS;
             }
             return VLC_EGENERIC;
@@ -262,7 +264,7 @@ int demux2_vaControlHelper( stream_t *s,
             i64 = (int64_t)va_arg( args, int64_t );
             if( i_bitrate > 0 && i64 >= 0 )
             {
-                int64_t i_block = i64 * i_bitrate / I64C(8000000) / i_align;
+                int64_t i_block = i64 * i_bitrate / INT64_C(8000000) / i_align;
                 if( stream_Seek( s, i_start + i_block * i_align ) )
                 {
                     return VLC_EGENERIC;
@@ -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;
@@ -337,10 +346,10 @@ stream_t *__stream_DemuxNew( vlc_object_t *p_obj, const char *psz_demux,
     p_sys->psz_name = strdup( psz_demux );
 
     /* decoder fifo */
-    if( ( p_sys->p_fifo = block_FifoNew( s ) ) == NULL )
+    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;
     }
@@ -374,7 +384,7 @@ void stream_DemuxDelete( stream_t *s )
     block_FifoPut( p_sys->p_fifo, p_empty );
     vlc_thread_join( s );
 
-    if( p_sys->p_demux ) demux2_Delete( p_sys->p_demux );
+    if( p_sys->p_demux ) demux_Delete( p_sys->p_demux );
     if( p_sys->p_block ) block_Release( p_sys->p_block );
 
     block_FifoRelease( p_sys->p_fifo );
@@ -530,7 +540,7 @@ static int DStreamThread( stream_t *s )
     demux_t *p_demux;
 
     /* Create the demuxer */
-    if( !(p_demux = demux2_New( s, "", p_sys->psz_name, "", s, p_sys->out,
+    if( !(p_demux = demux_New( s, "", p_sys->psz_name, "", s, p_sys->out,
                                false )) )
     {
         return VLC_EGENERIC;