]> git.sesse.net Git - vlc/blobdiff - modules/misc/dummy/input.c
Replaced a certain amount of vlc_object_find by pl_Yield
[vlc] / modules / misc / dummy / input.c
index 6d6da6b2dc00007f2e57caebddca757684c85721..64ba12dde34d2412b8dee6be5c09de8908b64f8d 100644 (file)
 /*****************************************************************************
  * Preamble
  *****************************************************************************/
-#include <stdlib.h>
-#include <string.h>
 
-#include <vlc/vlc.h>
-#include <vlc/intf.h>
-#include <vlc/input.h>
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+#include <vlc_common.h>
+#include <vlc_interface.h>
+#include <vlc_access.h>
+#include <vlc_demux.h>
+#include <vlc_playlist.h>
+
+#include "dummy.h"
 
 /*****************************************************************************
  * Access functions.
  *****************************************************************************/
 static int AccessRead( access_t *p_access, uint8_t *p, int i_size )
 {
+    VLC_UNUSED(p_access);
     memset( p, 0, i_size );
     return i_size;
 }
 static int AccessControl( access_t *p_access, int i_query, va_list args )
 {
-    vlc_bool_t   *pb_bool;
+    bool   *pb_bool;
     int          *pi_int;
     int64_t      *pi_64;
 
@@ -52,8 +59,8 @@ static int AccessControl( access_t *p_access, int i_query, va_list args )
         case ACCESS_CAN_FASTSEEK:
         case ACCESS_CAN_PAUSE:
         case ACCESS_CAN_CONTROL_PACE:
-            pb_bool = (vlc_bool_t*)va_arg( args, vlc_bool_t* );
-            *pb_bool = VLC_FALSE;
+            pb_bool = (bool*)va_arg( args, bool* );
+            *pb_bool = false;
             break;
 
         /* */
@@ -82,7 +89,7 @@ static int AccessControl( access_t *p_access, int i_query, va_list args )
     return VLC_SUCCESS;
 }
 
-int E_(OpenAccess)( vlc_object_t *p_this )
+int OpenAccess( vlc_object_t *p_this )
 {
     access_t *p_access = (access_t*)p_this;
 
@@ -94,12 +101,13 @@ int E_(OpenAccess)( vlc_object_t *p_this )
     p_access->info.i_update = 0;
     p_access->info.i_size = 0;
     p_access->info.i_pos = 0;
-    p_access->info.b_eof = VLC_FALSE;
+    p_access->info.b_eof = false;
     p_access->info.i_title = 0;
     p_access->info.i_seekpoint = 0;
     p_access->p_sys = NULL;
 
     /* Force dummy demux plug-in */
+    free( p_access->psz_demux );
     p_access->psz_demux = strdup( "vlc" );
 
     return VLC_SUCCESS;
@@ -116,7 +124,7 @@ struct demux_sys_t
 
     /* Used for the pause command */
     mtime_t expiration;
-    
     /* The command to run */
     char* psz_command;
 };
@@ -134,7 +142,7 @@ static int DemuxControl( demux_t *, int, va_list );
 /*****************************************************************************
  * OpenDemux: initialize the target, ie. parse the command
  *****************************************************************************/
-int E_(OpenDemux) ( vlc_object_t *p_this )
+int OpenDemux ( vlc_object_t *p_this )
 {
     demux_t *p_demux = (demux_t*)p_this;
     char * psz_name = p_demux->psz_path;
@@ -172,7 +180,7 @@ int E_(OpenDemux) ( vlc_object_t *p_this )
         p_sys->expiration = mdate() + (mtime_t)i_arg * (mtime_t)1000000;
         return VLC_SUCCESS;
     }
-    
     msg_Err( p_demux, "unknown command `%s'", psz_name );
 
     free( p_sys );
@@ -182,7 +190,7 @@ int E_(OpenDemux) ( vlc_object_t *p_this )
 /*****************************************************************************
  * CloseDemux: initialize the target, ie. parse the command
  *****************************************************************************/
-void E_(CloseDemux) ( vlc_object_t *p_this )
+void CloseDemux ( vlc_object_t *p_this )
 {
     demux_t *p_demux = (demux_t*)p_this;
 
@@ -196,33 +204,28 @@ static int Demux( demux_t *p_demux )
 {
     demux_sys_t *p_sys = p_demux->p_sys;
     playlist_t *p_playlist;
-    vlc_bool_t b_eof = VLC_FALSE;
-
-    p_playlist = vlc_object_find( p_demux, VLC_OBJECT_PLAYLIST, FIND_PARENT );
+    bool b_eof = false;
 
-    if( p_playlist == NULL )
-    {
-        msg_Err( p_demux, "we are not attached to a playlist" );
-        return -1;
-    }
+    p_playlist = pl_Yield( p_demux );
 
     switch( p_sys->i_command )
     {
         case COMMAND_QUIT:
-            b_eof = p_demux->p_libvlc->b_die = VLC_TRUE;
+            b_eof = true;
+            vlc_object_kill( p_demux->p_libvlc );
             break;
 
         case COMMAND_PAUSE:
             if( mdate() >= p_sys->expiration )
-                b_eof = VLC_TRUE;
+                b_eof = true;
             else
                 msleep( 10000 );
             break;
-        
         case COMMAND_NOP:
         default:
-            b_eof = VLC_TRUE;
-            break;       
+            b_eof = true;
+            break;
     }
 
     vlc_object_release( p_playlist );
@@ -231,7 +234,7 @@ static int Demux( demux_t *p_demux )
 
 static int DemuxControl( demux_t *p_demux, int i_query, va_list args )
 {
-    return demux2_vaControlHelper( p_demux->s,
+    return demux_vaControlHelper( p_demux->s,
                                    0, 0, 0, 1,
                                    i_query, args );
 }