+ /* 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;
+ int i_err;
+ playlist_t *p_playlist;
+ vlc_t *p_vlc = vlc_current_object( i_object );
+
+ 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, psz_target,
+ i_mode, i_pos );
+
+ for( i = 0 ; i< i_options ; i++ )
+ {
+ playlist_AddOption( p_playlist, i_err , ppsz_options[i] );
+ }
+
+ 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 = vlc_current_object( i_object );
+ int i_ret;
+
+ 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;
+ }
+ }
+
+ i_ret = var_Set( p_vlc, psz_var, value );
+
+ if( i_object ) vlc_object_release( p_vlc );
+ return i_ret;
+}
+
+/*****************************************************************************
+ * VLC_Get: get a vlc variable
+ *****************************************************************************
+ *
+ *****************************************************************************/
+int VLC_Get( int i_object, char const *psz_var, vlc_value_t *p_value )
+{
+ vlc_t *p_vlc = vlc_current_object( i_object );
+ int i_ret;
+
+ if( !p_vlc )
+ {
+ return VLC_ENOOBJ;
+ }
+
+ i_ret = var_Get( p_vlc, psz_var, p_value );
+
+ if( i_object ) vlc_object_release( p_vlc );
+ return i_ret;
+}
+
+/* FIXME: temporary hacks */
+
+
+/*****************************************************************************
+ * VLC_IsPlaying: Query for Playlist Status
+ *****************************************************************************/
+vlc_bool_t VLC_IsPlaying( int i_object )
+{
+
+ playlist_t * p_playlist;
+ vlc_bool_t playing;
+
+ vlc_t *p_vlc = vlc_current_object( i_object );
+
+ /* Check that the handle is valid */
+ if( !p_vlc )
+ {
+ return VLC_ENOOBJ;
+ }
+
+ p_playlist = vlc_object_find( p_vlc, VLC_OBJECT_PLAYLIST, FIND_CHILD );
+
+ if( !p_playlist )
+ {
+ if( i_object ) vlc_object_release( p_vlc );
+ return VLC_ENOOBJ;
+ }
+
+ playing = playlist_IsPlaying( p_playlist );