[vlc-devel] commit: vlc using libvlc ( Rémi Denis-Courmont )

git version control git at videolan.org
Thu May 15 20:24:44 CEST 2008


vlc | branch: master | Rémi Denis-Courmont <rem at videolan.org> | Thu May 15 20:11:41 2008 +0300| [2a855b131692979ae954939ad5d5a7d78cc21b44]

vlc using libvlc

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=2a855b131692979ae954939ad5d5a7d78cc21b44
---

 src/Makefile.am |    3 ++-
 src/vlc.c       |   37 ++++++++++++++-----------------------
 2 files changed, 16 insertions(+), 24 deletions(-)

diff --git a/src/Makefile.am b/src/Makefile.am
index ad9a089..8f488b4 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -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
diff --git a/src/vlc.c b/src/vlc.c
index 208fd86..deaba4b 100644
--- 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 */
         {




More information about the vlc-devel mailing list