+
+ if( p_vlc->pf_memset == NULL )
+ {
+ p_vlc->pf_memset = memset;
+ }
+
+ /*
+ * Initialize hotkey handling
+ */
+ var_Create( p_vlc, "key-pressed", VLC_VAR_INTEGER );
+ p_vlc->p_hotkeys = malloc( sizeof(p_hotkeys) );
+ /* Do a copy (we don't need to modify the strings) */
+ memcpy( p_vlc->p_hotkeys, p_hotkeys, sizeof(p_hotkeys) );
+
+ /*
+ * Initialize playlist and get commandline files
+ */
+ p_playlist = playlist_Create( p_vlc );
+ if( !p_playlist )
+ {
+ msg_Err( p_vlc, "playlist initialization failed" );
+ if( p_vlc->p_memcpy_module != NULL )
+ {
+ module_Unneed( p_vlc, p_vlc->p_memcpy_module );
+ }
+ /*module_EndBank( p_vlc );*/
+ if( i_object ) vlc_object_release( p_vlc );
+ return VLC_EGENERIC;
+ }
+
+ /*
+ * Load background interfaces
+ */
+ psz_modules = config_GetPsz( p_vlc, "extraintf" );
+ psz_parser = psz_modules;
+ while ( psz_parser && *psz_parser )
+ {
+ char *psz_module, *psz_temp;
+ psz_module = psz_parser;
+ psz_parser = strchr( psz_module, ',' );
+ if ( psz_parser )
+ {
+ *psz_parser = '\0';
+ psz_parser++;
+ }
+ psz_temp = (char *)malloc( strlen(psz_module) + sizeof(",none") );
+ if( psz_temp )
+ {
+ sprintf( psz_temp, "%s,none", psz_module );
+ VLC_AddIntf( 0, psz_temp, VLC_FALSE );
+ free( psz_temp );
+ }
+ }
+ if ( psz_modules )
+ {
+ free( psz_modules );
+ }
+
+ /*
+ * Allways load the hotkeys interface if it exists
+ */
+ VLC_AddIntf( 0, "hotkeys,none", VLC_FALSE );
+
+ /*
+ * FIXME: kludge to use a p_vlc-local variable for the Mozilla plugin
+ */
+ var_Create( p_vlc, "drawable", VLC_VAR_INTEGER );
+ var_Create( p_vlc, "drawableredraw", VLC_VAR_INTEGER );
+ var_Create( p_vlc, "drawablet", VLC_VAR_INTEGER );
+ var_Create( p_vlc, "drawablel", VLC_VAR_INTEGER );
+ var_Create( p_vlc, "drawableb", VLC_VAR_INTEGER );
+ var_Create( p_vlc, "drawabler", VLC_VAR_INTEGER );
+ var_Create( p_vlc, "drawablex", VLC_VAR_INTEGER );
+ var_Create( p_vlc, "drawabley", VLC_VAR_INTEGER );
+ var_Create( p_vlc, "drawablew", VLC_VAR_INTEGER );
+ var_Create( p_vlc, "drawableh", VLC_VAR_INTEGER );
+ var_Create( p_vlc, "drawableportx", VLC_VAR_INTEGER );
+ var_Create( p_vlc, "drawableporty", VLC_VAR_INTEGER );
+
+ /*
+ * Get input filenames given as commandline arguments
+ */
+ GetFilenames( p_vlc, i_argc, ppsz_argv );
+
+ if( i_object ) vlc_object_release( p_vlc );
+ return VLC_SUCCESS;
+}
+
+/*****************************************************************************
+ * VLC_AddIntf: add an interface
+ *****************************************************************************
+ * This function opens an interface plugin and runs it. If b_block is set
+ * to 0, VLC_AddIntf will return immediately and let the interface run in a
+ * separate thread. If b_block is set to 1, VLC_AddIntf will continue until
+ * user requests to quit.
+ *****************************************************************************/
+int VLC_AddIntf( int i_object, char const *psz_module, vlc_bool_t b_block )
+{
+ int i_err;
+ intf_thread_t *p_intf;
+ vlc_t *p_vlc = vlc_current_object( i_object );
+
+ if( !p_vlc )
+ {
+ return VLC_ENOOBJ;
+ }
+
+ /* Try to create the interface */
+ p_intf = intf_Create( p_vlc, psz_module ? psz_module : "$intf" );
+
+ if( p_intf == NULL )
+ {
+ msg_Err( p_vlc, "interface \"%s\" initialization failed", psz_module );
+ if( i_object ) vlc_object_release( p_vlc );
+ return VLC_EGENERIC;
+ }
+
+ /* Try to run the interface */
+ p_intf->b_block = b_block;
+ i_err = intf_RunThread( p_intf );
+ if( i_err )
+ {
+ vlc_object_detach( p_intf );
+ intf_Destroy( p_intf );
+ if( i_object ) vlc_object_release( p_vlc );
+ return i_err;
+ }
+
+ if( i_object ) vlc_object_release( p_vlc );
+ return VLC_SUCCESS;
+}
+
+/*****************************************************************************
+ * VLC_Destroy: stop playing and destroy everything.
+ *****************************************************************************
+ * This function requests the running threads to finish, waits for their
+ * termination, and destroys their structure.
+ *****************************************************************************/
+int VLC_Destroy( int i_object )
+{
+ vlc_t *p_vlc = vlc_current_object( i_object );
+
+ if( !p_vlc )
+ {
+ return VLC_ENOOBJ;
+ }
+
+ /*
+ * Free allocated memory
+ */
+ if( p_vlc->p_memcpy_module )
+ {
+ module_Unneed( p_vlc, p_vlc->p_memcpy_module );
+ p_vlc->p_memcpy_module = NULL;
+ }
+
+ if( p_vlc->psz_homedir )
+ {
+ free( p_vlc->psz_homedir );
+ p_vlc->psz_homedir = NULL;
+ }
+
+ if( p_vlc->psz_configfile )
+ {
+ free( p_vlc->psz_configfile );
+ p_vlc->psz_configfile = NULL;
+ }
+
+ if( p_vlc->p_hotkeys )
+ {
+ free( p_vlc->p_hotkeys );
+ p_vlc->p_hotkeys = NULL;
+ }
+
+ /*
+ * XXX: Free module bank !
+ */
+ /*module_EndBank( p_vlc );*/
+
+ /*
+ * System specific cleaning code
+ */
+ system_End( p_vlc );
+
+ /* Destroy mutexes */
+ vlc_mutex_destroy( &p_vlc->config_lock );
+#ifdef SYS_DARWIN
+ vlc_mutex_destroy( &p_vlc->quicktime_lock );
+#endif
+
+ vlc_object_detach( p_vlc );
+
+ /* Release object before destroying it */
+ if( i_object ) vlc_object_release( p_vlc );
+
+ vlc_object_destroy( p_vlc );
+
+ /* Stop thread system: last one out please shut the door! */
+ vlc_threads_end( p_libvlc );
+
+ return VLC_SUCCESS;
+}
+
+/*****************************************************************************
+ * VLC_Die: ask vlc to die.
+ *****************************************************************************
+ * This function sets p_vlc->b_die to VLC_TRUE, but does not do any other
+ * task. It is your duty to call VLC_End and VLC_Destroy afterwards.
+ *****************************************************************************/
+int VLC_Die( int i_object )
+{
+ vlc_t *p_vlc = vlc_current_object( i_object );
+
+ if( !p_vlc )
+ {
+ return VLC_ENOOBJ;
+ }
+
+ p_vlc->b_die = VLC_TRUE;
+
+ if( i_object ) vlc_object_release( p_vlc );
+ return VLC_SUCCESS;
+}
+
+/*****************************************************************************
+ * VLC_AddTarget: adds a target for playing.
+ *****************************************************************************
+ * This function adds psz_target to the current playlist. If a playlist does
+ * not exist, it will create one.
+ *****************************************************************************/
+int VLC_AddTarget( int i_object, char const *psz_target,
+ char const **ppsz_options, int i_options,
+ int i_mode, int i_pos )
+{
+ int i_err;
+ playlist_t *p_playlist;
+ vlc_t *p_vlc = vlc_current_object( i_object );
+
+ if( !p_vlc )