]> git.sesse.net Git - vlc/commitdiff
vlc using libvlc
authorRémi Denis-Courmont <rem@videolan.org>
Thu, 15 May 2008 17:11:41 +0000 (20:11 +0300)
committerRémi Denis-Courmont <rem@videolan.org>
Thu, 15 May 2008 18:09:08 +0000 (21:09 +0300)
src/Makefile.am
src/vlc.c

index ad9a0892fc8d79962a7cb77a5c474c3d2e5894cb..8f488b428dc562489f3b50b02afb1842df9ee63e 100644 (file)
@@ -439,7 +439,8 @@ vlc_DEPENDENCIES = $(DATA_win32_rc) libvlc.la
 
 vlc_CFLAGS = `$(VLC_CONFIG) --cflags vlc`
 vlc_LDFLAGS = `$(VLC_CONFIG) --ldflags vlc`
-vlc_LDADD = $(DATA_win32_rc) libvlccore.la $(LTLIBINTL) \
+# vlc needs libvlccore for locale conversion
+vlc_LDADD = $(DATA_win32_rc) libvlc.la libvlccore.la $(LTLIBINTL) \
        `$(VLC_CONFIG) -libs vlc`
 
 if BUILD_VLC
index 208fd86b5dcc7c3ba12d3a12e8f5bc4c0456f1cd..deaba4bedfb2d52fd66ef234236da049be2766cb 100644 (file)
--- a/src/vlc.c
+++ b/src/vlc.c
@@ -25,8 +25,6 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
  *****************************************************************************/
 
-#include "config.h"
-
 #ifdef HAVE_CONFIG_H
 # include "config.h"
 #endif
@@ -63,13 +61,13 @@ static void *SigHandler (void *set);
  *****************************************************************************/
 int main( int i_argc, const char *ppsz_argv[] )
 {
-    int i_ret, id;
+    int i_ret;
 
     setlocale (LC_ALL, "");
 
 #ifndef __APPLE__
     /* This clutters OSX GUI error logs */
-    fprintf( stderr, "VLC media player %s\n", VLC_Version() );
+    fprintf( stderr, "VLC media player %s\n", libvlc_get_version() );
 #endif
 
 #ifdef HAVE_PUTENV
@@ -89,11 +87,6 @@ int main( int i_argc, const char *ppsz_argv[] )
     /* FIXME: rootwrap (); */
 #endif
 
-    /* Create a libvlc structure */
-    id = VLC_Create();
-    if( id < 0 )
-        return 1;
-
 #if !defined(WIN32) && !defined(UNDER_CE)
     /* Synchronously intercepted POSIX signals.
      *
@@ -181,26 +174,24 @@ int main( int i_argc, const char *ppsz_argv[] )
     else
 #endif
     {
+        /* Note that FromLocale() can be used before libvlc is initialized */
         for (int i = 0; i < i_argc; i++)
             if ((ppsz_argv[i] = FromLocale (ppsz_argv[i])) == NULL)
                 return 1; // BOOM!
     }
 
+    libvlc_exception_t ex;
+    libvlc_exception_init (&ex);
+
     /* Initialize libvlc */
-    i_ret = VLC_Init( id, i_argc, ppsz_argv );
-    if( i_ret < 0 )
+    libvlc_instance_t *vlc = libvlc_new (i_argc, ppsz_argv, &ex);
+    if (vlc != NULL)
     {
-        VLC_Destroy( 0 );
-        return i_ret == VLC_EEXITSUCCESS ? 0 : -i_ret;
+        libvlc_run_interface (vlc, NULL, &ex);
+        libvlc_release (vlc);
     }
-
-    i_ret = VLC_AddIntf( 0, NULL, true, true );
-
-    /* Finish the threads */
-    VLC_CleanUp( 0 );
-
-    /* Destroy the libvlc structure */
-    VLC_Destroy( 0 );
+    i_ret = libvlc_exception_raised (&ex);
+    libvlc_exception_clear (&ex);
 
     for (int i = 0; i < i_argc; i++)
         LocaleFree (ppsz_argv[i]);
@@ -216,7 +207,7 @@ int main( int i_argc, const char *ppsz_argv[] )
     pthread_join (sigth, NULL);
 #endif
 
-    return -i_ret;
+    return i_ret;
 }
 
 #if !defined(WIN32) && !defined(UNDER_CE)
@@ -261,7 +252,7 @@ static void *SigHandler (void *data)
 
             fprintf (stderr, "signal %d received, terminating vlc - do it "
                             "again quickly in case it gets stuck\n", i_signal);
-            VLC_Die( 0 );
+            //VLC_Die( 0 );
         }
         else /* time (NULL) <= abort_time */
         {