]> git.sesse.net Git - vlc/commitdiff
mediacontrol_core.c: prepend the argv[0] here, since libvlc_new no
authorOlivier Aubert <olivier.aubert@liris.cnrs.fr>
Tue, 26 Sep 2006 15:06:22 +0000 (15:06 +0000)
committerOlivier Aubert <olivier.aubert@liris.cnrs.fr>
Tue, 26 Sep 2006 15:06:22 +0000 (15:06 +0000)
longer does.

src/control/mediacontrol_core.c

index 91731ae7fcd56f029cdf6a898666801e0f35dcf6..18f780097daf721b1930b5a5ce9ea16d0e69d2bd 100644 (file)
@@ -59,6 +59,8 @@ mediacontrol_Instance* mediacontrol_new( int argc, char** argv, mediacontrol_Exc
 {
     mediacontrol_Instance* retval;
     libvlc_exception_t ex;
+    char** ppsz_argv = NULL;
+    int i_index;
 
     libvlc_exception_init( &ex );
     exception=mediacontrol_exception_init( exception );
@@ -67,7 +69,18 @@ mediacontrol_Instance* mediacontrol_new( int argc, char** argv, mediacontrol_Exc
     if( !retval ) 
         RAISE_NULL( mediacontrol_InternalException, "Out of memory" );
 
-    retval->p_instance = libvlc_new( argc, argv, &ex );
+    /* Prepend a dummy argv[0] so that users of the API do not have to  
+       do it themselves, and can simply provide the args list. */ 
+    ppsz_argv = malloc( ( argc + 2 ) * sizeof( char * ) ) ; 
+    if( ! ppsz_argv )  
+        RAISE_NULL( mediacontrol_InternalException, "Out of memory" ); 
+                
+    ppsz_argv[0] = strdup("vlc"); 
+    for ( i_index = 0; i_index < argc; i_index++ ) 
+        ppsz_argv[i_index + 1] = argv[i_index]; 
+    ppsz_argv[argc + 1] = NULL; 
+                    
+    retval->p_instance = libvlc_new( argc + 1, ppsz_argv, &ex );
     retval->p_playlist = retval->p_instance->p_libvlc_int->p_playlist;
     HANDLE_LIBVLC_EXCEPTION_NULL( &ex );
     return retval;