diff --git a/src/input/input.c b/src/input/input.c index 078d0904d5..0d669bd640 100644 --- a/src/input/input.c +++ b/src/input/input.c @@ -176,6 +176,17 @@ int input_Start( input_thread_t *p_input ) /* Create thread and wait for its readiness. */ priv->is_running = !vlc_clone( &priv->thread, func, priv, VLC_THREAD_PRIORITY_INPUT ); + + + char name[128]; + vlc_thread_t *vlc_th =(vlc_thread_t*)&priv->thread; + mach_port_t tid = pthread_mach_thread_np(vlc_th->handle); + uint64_t tid_np; + pthread_threadid_np(vlc_th->handle, &tid_np); + + sprintf(name,"vlc-player-end, %x-%x-%qx",tid,tid_np,priv->thread); + pthread_setname_np(name); + if( !priv->is_running ) { msg_Err( p_input, "cannot create input thread" ); @@ -215,7 +226,12 @@ void input_Stop( input_thread_t *p_input ) void input_Close( input_thread_t *p_input ) { if( input_priv(p_input)->is_running ) + { + msg_Dbg( p_input, "Closing an input: thread=%qx", p_input); + vlc_join( input_priv(p_input)->thread, NULL ); + } + vlc_interrupt_deinit( &input_priv(p_input)->interrupt ); Destroy(p_input); } @@ -266,7 +282,9 @@ static input_thread_t *Create( vlc_object_t *p_parent, /* Allocate descriptor */ input_thread_private_t *priv; + char * psz_name = input_item_GetName( p_item ); priv = vlc_custom_create( p_parent, sizeof( *priv ), "input" ); + //priv = vlc_custom_create( p_parent, sizeof( *priv ), "input" ); if( unlikely(priv == NULL) ) return NULL; @@ -279,7 +297,6 @@ static input_thread_t *Create( vlc_object_t *p_parent, input_thread_t *p_input = &priv->input; - char * psz_name = input_item_GetName( p_item ); const char *option_str; switch (option) { @@ -293,7 +310,10 @@ static input_thread_t *Create( vlc_object_t *p_parent, option_str = ""; break; } - msg_Dbg( p_input, "Creating an input for %s'%s'", option_str, psz_name); + + mach_port_t tid = pthread_mach_thread_np(p_input); + + msg_Dbg( p_input, "Creating an input for %s'%s' tid=%x thread=%qx", option_str, psz_name, tid, p_input); free( psz_name ); var_Create(p_input, "avstat", VLC_VAR_BOOL | VLC_VAR_DOINHERIT); @@ -464,7 +484,12 @@ static void *Run( void *data ) input_thread_private_t *priv = data; input_thread_t *p_input = &priv->input; - vlc_thread_set_name("vlc-input"); + char name[128]; + uint64_t tid_np; + + pthread_threadid_np(NULL,&tid_np); + sprintf(name,"vlc-input tid_np=%qx",tid_np); + vlc_thread_set_name(name); vlc_interrupt_set(&priv->interrupt); diff --git a/src/posix/thread.c b/src/posix/thread.c index 11009dcd2b..7cdbc033ee 100644 --- a/src/posix/thread.c +++ b/src/posix/thread.c @@ -180,6 +180,16 @@ static int vlc_clone_attr (vlc_thread_t *th, pthread_attr_t *attr, pthread_sigmask (SIG_SETMASK, &oldset, NULL); pthread_attr_destroy (attr); (void) priority; + + char name[128]; + uint64_t tid_np; + pthread_threadid_np(th->handle, &tid_np); + mach_port_t tid = pthread_mach_thread_np(th->handle); + //sprintf(name,"deckard> vlc-%x-%x-%qx",tid_np,tid,th->handle); + + fprintf(stderr,"deckard> pthread create vlc-%x-%x-%qx entry=%qx\n",tid,tid_np,th->handle,entry); + + //pthread_setname_np(name); return ret; } @@ -194,7 +204,14 @@ int vlc_clone (vlc_thread_t *th, void *(*entry) (void *), void *data, void vlc_join(vlc_thread_t th, void **result) { + char name[128]; + uint64_t tid_np; + pthread_threadid_np(th.handle, &tid_np); + mach_port_t tid = pthread_mach_thread_np(th.handle); + fprintf(stderr,"deckard> pthread join vlc-%x-%x-%qx\n",tid,tid_np,th.handle); + int val = pthread_join(th.handle, result); + VLC_THREAD_ASSERT ("joining thread"); }