]> git.sesse.net Git - vlc/commitdiff
mediacontrol_new: new API (pass argc and argv), use the new libvlc_new API
authorOlivier Aubert <olivier.aubert@liris.cnrs.fr>
Mon, 25 Sep 2006 15:52:55 +0000 (15:52 +0000)
committerOlivier Aubert <olivier.aubert@liris.cnrs.fr>
Mon, 25 Sep 2006 15:52:55 +0000 (15:52 +0000)
include/mediacontrol_internal.h
include/vlc/mediacontrol.h
src/control/mediacontrol_core.c

index 36b1f4f790ffd1fc4eea02413011ea4aac093599..a6021566e4432c6c49e2f18b285027b40719580e 100644 (file)
@@ -49,8 +49,8 @@ vlc_int64_t mediacontrol_position2microsecond(
 #define RAISE( c, m )  exception->code = c; \
                        exception->message = strdup(m);
 
-#define RAISE_NULL( c, m ) RAISE( c, m ); return NULL;
-#define RAISE_VOID( c, m ) RAISE( c, m ); return;
+#define RAISE_NULL( c, m ) { RAISE( c, m ); return NULL; }
+#define RAISE_VOID( c, m ) { RAISE( c, m ); return; }
 
 #define HANDLE_LIBVLC_EXCEPTION_VOID( e )  if( libvlc_exception_raised( e ) ) {        \
        RAISE( mediacontrol_InternalException, libvlc_exception_get_message( e )); \
index d9bd2ad18eaf0dc899a3dc02b1c381ae1fac951b..4c47b4ee96ccc938e0a306cb666b8ee734d59cca 100644 (file)
@@ -112,7 +112,7 @@ void mediacontrol_exception_free(mediacontrol_Exception *exception);
  * Core functions
  *****************************************************************************/
 mediacontrol_Instance *
-  mediacontrol_new( char **args, mediacontrol_Exception *exception );
+mediacontrol_new( int argc, char **argv, mediacontrol_Exception *exception );
 
 /* Bridge with the libvlc API */
 mediacontrol_Instance *
index a265d3a2fa9aba13af581a2f76f2d72e1d014bc4..03e62b4dd4c7904f24516497c4fdcedc4a4bee13 100644 (file)
 #    include <sys/types.h>
 #endif
 
-mediacontrol_Instance* mediacontrol_new( char** args, mediacontrol_Exception *exception )
+mediacontrol_Instance* mediacontrol_new( int argc, char** argv, mediacontrol_Exception *exception )
 {
     mediacontrol_Instance* retval;
     libvlc_exception_t ex;
-    char **ppsz_argv;
-    int i_count = 0;
-    int i_index;
-    char **p_tmp;
 
     libvlc_exception_init( &ex );
     exception=mediacontrol_exception_init( exception );
 
-    /* Copy args array */
-    if( args )
-    {
-        for ( p_tmp = args ; *p_tmp != NULL ; p_tmp++ )
-            i_count++;
-    }
-
-    ppsz_argv = malloc( ( i_count + 2 ) * sizeof( char * ) ) ;
-    if( ! ppsz_argv )
-    {
-        RAISE_NULL( mediacontrol_InternalException, "out of memory" );
-    }
-    ppsz_argv[0] = "vlc";
-    for ( i_index = 0; i_index < i_count; i_index++ )
-    {
-        ppsz_argv[i_index + 1] = strdup( args[i_index] );
-        if( ! ppsz_argv[i_index + 1] )
-        {
-            RAISE_NULL( mediacontrol_InternalException, "out of memory" );
-        }
-    }
-
-    ppsz_argv[i_count + 2] = NULL;
-
     retval = ( mediacontrol_Instance* )malloc( sizeof( mediacontrol_Instance ) );
-    if( ! retval )
-    { 
-        RAISE_NULL( mediacontrol_InternalException, "out of memory" );
-    }
+    if( !retval ) 
+        RAISE_NULL( mediacontrol_InternalException, "Out of memory" );
 
-    retval->p_instance = libvlc_new( i_count + 1, ppsz_argv, &ex );
+    retval->p_instance = libvlc_new( argc, argv, &ex );
     retval->p_playlist = retval->p_instance->p_libvlc_int->p_playlist;
     HANDLE_LIBVLC_EXCEPTION_NULL( &ex );
     return retval;  
@@ -127,7 +97,7 @@ mediacontrol_new_from_instance( libvlc_instance_t* p_instance,
   retval = ( mediacontrol_Instance* )malloc( sizeof( mediacontrol_Instance ) );
   if( ! retval )
   { 
-      RAISE_NULL( mediacontrol_InternalException, "out of memory" );
+      RAISE_NULL( mediacontrol_InternalException, "Out of memory" );
   }
   retval->p_instance = p_instance;
   retval->p_playlist = retval->p_instance->p_libvlc_int->p_playlist;