X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=src%2Finterface%2Finterface.c;h=a3fb41a6fae640cdd7863a0beb6ccfbd790a4613;hb=d78cb0b36d74d5f8221e0c5bab62ca0cbc933fda;hp=b850eeb4102923768ca29298f5d4229b5522c68e;hpb=ca6669acaae8a1e0c4ec8ad7e98e6a3a837a8d61;p=vlc diff --git a/src/interface/interface.c b/src/interface/interface.c index b850eeb410..a3fb41a6fa 100644 --- a/src/interface/interface.c +++ b/src/interface/interface.c @@ -56,10 +56,9 @@ static int AddIntfCallback( vlc_object_t *, char const *, vlc_value_t , vlc_value_t , void * ); /** - * \brief Destroy the interface after the main loop endeed. + * Destroy the interface after the main loop endeed. * - * \param p_intf the interface thread - * \return nothing + * @param p_obj: the interface thread */ static void intf_Destroy( vlc_object_t *obj ) { @@ -73,18 +72,14 @@ static void intf_Destroy( vlc_object_t *obj ) vlc_mutex_destroy( &p_intf->change_lock ); } -/***************************************************************************** - * intf_Create: prepare interface before main loop - ***************************************************************************** - * This function opens output devices and creates specific interfaces. It sends - * its own error messages. - *****************************************************************************/ + /** - * Create the interface, and prepare it for main loop. + * Create the interface, and prepare it for main loop. It opens ouput device + * and creates specific interfaces. Sends its own error messages. * - * \param p_this the calling vlc_object_t - * \param psz_module a preferred interface module - * \return a pointer to the created interface thread, NULL on error + * @param p_this the calling vlc_object_t + * @param psz_module a preferred interface module + * @return a pointer to the created interface thread, NULL on error */ intf_thread_t* __intf_Create( vlc_object_t *p_this, const char *psz_module ) { @@ -94,7 +89,6 @@ intf_thread_t* __intf_Create( vlc_object_t *p_this, const char *psz_module ) p_intf = vlc_object_create( p_this, VLC_OBJECT_INTF ); if( !p_intf ) return NULL; - p_intf->b_interaction = false; #if defined( __APPLE__ ) || defined( WIN32 ) p_intf->b_should_run_on_first_thread = false; #endif @@ -111,10 +105,6 @@ intf_thread_t* __intf_Create( vlc_object_t *p_this, const char *psz_module ) return NULL; } - /* Initialize structure */ - p_intf->b_menu = false; - p_intf->b_menu_change = false; - /* Initialize mutexes */ vlc_mutex_init( &p_intf->change_lock ); @@ -125,16 +115,12 @@ intf_thread_t* __intf_Create( vlc_object_t *p_this, const char *psz_module ) return p_intf; } -/***************************************************************************** - * intf_RunThread: launch the interface thread - ***************************************************************************** - * This function either creates a new thread and runs the interface in it. - *****************************************************************************/ + /** * Starts and runs the interface thread. * - * \param p_intf the interface thread - * \return VLC_SUCCESS on success, an error number else + * @param p_intf the interface thread + * @return VLC_SUCCESS on success, an error number else */ int intf_RunThread( intf_thread_t *p_intf ) { @@ -154,7 +140,7 @@ int intf_RunThread( intf_thread_t *p_intf ) /* Make sure our MonitorLibVLCDeath thread exit */ vlc_object_kill( p_intf ); /* It is monitoring libvlc, not the p_intf */ - vlc_object_signal( p_intf->p_libvlc ); + vlc_object_kill( p_intf->p_libvlc ); vlc_thread_join( p_intf ); vlc_object_detach( p_intf ); @@ -173,12 +159,12 @@ int intf_RunThread( intf_thread_t *p_intf ) return VLC_SUCCESS; } + /** * Stops the interface thread * * This function asks the interface thread to stop - * \param p_intf the interface thread - * \return nothing + * @param p_intf the interface thread */ void intf_StopThread( intf_thread_t *p_intf ) { @@ -187,11 +173,15 @@ void intf_StopThread( intf_thread_t *p_intf ) vlc_thread_join( p_intf ); } + + /* Following functions are local */ -/***************************************************************************** +/** * RunInterface: setups necessary data and give control to the interface - *****************************************************************************/ + * + * @param p_this: interface object + */ static void* RunInterface( vlc_object_t *p_this ) { intf_thread_t *p_intf = (intf_thread_t *)p_this; @@ -231,9 +221,11 @@ static void* RunInterface( vlc_object_t *p_this ) } #if defined( __APPLE__ ) || defined( WIN32 ) -/***************************************************************************** +/** * MonitorLibVLCDeath: Used when b_should_run_on_first_thread is set. - *****************************************************************************/ + * + * @param p_this: the interface object + */ static void * MonitorLibVLCDeath( vlc_object_t * p_this ) { intf_thread_t *p_intf = (intf_thread_t *)p_this; @@ -271,13 +263,14 @@ static void * MonitorLibVLCDeath( vlc_object_t * p_this ) static int AddIntfCallback( vlc_object_t *p_this, char const *psz_cmd, vlc_value_t oldval, vlc_value_t newval, void *p_data ) { - intf_thread_t *p_intf; - char *psz_intf = malloc( strlen(newval.psz_string) + sizeof(",none") ); - (void)psz_cmd; (void)oldval; (void)p_data; + intf_thread_t *p_intf; + char* psz_intf; /* Try to create the interface */ - sprintf( psz_intf, "%s,none", newval.psz_string ); + if( asprintf( &psz_intf, "%s,none", newval.psz_string ) == -1 ) + return VLC_ENOMEM; + p_intf = intf_Create( p_this->p_libvlc, psz_intf ); free( psz_intf ); if( p_intf == NULL )