]> git.sesse.net Git - vlc/blobdiff - modules/access/fake.c
Merge branch '1.0-bugfix'
[vlc] / modules / access / fake.c
index 1bd3214fe3ed4291c25ce4b1cb28c644138c93af..0cd8b09c1e1213b51c28e4e63d3b680fc176e9f7 100644 (file)
@@ -66,14 +66,14 @@ vlc_module_begin ()
     set_subcategory( SUBCAT_INPUT_ACCESS )
 
     add_integer( "fake-caching", DEFAULT_PTS_DELAY / 1000, NULL,
-                 CACHING_TEXT, CACHING_LONGTEXT, true );
+                 CACHING_TEXT, CACHING_LONGTEXT, true )
     add_float( "fake-fps", 25.0, NULL, FPS_TEXT, FPS_LONGTEXT, true )
     add_integer( "fake-id", 0, NULL, ID_TEXT, ID_LONGTEXT, true )
     add_integer( "fake-duration", -1, NULL, DURATION_TEXT, DURATION_LONGTEXT,
-                 true );
+                 true )
 
     add_shortcut( "fake" )
-    set_capability( "access_demux", 100 )
+    set_capability( "access_demux", 10 )
     set_callbacks( Open, Close )
 vlc_module_end ()
 
@@ -102,9 +102,9 @@ static int Open( vlc_object_t *p_this )
 
     if( *p_demux->psz_access != '\0' )
     {
-       /* if an access is provided, then it has to be "fake" */
-       if( strcmp( p_demux->psz_access, "fake" ) != 0 )
-        return VLC_EGENERIC;
+        /* if an access is provided, then it has to be "fake" */
+        if( strcmp( p_demux->psz_access, "fake" ) )
+            return VLC_EGENERIC;
 
         msg_Dbg( p_demux, "fake:// access_demux detected" );
     }
@@ -121,23 +121,15 @@ static int Open( vlc_object_t *p_this )
         vlc_fourcc_t i_codec = image_Ext2Fourcc( p_demux->psz_path );
         if( !i_codec )
             return VLC_EGENERIC;
-        char* p_codec = (char*) &i_codec;
-        msg_Dbg( p_demux, "still image detected with codec format %c%c%c%c",
-                   p_codec[0], p_codec[1], p_codec[2], p_codec[3] );
+        msg_Dbg( p_demux, "still image detected with codec format %4.4s",
+                 (const char*)&i_codec );
     }
 
     if( p_demux->psz_path && *p_demux->psz_path )
     {
-        vlc_object_t* p_input = vlc_object_find( p_demux, VLC_OBJECT_INPUT,
-                                                 FIND_PARENT );
-        if( !p_input )
-            return VLC_EGENERIC;
-
         /* set up fake-file on the fly */
-        var_Create( p_input, "fake-file", VLC_VAR_STRING );
-        var_SetString( p_input, "fake-file", p_demux->psz_path );
-
-        vlc_object_release( p_input );
+        var_Create( p_demux->p_parent, "fake-file", VLC_VAR_STRING );
+        var_SetString( p_demux->p_parent, "fake-file", p_demux->psz_path );
     }
 
     /* Set up p_demux */
@@ -222,19 +214,16 @@ static int Control( demux_t *p_demux, int i_query, va_list args )
             return VLC_SUCCESS;
 
         case DEMUX_GET_POSITION:
+            if( p_sys->i_duration <= 0 )
+                return VLC_EGENERIC;
             pf = (double*)va_arg( args, double* );
-            if( p_sys->i_duration > 0 )
-            {
-                *pf = (double)( p_sys->i_last_pts - p_sys->i_first_pts )
-                                / (double)(p_sys->i_duration);
-            }
-            else
-            {
-                *pf = 0;
-            }
+            *pf = (double)( p_sys->i_last_pts - p_sys->i_first_pts )
+                            / (double)(p_sys->i_duration);
             return VLC_SUCCESS;
 
         case DEMUX_SET_POSITION:
+            if( p_sys->i_duration <= 0 )
+                return VLC_EGENERIC;
             f = (double)va_arg( args, double );
             i64 = f * (double)p_sys->i_duration;
             p_sys->i_first_pts = p_sys->i_last_pts - i64;
@@ -243,13 +232,12 @@ static int Control( demux_t *p_demux, int i_query, va_list args )
 
         case DEMUX_GET_TIME:
             pi64 = (int64_t *)va_arg( args, int64_t * );
-            if ( p_sys->i_duration )
-                *pi64 = p_sys->i_last_pts - p_sys->i_first_pts;
-            else
-                *pi64 = p_sys->i_last_pts;
+            *pi64 = p_sys->i_last_pts - p_sys->i_first_pts;
             return VLC_SUCCESS;
 
         case DEMUX_GET_LENGTH:
+            if( p_sys->i_duration <= 0 )
+                return VLC_EGENERIC;
             pi64 = (int64_t*)va_arg( args, int64_t * );
             *pi64 = p_sys->i_duration;
             return VLC_SUCCESS;