/** * Cleanup a libvlc instance. The instance is not completely deallocated * \param p_libvlc the instance to clean */ void libvlc_InternalCleanup( libvlc_int_t *p_libvlc ) { libvlc_priv_t *priv = libvlc_priv (p_libvlc); /* Ask the interfaces to stop and destroy them */ msg_Dbg( p_libvlc, "removing all interfaces" ); libvlc_Quit( p_libvlc ); intf_DestroyAll( p_libvlc ); #ifdef ENABLE_VLM /* Destroy VLM if created in libvlc_InternalInit */ if( priv->p_vlm ) { vlm_Delete( priv->p_vlm ); } #endif /* Free playlist now, all threads are gone */ playlist_t *p_playlist = libvlc_priv (p_libvlc)->p_playlist; if( p_playlist != NULL ) playlist_Destroy( p_playlist ); #if !defined( _WIN32 ) && !defined( __OS2__ ) char *pidfile = var_InheritString( p_libvlc, "pidfile" ); if( pidfile != NULL ) { msg_Dbg( p_libvlc, "removing PID file %s", pidfile ); if( unlink( pidfile ) ) msg_Warn( p_libvlc, "cannot remove PID file %s: %s", pidfile, vlc_strerror_c(errno) ); free( pidfile ); } #endif if (priv->parser != NULL) playlist_preparser_Delete(priv->parser); vlc_DeinitActions( p_libvlc, priv->actions ); /* Save the configuration */ if( !var_InheritBool( p_libvlc, "ignore-config" ) ) config_AutoSaveConfigFile( VLC_OBJECT(p_libvlc) ); /* Free module bank. It is refcounted, so we call this each time */ module_EndBank (true); vlc_LogDeinit (p_libvlc); #if defined(_WIN32) || defined(__OS2__) system_End( ); #endif }
/** * Cleanup a libvlc instance. The instance is not completely deallocated * \param p_libvlc the instance to clean */ void libvlc_InternalCleanup( libvlc_int_t *p_libvlc ) { libvlc_priv_t *priv = libvlc_priv (p_libvlc); playlist_t *p_playlist = libvlc_priv (p_libvlc)->p_playlist; /* Deactivate the playlist */ msg_Dbg( p_libvlc, "deactivating the playlist" ); pl_Deactivate( p_libvlc ); /* Remove all services discovery */ msg_Dbg( p_libvlc, "removing all services discovery tasks" ); playlist_ServicesDiscoveryKillAll( p_playlist ); /* Ask the interfaces to stop and destroy them */ msg_Dbg( p_libvlc, "removing all interfaces" ); libvlc_Quit( p_libvlc ); intf_DestroyAll( p_libvlc ); #ifdef ENABLE_VLM /* Destroy VLM if created in libvlc_InternalInit */ if( priv->p_vlm ) { vlm_Delete( priv->p_vlm ); } #endif #if defined(MEDIA_LIBRARY) media_library_t* p_ml = priv->p_ml; if( p_ml ) { ml_Destroy( VLC_OBJECT( p_ml ) ); vlc_object_release( p_ml ); libvlc_priv(p_playlist->p_libvlc)->p_ml = NULL; } #endif /* Free playlist now, all threads are gone */ playlist_Destroy( p_playlist ); msg_Dbg( p_libvlc, "removing stats" ); #if !defined( WIN32 ) && !defined( __OS2__ ) char* psz_pidfile = NULL; if( b_daemon ) { psz_pidfile = var_CreateGetNonEmptyString( p_libvlc, "pidfile" ); if( psz_pidfile != NULL ) { msg_Dbg( p_libvlc, "removing pid file %s", psz_pidfile ); if( unlink( psz_pidfile ) == -1 ) { msg_Dbg( p_libvlc, "removing pid file %s: %m", psz_pidfile ); } } free( psz_pidfile ); } #endif /* Save the configuration */ if( !var_InheritBool( p_libvlc, "ignore-config" ) ) config_AutoSaveConfigFile( VLC_OBJECT(p_libvlc) ); /* Free module bank. It is refcounted, so we call this each time */ module_EndBank (true); vlc_DeinitActions( p_libvlc, priv->actions ); }