[vlc-devel] [PATCH 2/3] Add an abort function to the Mac interface hack, remove extra thread
Juho Vähä-Herttua
juhovh at iki.fi
Sat Jul 31 17:47:32 CEST 2010
---
include/vlc_interface.h | 1 +
src/interface/interface.c | 42 ++++++++++--------------------------------
2 files changed, 11 insertions(+), 32 deletions(-)
diff --git a/include/vlc_interface.h b/include/vlc_interface.h
index ed9b64e..52b4973 100644
--- a/include/vlc_interface.h
+++ b/include/vlc_interface.h
@@ -55,6 +55,7 @@ typedef struct intf_thread_t
/* Thread properties and locks */
#if defined( __APPLE__ )
bool b_should_run_on_first_thread;
+ void ( *pf_abort ) ( struct intf_thread_t * ); /** Abort function */
#endif
/* Specific interfaces */
diff --git a/src/interface/interface.c b/src/interface/interface.c
index 43b45f2..6315428 100644
--- a/src/interface/interface.c
+++ b/src/interface/interface.c
@@ -51,9 +51,6 @@
* Local prototypes
*****************************************************************************/
static void* RunInterface( vlc_object_t *p_this );
-#if defined( __APPLE__ )
-static void * MonitorLibVLCDeath( vlc_object_t *p_this );
-#endif
static int AddIntfCallback( vlc_object_t *, char const *,
vlc_value_t , vlc_value_t , void * );
@@ -108,6 +105,7 @@ int intf_Create( vlc_object_t *p_this, const char *psz_module )
vlc_object_attach( p_intf, p_libvlc );
#if defined( __APPLE__ )
p_intf->b_should_run_on_first_thread = false;
+ p_intf->pf_abort = NULL;
#endif
/* Choose the best module */
@@ -132,18 +130,15 @@ int intf_Create( vlc_object_t *p_this, const char *psz_module )
* (it needs access to the main thread) */
if( p_intf->b_should_run_on_first_thread )
{
- if( vlc_thread_create( p_intf, "interface", MonitorLibVLCDeath,
- VLC_THREAD_PRIORITY_LOW ) )
+ if( p_intf->pf_abort )
{
- msg_Err( p_intf, "cannot spawn libvlc death monitoring thread" );
- vlc_mutex_unlock( &lock );
- goto error;
+ libvlc_SetExitHandler( p_intf->p_libvlc,
+ (void (*) (void *)) p_intf->pf_abort,
+ (void *) p_intf );
}
+
assert( p_intf->pf_run );
p_intf->pf_run( p_intf );
-
- /* It is monitoring libvlc, not the p_intf */
- vlc_object_kill( p_intf->p_libvlc );
}
else
#endif
@@ -197,7 +192,11 @@ void intf_DestroyAll( libvlc_int_t *p_libvlc )
{
intf_thread_t *p_next = p_intf->p_next;
+#if defined( __APPLE__ )
+ if( p_intf->pf_run && !p_intf->b_should_run_on_first_thread )
+#else
if( p_intf->pf_run )
+#endif
vlc_thread_join( p_intf );
module_unneed( p_intf, p_intf->p_module );
free( p_intf->psz_intf );
@@ -223,27 +222,6 @@ static void* RunInterface( vlc_object_t *p_this )
return NULL;
}
-#if defined( __APPLE__ )
-#include "control/libvlc_internal.h" /* libvlc_InternalWait */
-/**
- * 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;
- libvlc_int_t * p_libvlc = p_intf->p_libvlc;
- int canc = vlc_savecancel ();
-
- libvlc_InternalWait( p_libvlc );
-
- vlc_object_kill( p_intf ); /* Kill the stupid first thread interface */
- vlc_restorecancel (canc);
- return NULL;
-}
-#endif
-
static int AddIntfCallback( vlc_object_t *p_this, char const *psz_cmd,
vlc_value_t oldval, vlc_value_t newval, void *p_data )
{
--
1.6.5.7
More information about the vlc-devel
mailing list