]> git.sesse.net Git - vlc/blobdiff - lib/core.c
mux: avi: don't try to delete failed stream
[vlc] / lib / core.c
index 6e88b9481e6e5d55a5435f7f37f79760e6f97794..fa5c4de6d0c0a623c9b271f8fd748da0e199c93c 100644 (file)
@@ -1,24 +1,24 @@
 /*****************************************************************************
  * core.c: Core libvlc new API functions : initialization
  *****************************************************************************
- * Copyright (C) 2005 the VideoLAN team
+ * Copyright (C) 2005 VLC authors and VideoLAN
  * $Id$
  *
  * Authors: ClĂ©ment Stenac <zorglub@videolan.org>
  *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2.1 of the License, or
  * (at your option) any later version.
  *
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
  *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
  *****************************************************************************/
 
 #ifdef HAVE_CONFIG_H
 #include <limits.h>
 #include <assert.h>
 
-static const char nomemstr[] = "Insufficient memory";
+#include "../src/revision.c"
 
 libvlc_instance_t * libvlc_new( int argc, const char *const *argv )
 {
+    libvlc_threads_init ();
+
     libvlc_instance_t *p_new = malloc (sizeof (*p_new));
     if (unlikely(p_new == NULL))
         return NULL;
 
-    libvlc_init_threads ();
-
     const char *my_argv[argc + 2];
     my_argv[0] = "libvlc"; /* dummy arg0, skipped by getopt() et al */
     for( int i = 0; i < argc; i++ )
@@ -69,13 +69,11 @@ libvlc_instance_t * libvlc_new( int argc, const char *const *argv )
     p_new->ref_count = 1;
     p_new->p_callback_list = NULL;
     vlc_mutex_init(&p_new->instance_lock);
-    var_Create( p_libvlc_int, "http-user-agent",
-                VLC_VAR_STRING|VLC_VAR_DOINHERIT );
     return p_new;
 
 error:
-    libvlc_deinit_threads ();
     free (p_new);
+    libvlc_threads_deinit ();
     return NULL;
 }
 
@@ -107,26 +105,8 @@ void libvlc_release( libvlc_instance_t *p_instance )
         libvlc_InternalCleanup( p_instance->p_libvlc_int );
         libvlc_InternalDestroy( p_instance->p_libvlc_int );
         free( p_instance );
-        libvlc_deinit_threads ();
-    }
-}
-
-int libvlc_add_intf( libvlc_instance_t *p_i, const char *name )
-{
-    if( libvlc_InternalAddIntf( p_i->p_libvlc_int, name ))
-    {
-        if( name )
-        {
-            libvlc_printerr("interface \"%s\" initialization failed",
-                name );
-        }
-        else
-        {
-            libvlc_printerr("default interface initialization failed");
-        }
-        return -1;
+        libvlc_threads_deinit ();
     }
-    return 0;
 }
 
 void libvlc_set_exit_handler( libvlc_instance_t *p_i, void (*cb) (void *),
@@ -136,10 +116,20 @@ void libvlc_set_exit_handler( libvlc_instance_t *p_i, void (*cb) (void *),
     libvlc_SetExitHandler( p_libvlc, cb, data );
 }
 
+static void libvlc_wait_wakeup( void *data )
+{
+    vlc_sem_post( data );
+}
+
 void libvlc_wait( libvlc_instance_t *p_i )
 {
-    libvlc_int_t *p_libvlc = p_i->p_libvlc_int;
-    libvlc_InternalWait( p_libvlc );
+    vlc_sem_t sem;
+
+    vlc_sem_init( &sem, 0 );
+    libvlc_set_exit_handler( p_i, libvlc_wait_wakeup, &sem );
+    vlc_sem_wait( &sem );
+    libvlc_set_exit_handler( p_i, NULL, NULL );
+    vlc_sem_destroy( &sem );
 }
 
 void libvlc_set_user_agent (libvlc_instance_t *p_i,
@@ -157,6 +147,16 @@ void libvlc_set_user_agent (libvlc_instance_t *p_i,
     }
 }
 
+void libvlc_set_app_id(libvlc_instance_t *p_i, const char *id,
+                       const char *version, const char *icon)
+{
+    libvlc_int_t *p_libvlc = p_i->p_libvlc_int;
+
+    var_SetString(p_libvlc, "app-id", id ? id : "");
+    var_SetString(p_libvlc, "app-version", version ? version : "");
+    var_SetString(p_libvlc, "app-icon-name", icon ? icon : "");
+}
+
 const char * libvlc_get_version(void)
 {
     return VERSION_MESSAGE;
@@ -181,13 +181,13 @@ void libvlc_free( void *ptr )
 static libvlc_module_description_t *module_description_list_get(
                 libvlc_instance_t *p_instance, const char *capability )
 {
-    VLC_UNUSED( p_instance );
     libvlc_module_description_t *p_list = NULL,
                           *p_actual = NULL,
                           *p_previous = NULL;
-    module_t **module_list = module_list_get( NULL );
+    size_t count;
+    module_t **module_list = module_list_get( &count );
 
-    for (size_t i = 0; module_list[i]; i++)
+    for (size_t i = 0; i < count; i++)
     {
         module_t *p_module = module_list[i];
 
@@ -222,6 +222,7 @@ static libvlc_module_description_t *module_description_list_get(
     }
 
     module_list_free( module_list );
+    VLC_UNUSED( p_instance );
     return p_list;
 }