+ 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 );
+ }
+
+ /*
+ * FIXME: kludge to use a p_vlc-local variable for the Mozilla plugin
+ */
+ var_Create( p_vlc, "drawable", 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;
+
+ p_vlc = i_object ? vlc_object_get( &libvlc, i_object ) : p_static_vlc;
+
+ 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;
+
+ p_vlc = i_object ? vlc_object_get( &libvlc, i_object ) : p_static_vlc;
+
+ if( !p_vlc )
+ {
+ return VLC_ENOOBJ;
+ }
+
+ /*
+ * Go back into channel 0 which is the network
+ */
+ if( config_GetInt( p_vlc, "network-channel" ) && p_vlc->p_channel )
+ {
+ network_ChannelJoin( p_vlc, COMMON_CHANNEL );
+ }
+
+ /*
+ * 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;
+ }
+
+ /*
+ * 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 );
+
+ 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( &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;
+
+ p_vlc = i_object ? vlc_object_get( &libvlc, i_object ) : p_static_vlc;
+
+ 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, int i_mode, int i_pos )
+{
+ int i_err;
+ playlist_t *p_playlist;
+ vlc_t *p_vlc;
+
+ p_vlc = i_object ? vlc_object_get( &libvlc, i_object ) : p_static_vlc;
+
+ if( !p_vlc )
+ {
+ return VLC_ENOOBJ;
+ }
+
+ p_playlist = vlc_object_find( p_vlc, VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );
+
+ if( p_playlist == NULL )
+ {
+ msg_Dbg( p_vlc, "no playlist present, creating one" );
+ p_playlist = playlist_Create( p_vlc );
+
+ if( p_playlist == NULL )
+ {
+ if( i_object ) vlc_object_release( p_vlc );
+ return VLC_EGENERIC;
+ }
+
+ vlc_object_yield( p_playlist );
+ }
+
+ i_err = playlist_Add( p_playlist, psz_target, i_mode, i_pos );
+
+ vlc_object_release( p_playlist );
+
+ if( i_object ) vlc_object_release( p_vlc );
+ return i_err;
+}
+
+/*****************************************************************************
+ * VLC_Set: set a vlc variable
+ *****************************************************************************
+ *
+ *****************************************************************************/
+int VLC_Set( int i_object, char const *psz_var, vlc_value_t value )
+{
+ vlc_t *p_vlc;
+ int i_ret;
+
+ p_vlc = i_object ? vlc_object_get( &libvlc, i_object ) : p_static_vlc;
+
+ if( !p_vlc )
+ {
+ return VLC_ENOOBJ;
+ }
+
+ /* FIXME: Temporary hack for Mozilla, if variable starts with conf:: then
+ * we handle it as a configuration variable. Don't tell Gildas :) -- sam */
+ if( !strncmp( psz_var, "conf::", 6 ) )
+ {
+ module_config_t *p_item;
+ char const *psz_newvar = psz_var + 6;
+
+ p_item = config_FindConfig( VLC_OBJECT(p_vlc), psz_newvar );
+
+ if( p_item )
+ {
+ switch( p_item->i_type )
+ {
+ case CONFIG_ITEM_BOOL:
+ config_PutInt( p_vlc, psz_newvar, value.b_bool );
+ break;
+ case CONFIG_ITEM_INTEGER:
+ config_PutInt( p_vlc, psz_newvar, value.i_int );
+ break;
+ case CONFIG_ITEM_FLOAT:
+ config_PutFloat( p_vlc, psz_newvar, value.f_float );
+ break;
+ default:
+ config_PutPsz( p_vlc, psz_newvar, value.psz_string );
+ break;
+ }
+ if( i_object ) vlc_object_release( p_vlc );
+ return VLC_SUCCESS;