1 /*****************************************************************************
2 * threads.c : threads implementation for the VideoLAN client
3 *****************************************************************************
4 * Copyright (C) 1999-2007 the VideoLAN team
7 * Authors: Jean-Marc Dressler <polux@via.ecp.fr>
8 * Samuel Hocevar <sam@zoy.org>
9 * Gildas Bazin <gbazin@netcourrier.com>
12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2 of the License, or
15 * (at your option) any later version.
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
25 *****************************************************************************/
39 #define VLC_THREADS_UNINITIALIZED 0
40 #define VLC_THREADS_PENDING 1
41 #define VLC_THREADS_ERROR 2
42 #define VLC_THREADS_READY 3
44 /*****************************************************************************
45 * Global mutex for lazy initialization of the threads system
46 *****************************************************************************/
47 static volatile unsigned i_initializations = 0;
48 static volatile int i_status = VLC_THREADS_UNINITIALIZED;
49 static vlc_object_t *p_root;
51 #if defined( UNDER_CE )
52 #elif defined( WIN32 )
54 /* following is only available on NT/2000/XP and above */
55 static SIGNALOBJECTANDWAIT pf_SignalObjectAndWait = NULL;
58 ** On Windows NT/2K/XP we use a slow mutex implementation but which
59 ** allows us to correctly implement condition variables.
60 ** You can also use the faster Win9x implementation but you might
61 ** experience problems with it.
63 static vlc_bool_t b_fast_mutex = VLC_FALSE;
65 ** On Windows 9x/Me you can use a fast but incorrect condition variables
66 ** implementation (more precisely there is a possibility for a race
67 ** condition to happen).
68 ** However it is possible to use slower alternatives which are more robust.
69 ** Currently you can choose between implementation 0 (which is the
70 ** fastest but slightly incorrect), 1 (default) and 2.
72 static int i_win9x_cv = 1;
74 #elif defined( HAVE_KERNEL_SCHEDULER_H )
75 #elif defined( LIBVLC_USE_PTHREAD )
76 static pthread_mutex_t once_mutex = PTHREAD_MUTEX_INITIALIZER;
79 vlc_threadvar_t msg_context_global_key;
82 /*****************************************************************************
83 * vlc_threads_error: Report an error from the threading mecanism
84 *****************************************************************************
85 * This is especially useful to debug those errors, as this is a nice symbol
86 * on which you can break.
87 *****************************************************************************/
88 void vlc_threads_error( vlc_object_t *p_this )
90 msg_Err( p_this, "Error detected. Put a breakpoint in '%s' to debug.",
95 /*****************************************************************************
96 * vlc_threads_init: initialize threads system
97 *****************************************************************************
98 * This function requires lazy initialization of a global lock in order to
99 * keep the library really thread-safe. Some architectures don't support this
100 * and thus do not guarantee the complete reentrancy.
101 *****************************************************************************/
102 int __vlc_threads_init( vlc_object_t *p_this )
104 libvlc_global_data_t *p_libvlc_global = (libvlc_global_data_t *)p_this;
105 int i_ret = VLC_SUCCESS;
107 /* If we have lazy mutex initialization, use it. Otherwise, we just
108 * hope nothing wrong happens. */
109 #if defined( UNDER_CE )
110 #elif defined( WIN32 )
111 if( IsDebuggerPresent() )
113 /* SignalObjectAndWait() is problematic under a debugger */
114 b_fast_mutex = VLC_TRUE;
117 #elif defined( HAVE_KERNEL_SCHEDULER_H )
118 #elif defined( LIBVLC_USE_PTHREAD )
119 pthread_mutex_lock( &once_mutex );
122 if( i_status == VLC_THREADS_UNINITIALIZED )
124 i_status = VLC_THREADS_PENDING;
126 /* We should be safe now. Do all the initialization stuff we want. */
127 p_libvlc_global->b_ready = VLC_FALSE;
129 #if defined( UNDER_CE )
130 /* Nothing to initialize */
132 #elif defined( WIN32 )
133 /* Dynamically get the address of SignalObjectAndWait */
134 if( GetVersion() < 0x80000000 )
138 /* We are running on NT/2K/XP, we can use SignalObjectAndWait */
139 hInstLib = LoadLibrary( "kernel32" );
142 pf_SignalObjectAndWait =
143 (SIGNALOBJECTANDWAIT)GetProcAddress( hInstLib,
144 "SignalObjectAndWait" );
148 #elif defined( HAVE_KERNEL_SCHEDULER_H )
149 #elif defined( LIBVLC_USE_PTHREAD )
152 p_root = vlc_object_create( p_libvlc_global, VLC_OBJECT_GLOBAL );
158 i_status = VLC_THREADS_ERROR;
163 i_status = VLC_THREADS_READY;
166 vlc_threadvar_create( p_root, &msg_context_global_key );
170 /* Just increment the initialization count */
174 /* If we have lazy mutex initialization support, unlock the mutex;
175 * otherwize, do a naive wait loop. */
176 #if defined( UNDER_CE )
177 while( i_status == VLC_THREADS_PENDING ) msleep( THREAD_SLEEP );
178 #elif defined( WIN32 )
179 while( i_status == VLC_THREADS_PENDING ) msleep( THREAD_SLEEP );
180 #elif defined( HAVE_KERNEL_SCHEDULER_H )
181 while( i_status == VLC_THREADS_PENDING ) msleep( THREAD_SLEEP );
182 #elif defined( LIBVLC_USE_PTHREAD )
183 pthread_mutex_unlock( &once_mutex );
186 if( i_status != VLC_THREADS_READY )
194 /*****************************************************************************
195 * vlc_threads_end: stop threads system
196 *****************************************************************************
197 * FIXME: This function is far from being threadsafe.
198 *****************************************************************************/
199 int __vlc_threads_end( vlc_object_t *p_this )
202 #if defined( UNDER_CE )
203 #elif defined( WIN32 )
204 #elif defined( HAVE_KERNEL_SCHEDULER_H )
205 #elif defined( LIBVLC_USE_PTHREAD )
206 pthread_mutex_lock( &once_mutex );
209 if( i_initializations == 0 )
213 if( i_initializations == 0 )
215 i_status = VLC_THREADS_UNINITIALIZED;
216 vlc_object_destroy( p_root );
219 #if defined( UNDER_CE )
220 #elif defined( WIN32 )
221 #elif defined( HAVE_KERNEL_SCHEDULER_H )
222 #elif defined( LIBVLC_USE_PTHREAD )
223 pthread_mutex_unlock( &once_mutex );
229 /* This is not prototyped under Linux, though it exists. */
230 int pthread_mutexattr_setkind_np( pthread_mutexattr_t *attr, int kind );
233 /*****************************************************************************
234 * vlc_mutex_init: initialize a mutex
235 *****************************************************************************/
236 int __vlc_mutex_init( vlc_object_t *p_this, vlc_mutex_t *p_mutex )
238 p_mutex->p_this = p_this;
240 #if defined( UNDER_CE )
241 InitializeCriticalSection( &p_mutex->csection );
244 #elif defined( WIN32 )
245 /* We use mutexes on WinNT/2K/XP because we can use the SignalObjectAndWait
246 * function and have a 100% correct vlc_cond_wait() implementation.
247 * As this function is not available on Win9x, we can use the faster
248 * CriticalSections */
249 if( pf_SignalObjectAndWait && !b_fast_mutex )
251 /* We are running on NT/2K/XP, we can use SignalObjectAndWait */
252 p_mutex->mutex = CreateMutex( 0, FALSE, 0 );
253 return ( p_mutex->mutex != NULL ? 0 : 1 );
257 p_mutex->mutex = NULL;
258 InitializeCriticalSection( &p_mutex->csection );
262 #elif defined( HAVE_KERNEL_SCHEDULER_H )
263 /* check the arguments and whether it's already been initialized */
264 if( p_mutex == NULL )
269 if( p_mutex->init == 9999 )
274 p_mutex->lock = create_sem( 1, "BeMutex" );
275 if( p_mutex->lock < B_NO_ERROR )
280 p_mutex->init = 9999;
283 #elif defined( LIBVLC_USE_PTHREAD )
286 /* Create error-checking mutex to detect problems more easily. */
287 pthread_mutexattr_t attr;
290 pthread_mutexattr_init( &attr );
291 # if defined(SYS_LINUX)
292 pthread_mutexattr_setkind_np( &attr, PTHREAD_MUTEX_ERRORCHECK_NP );
294 pthread_mutexattr_settype( &attr, PTHREAD_MUTEX_ERRORCHECK );
297 i_result = pthread_mutex_init( &p_mutex->mutex, &attr );
298 pthread_mutexattr_destroy( &attr );
302 return pthread_mutex_init( &p_mutex->mutex, NULL );
307 /*****************************************************************************
308 * vlc_mutex_init: initialize a recursive mutex (Do not use)
309 *****************************************************************************/
310 int __vlc_mutex_init_recursive( vlc_object_t *p_this, vlc_mutex_t *p_mutex )
313 /* Create mutex returns a recursive mutex */
314 p_mutex->mutex = CreateMutex( 0, FALSE, 0 );
315 return ( p_mutex->mutex != NULL ? 0 : 1 );
316 #elif defined( LIBVLC_USE_PTHREAD )
317 pthread_mutexattr_t attr;
320 pthread_mutexattr_init( &attr );
322 /* Create error-checking mutex to detect problems more easily. */
323 # if defined(SYS_LINUX)
324 pthread_mutexattr_setkind_np( &attr, PTHREAD_MUTEX_ERRORCHECK_NP );
326 pthread_mutexattr_settype( &attr, PTHREAD_MUTEX_ERRORCHECK );
329 pthread_mutexattr_settype( &attr, PTHREAD_MUTEX_RECURSIVE );
330 i_result = pthread_mutex_init( &p_mutex->mutex, &attr );
331 pthread_mutexattr_destroy( &attr );
334 msg_Err(p_this, "no recursive mutex found. Falling back to regular mutex.\n"
336 return __vlc_mutex_init( p_this, p_mutex );
341 /*****************************************************************************
342 * vlc_mutex_destroy: destroy a mutex, inner version
343 *****************************************************************************/
344 int __vlc_mutex_destroy( const char * psz_file, int i_line, vlc_mutex_t *p_mutex )
347 /* In case of error : */
350 #if defined( UNDER_CE )
351 DeleteCriticalSection( &p_mutex->csection );
354 #elif defined( WIN32 )
357 CloseHandle( p_mutex->mutex );
361 DeleteCriticalSection( &p_mutex->csection );
365 #elif defined( HAVE_KERNEL_SCHEDULER_H )
366 if( p_mutex->init == 9999 )
368 delete_sem( p_mutex->lock );
374 #elif defined( LIBVLC_USE_PTHREAD )
375 i_result = pthread_mutex_destroy( &p_mutex->mutex );
378 i_thread = CAST_PTHREAD_TO_INT(pthread_self());
386 msg_Err( p_mutex->p_this,
387 "thread %d: mutex_destroy failed at %s:%d (%d:%m)",
388 i_thread, psz_file, i_line, i_result );
389 vlc_threads_error( p_mutex->p_this );
394 /*****************************************************************************
395 * vlc_cond_init: initialize a condition
396 *****************************************************************************/
397 int __vlc_cond_init( vlc_object_t *p_this, vlc_cond_t *p_condvar )
399 p_condvar->p_this = p_this;
401 #if defined( UNDER_CE )
402 /* Initialize counter */
403 p_condvar->i_waiting_threads = 0;
405 /* Create an auto-reset event. */
406 p_condvar->event = CreateEvent( NULL, /* no security */
407 FALSE, /* auto-reset event */
408 FALSE, /* start non-signaled */
409 NULL ); /* unnamed */
410 return !p_condvar->event;
412 #elif defined( WIN32 )
413 /* Initialize counter */
414 p_condvar->i_waiting_threads = 0;
417 p_condvar->i_win9x_cv = i_win9x_cv;
418 p_condvar->SignalObjectAndWait = pf_SignalObjectAndWait;
420 if( (p_condvar->SignalObjectAndWait && !b_fast_mutex)
421 || p_condvar->i_win9x_cv == 0 )
423 /* Create an auto-reset event. */
424 p_condvar->event = CreateEvent( NULL, /* no security */
425 FALSE, /* auto-reset event */
426 FALSE, /* start non-signaled */
427 NULL ); /* unnamed */
429 p_condvar->semaphore = NULL;
430 return !p_condvar->event;
434 p_condvar->semaphore = CreateSemaphore( NULL, /* no security */
435 0, /* initial count */
436 0x7fffffff, /* max count */
437 NULL ); /* unnamed */
439 if( p_condvar->i_win9x_cv == 1 )
440 /* Create a manual-reset event initially signaled. */
441 p_condvar->event = CreateEvent( NULL, TRUE, TRUE, NULL );
443 /* Create a auto-reset event. */
444 p_condvar->event = CreateEvent( NULL, FALSE, FALSE, NULL );
446 InitializeCriticalSection( &p_condvar->csection );
448 return !p_condvar->semaphore || !p_condvar->event;
451 #elif defined( HAVE_KERNEL_SCHEDULER_H )
457 if( p_condvar->init == 9999 )
462 p_condvar->thread = -1;
463 p_condvar->init = 9999;
466 #elif defined( LIBVLC_USE_PTHREAD )
467 pthread_condattr_t attr;
470 ret = pthread_condattr_init (&attr);
474 # if !defined (_POSIX_CLOCK_SELECTION)
475 /* Fairly outdated POSIX support (that was defined in 2001) */
476 # define _POSIX_CLOCK_SELECTION (-1)
478 # if (_POSIX_CLOCK_SELECTION >= 0)
479 /* NOTE: This must be the same clock as the one in mtime.c */
480 pthread_condattr_setclock (&attr, CLOCK_MONOTONIC);
483 ret = pthread_cond_init (&p_condvar->cond, &attr);
484 pthread_condattr_destroy (&attr);
490 /*****************************************************************************
491 * vlc_cond_destroy: destroy a condition, inner version
492 *****************************************************************************/
493 int __vlc_cond_destroy( const char * psz_file, int i_line, vlc_cond_t *p_condvar )
496 /* In case of error : */
499 #if defined( UNDER_CE )
500 i_result = !CloseHandle( p_condvar->event );
502 #elif defined( WIN32 )
503 if( !p_condvar->semaphore )
504 i_result = !CloseHandle( p_condvar->event );
506 i_result = !CloseHandle( p_condvar->event )
507 || !CloseHandle( p_condvar->semaphore );
509 if( p_condvar->semaphore != NULL )
510 DeleteCriticalSection( &p_condvar->csection );
512 #elif defined( HAVE_KERNEL_SCHEDULER_H )
516 #elif defined( LIBVLC_USE_PTHREAD )
517 i_result = pthread_cond_destroy( &p_condvar->cond );
520 i_thread = CAST_PTHREAD_TO_INT(pthread_self());
528 msg_Err( p_condvar->p_this,
529 "thread %d: cond_destroy failed at %s:%d (%d:%m)",
530 i_thread, psz_file, i_line, i_result );
531 vlc_threads_error( p_condvar->p_this );
536 /*****************************************************************************
537 * vlc_tls_create: create a thread-local variable
538 *****************************************************************************/
539 int __vlc_threadvar_create( vlc_object_t *p_this, vlc_threadvar_t *p_tls )
544 #if defined( HAVE_KERNEL_SCHEDULER_H )
545 msg_Err( p_this, "TLS not implemented" );
547 #elif defined( UNDER_CE ) || defined( WIN32 )
548 #elif defined( WIN32 )
549 p_tls->handle = TlsAlloc();
550 i_ret = !( p_tls->handle == 0xFFFFFFFF );
552 #elif defined( LIBVLC_USE_PTHREAD )
553 i_ret = pthread_key_create( &p_tls->handle, NULL );
558 /*****************************************************************************
559 * vlc_thread_create: create a thread, inner version
560 *****************************************************************************
561 * Note that i_priority is only taken into account on platforms supporting
562 * userland real-time priority threads.
563 *****************************************************************************/
564 int __vlc_thread_create( vlc_object_t *p_this, const char * psz_file, int i_line,
565 const char *psz_name, void * ( *func ) ( void * ),
566 int i_priority, vlc_bool_t b_wait )
569 void *p_data = (void *)p_this;
570 vlc_object_internals_t *p_priv = p_this->p_internals;
572 vlc_mutex_lock( &p_this->object_lock );
574 #if defined( WIN32 ) || defined( UNDER_CE )
576 /* When using the MSVCRT C library you have to use the _beginthreadex
577 * function instead of CreateThread, otherwise you'll end up with
578 * memory leaks and the signal functions not working (see Microsoft
579 * Knowledge Base, article 104641) */
580 #if defined( UNDER_CE )
582 HANDLE hThread = CreateThread( NULL, 0, (LPTHREAD_START_ROUTINE)func,
583 (LPVOID)p_data, CREATE_SUSPENDED,
587 uintptr_t hThread = _beginthreadex( NULL, 0,
588 (LPTHREAD_START_ROUTINE)func,
589 (void*)p_data, CREATE_SUSPENDED,
592 p_priv->thread_id.id = (DWORD)threadId;
593 p_priv->thread_id.hThread = (HANDLE)hThread;
594 ResumeThread((HANDLE)hThread);
597 i_ret = ( p_priv->thread_id.hThread ? 0 : 1 );
599 if( i_ret && i_priority )
601 if( !SetThreadPriority(p_priv->thread_id.hThread, i_priority) )
603 msg_Warn( p_this, "couldn't set a faster priority" );
608 #elif defined( HAVE_KERNEL_SCHEDULER_H )
609 p_priv->thread_id = spawn_thread( (thread_func)func, psz_name,
610 i_priority, p_data );
611 i_ret = resume_thread( p_priv->thread_id );
613 #elif defined( LIBVLC_USE_PTHREAD )
614 i_ret = pthread_create( &p_priv->thread_id, NULL, func, p_data );
617 if( config_GetInt( p_this, "rt-priority" ) )
620 int i_error, i_policy;
621 struct sched_param param;
623 memset( ¶m, 0, sizeof(struct sched_param) );
624 if( config_GetType( p_this, "rt-offset" ) )
626 i_priority += config_GetInt( p_this, "rt-offset" );
628 if( i_priority <= 0 )
630 param.sched_priority = (-1) * i_priority;
631 i_policy = SCHED_OTHER;
635 param.sched_priority = i_priority;
638 if( (i_error = pthread_setschedparam( p_priv->thread_id,
639 i_policy, ¶m )) )
642 msg_Warn( p_this, "couldn't set thread priority (%s:%d): %m",
660 msg_Dbg( p_this, "waiting for thread completion" );
661 vlc_object_wait( p_this );
664 p_priv->b_thread = VLC_TRUE;
666 #if defined( WIN32 ) || defined( UNDER_CE )
667 msg_Dbg( p_this, "thread %u (%s) created at priority %d (%s:%d)",
668 (unsigned int)p_priv->thread_id.id, psz_name,
669 i_priority, psz_file, i_line );
671 msg_Dbg( p_this, "thread %u (%s) created at priority %d (%s:%d)",
672 (unsigned int)p_priv->thread_id, psz_name, i_priority,
677 vlc_mutex_unlock( &p_this->object_lock );
682 msg_Err( p_this, "%s thread could not be created at %s:%d (%m)",
683 psz_name, psz_file, i_line );
684 vlc_threads_error( p_this );
685 vlc_mutex_unlock( &p_this->object_lock );
691 /*****************************************************************************
692 * vlc_thread_set_priority: set the priority of the current thread when we
693 * couldn't set it in vlc_thread_create (for instance for the main thread)
694 *****************************************************************************/
695 int __vlc_thread_set_priority( vlc_object_t *p_this, const char * psz_file,
696 int i_line, int i_priority )
698 vlc_object_internals_t *p_priv = p_this->p_internals;
699 #if defined( WIN32 ) || defined( UNDER_CE )
700 if( !p_priv->thread_id.hThread )
701 p_priv->thread_id.hThread = GetCurrentThread();
702 if( !SetThreadPriority(p_priv->thread_id.hThread, i_priority) )
704 msg_Warn( p_this, "couldn't set a faster priority" );
708 #elif defined( LIBVLC_USE_PTHREAD )
710 if( config_GetInt( p_this, "rt-priority" ) > 0 )
713 int i_error, i_policy;
714 struct sched_param param;
716 memset( ¶m, 0, sizeof(struct sched_param) );
717 if( config_GetType( p_this, "rt-offset" ) )
719 i_priority += config_GetInt( p_this, "rt-offset" );
721 if( i_priority <= 0 )
723 param.sched_priority = (-1) * i_priority;
724 i_policy = SCHED_OTHER;
728 param.sched_priority = i_priority;
731 if( !p_priv->thread_id )
732 p_priv->thread_id = pthread_self();
733 if( (i_error = pthread_setschedparam( p_priv->thread_id,
734 i_policy, ¶m )) )
737 msg_Warn( p_this, "couldn't set thread priority (%s:%d): %m",
747 /*****************************************************************************
748 * vlc_thread_ready: tell the parent thread we were successfully spawned
749 *****************************************************************************/
750 void __vlc_thread_ready( vlc_object_t *p_this )
752 vlc_object_signal( p_this );
755 /*****************************************************************************
756 * vlc_thread_join: wait until a thread exits, inner version
757 *****************************************************************************/
758 void __vlc_thread_join( vlc_object_t *p_this, const char * psz_file, int i_line )
760 vlc_object_internals_t *p_priv = p_this->p_internals;
762 #if defined( UNDER_CE ) || defined( WIN32 )
764 BOOL (WINAPI *OurGetThreadTimes)( HANDLE, FILETIME*, FILETIME*,
765 FILETIME*, FILETIME* );
766 FILETIME create_ft, exit_ft, kernel_ft, user_ft;
767 int64_t real_time, kernel_time, user_time;
771 ** object will close its thread handle when destroyed, duplicate it here
772 ** to be on the safe side
774 if( ! DuplicateHandle(GetCurrentProcess(),
775 p_priv->thread_id.hThread,
780 DUPLICATE_SAME_ACCESS) )
782 msg_Err( p_this, "thread_join(%u) failed at %s:%d (%s)",
783 (unsigned int)p_priv->thread_id.id,
784 psz_file, i_line, GetLastError() );
785 vlc_threads_error( p_this );
786 p_priv->b_thread = VLC_FALSE;
790 WaitForSingleObject( hThread, INFINITE );
792 msg_Dbg( p_this, "thread %u joined (%s:%d)",
793 (unsigned int)p_priv->thread_id.id,
795 #if defined( UNDER_CE )
796 hmodule = GetModuleHandle( _T("COREDLL") );
798 hmodule = GetModuleHandle( _T("KERNEL32") );
800 OurGetThreadTimes = (BOOL (WINAPI*)( HANDLE, FILETIME*, FILETIME*,
801 FILETIME*, FILETIME* ))
802 GetProcAddress( hmodule, _T("GetThreadTimes") );
804 if( OurGetThreadTimes &&
805 OurGetThreadTimes( hThread,
806 &create_ft, &exit_ft, &kernel_ft, &user_ft ) )
809 ((((int64_t)exit_ft.dwHighDateTime)<<32)| exit_ft.dwLowDateTime) -
810 ((((int64_t)create_ft.dwHighDateTime)<<32)| create_ft.dwLowDateTime);
814 ((((int64_t)kernel_ft.dwHighDateTime)<<32)|
815 kernel_ft.dwLowDateTime) / 10;
818 ((((int64_t)user_ft.dwHighDateTime)<<32)|
819 user_ft.dwLowDateTime) / 10;
821 msg_Dbg( p_this, "thread times: "
822 "real "I64Fd"m%fs, kernel "I64Fd"m%fs, user "I64Fd"m%fs",
823 real_time/60/1000000,
824 (double)((real_time%(60*1000000))/1000000.0),
825 kernel_time/60/1000000,
826 (double)((kernel_time%(60*1000000))/1000000.0),
827 user_time/60/1000000,
828 (double)((user_time%(60*1000000))/1000000.0) );
830 CloseHandle( hThread );
832 #else /* !defined(WIN32) */
836 #if defined( HAVE_KERNEL_SCHEDULER_H )
838 i_ret = (B_OK == wait_for_thread( p_priv->thread_id, &exit_value ));
840 #elif defined( LIBVLC_USE_PTHREAD )
841 i_ret = pthread_join( p_priv->thread_id, NULL );
848 msg_Err( p_this, "thread_join(%u) failed at %s:%d (%m)",
849 (unsigned int)p_priv->thread_id, psz_file, i_line );
850 vlc_threads_error( p_this );
854 msg_Dbg( p_this, "thread %u joined (%s:%d)",
855 (unsigned int)p_priv->thread_id, psz_file, i_line );
860 p_priv->b_thread = VLC_FALSE;