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;
81 #if defined(LIBVLC_USE_PTHREAD)
82 static inline unsigned long vlc_threadid (void)
84 union { pthread_t th; unsigned long int i; } v = { };
85 v.th = pthread_self ();
90 /*****************************************************************************
91 * vlc_thread_fatal: Report an error from the threading layer
92 *****************************************************************************
93 * This is mostly meant for debugging.
94 *****************************************************************************/
95 void vlc_pthread_fatal (const char *action, int error,
96 const char *file, unsigned line)
98 fprintf (stderr, "LibVLC fatal error %s in thread %lu at %s:%u: %d\n",
99 action, vlc_threadid (), file, line, error);
102 /* Sometimes strerror_r() crashes too, so make sure we print an error
103 * message before we invoke it */
105 /* Avoid the strerror_r() prototype brain damage in glibc */
107 fprintf (stderr, " Error message: %m\n");
112 switch (sterror_r (error, buf, sizeof (buf)))
117 case ERANGE: /* should never happen */
118 msg = "unknwon (too big to display)";
121 msg = "unknown (invalid error number)";
124 fprintf (stderr, " Error message: %s\n", msg);
133 /*****************************************************************************
134 * vlc_threads_init: initialize threads system
135 *****************************************************************************
136 * This function requires lazy initialization of a global lock in order to
137 * keep the library really thread-safe. Some architectures don't support this
138 * and thus do not guarantee the complete reentrancy.
139 *****************************************************************************/
140 int __vlc_threads_init( vlc_object_t *p_this )
142 libvlc_global_data_t *p_libvlc_global = (libvlc_global_data_t *)p_this;
143 int i_ret = VLC_SUCCESS;
145 /* If we have lazy mutex initialization, use it. Otherwise, we just
146 * hope nothing wrong happens. */
147 #if defined( UNDER_CE )
148 #elif defined( WIN32 )
149 if( IsDebuggerPresent() )
151 /* SignalObjectAndWait() is problematic under a debugger */
152 b_fast_mutex = VLC_TRUE;
155 #elif defined( HAVE_KERNEL_SCHEDULER_H )
156 #elif defined( LIBVLC_USE_PTHREAD )
157 pthread_mutex_lock( &once_mutex );
160 if( i_status == VLC_THREADS_UNINITIALIZED )
162 i_status = VLC_THREADS_PENDING;
164 /* We should be safe now. Do all the initialization stuff we want. */
165 p_libvlc_global->b_ready = VLC_FALSE;
167 #if defined( UNDER_CE )
168 /* Nothing to initialize */
170 #elif defined( WIN32 )
171 /* Dynamically get the address of SignalObjectAndWait */
172 if( GetVersion() < 0x80000000 )
176 /* We are running on NT/2K/XP, we can use SignalObjectAndWait */
177 hInstLib = LoadLibrary( "kernel32" );
180 pf_SignalObjectAndWait =
181 (SIGNALOBJECTANDWAIT)GetProcAddress( hInstLib,
182 "SignalObjectAndWait" );
186 #elif defined( HAVE_KERNEL_SCHEDULER_H )
187 #elif defined( LIBVLC_USE_PTHREAD )
190 p_root = vlc_object_create( p_libvlc_global, VLC_OBJECT_GLOBAL );
196 i_status = VLC_THREADS_ERROR;
201 i_status = VLC_THREADS_READY;
204 vlc_threadvar_create( p_root, &msg_context_global_key );
208 /* Just increment the initialization count */
212 /* If we have lazy mutex initialization support, unlock the mutex;
213 * otherwize, do a naive wait loop. */
214 #if defined( UNDER_CE )
215 while( i_status == VLC_THREADS_PENDING ) msleep( THREAD_SLEEP );
216 #elif defined( WIN32 )
217 while( i_status == VLC_THREADS_PENDING ) msleep( THREAD_SLEEP );
218 #elif defined( HAVE_KERNEL_SCHEDULER_H )
219 while( i_status == VLC_THREADS_PENDING ) msleep( THREAD_SLEEP );
220 #elif defined( LIBVLC_USE_PTHREAD )
221 pthread_mutex_unlock( &once_mutex );
224 if( i_status != VLC_THREADS_READY )
232 /*****************************************************************************
233 * vlc_threads_end: stop threads system
234 *****************************************************************************
235 * FIXME: This function is far from being threadsafe.
236 *****************************************************************************/
237 int __vlc_threads_end( vlc_object_t *p_this )
240 #if defined( UNDER_CE )
241 #elif defined( WIN32 )
242 #elif defined( HAVE_KERNEL_SCHEDULER_H )
243 #elif defined( LIBVLC_USE_PTHREAD )
244 pthread_mutex_lock( &once_mutex );
247 if( i_initializations == 0 )
251 if( i_initializations == 0 )
253 i_status = VLC_THREADS_UNINITIALIZED;
254 vlc_object_destroy( p_root );
257 #if defined( UNDER_CE )
258 #elif defined( WIN32 )
259 #elif defined( HAVE_KERNEL_SCHEDULER_H )
260 #elif defined( LIBVLC_USE_PTHREAD )
261 pthread_mutex_unlock( &once_mutex );
267 /* This is not prototyped under Linux, though it exists. */
268 int pthread_mutexattr_setkind_np( pthread_mutexattr_t *attr, int kind );
271 /*****************************************************************************
272 * vlc_mutex_init: initialize a mutex
273 *****************************************************************************/
274 int __vlc_mutex_init( vlc_mutex_t *p_mutex )
276 #if defined( UNDER_CE )
277 InitializeCriticalSection( &p_mutex->csection );
280 #elif defined( WIN32 )
281 /* We use mutexes on WinNT/2K/XP because we can use the SignalObjectAndWait
282 * function and have a 100% correct vlc_cond_wait() implementation.
283 * As this function is not available on Win9x, we can use the faster
284 * CriticalSections */
285 if( pf_SignalObjectAndWait && !b_fast_mutex )
287 /* We are running on NT/2K/XP, we can use SignalObjectAndWait */
288 p_mutex->mutex = CreateMutex( 0, FALSE, 0 );
289 return ( p_mutex->mutex != NULL ? 0 : 1 );
293 p_mutex->mutex = NULL;
294 InitializeCriticalSection( &p_mutex->csection );
298 #elif defined( HAVE_KERNEL_SCHEDULER_H )
299 /* check the arguments and whether it's already been initialized */
300 if( p_mutex == NULL )
305 if( p_mutex->init == 9999 )
310 p_mutex->lock = create_sem( 1, "BeMutex" );
311 if( p_mutex->lock < B_NO_ERROR )
316 p_mutex->init = 9999;
319 #elif defined( LIBVLC_USE_PTHREAD )
322 /* Create error-checking mutex to detect problems more easily. */
323 pthread_mutexattr_t attr;
326 pthread_mutexattr_init( &attr );
327 # if defined(SYS_LINUX)
328 pthread_mutexattr_setkind_np( &attr, PTHREAD_MUTEX_ERRORCHECK_NP );
330 pthread_mutexattr_settype( &attr, PTHREAD_MUTEX_ERRORCHECK );
333 i_result = pthread_mutex_init( &p_mutex->mutex, &attr );
334 pthread_mutexattr_destroy( &attr );
338 return pthread_mutex_init( &p_mutex->mutex, NULL );
343 /*****************************************************************************
344 * vlc_mutex_init: initialize a recursive mutex (Do not use)
345 *****************************************************************************/
346 int __vlc_mutex_init_recursive( vlc_mutex_t *p_mutex )
349 /* Create mutex returns a recursive mutex */
350 p_mutex->mutex = CreateMutex( 0, FALSE, 0 );
351 return ( p_mutex->mutex != NULL ? 0 : 1 );
352 #elif defined( LIBVLC_USE_PTHREAD )
353 pthread_mutexattr_t attr;
356 pthread_mutexattr_init( &attr );
358 /* Create error-checking mutex to detect problems more easily. */
359 # if defined(SYS_LINUX)
360 pthread_mutexattr_setkind_np( &attr, PTHREAD_MUTEX_ERRORCHECK_NP );
362 pthread_mutexattr_settype( &attr, PTHREAD_MUTEX_ERRORCHECK );
365 pthread_mutexattr_settype( &attr, PTHREAD_MUTEX_RECURSIVE );
366 i_result = pthread_mutex_init( &p_mutex->mutex, &attr );
367 pthread_mutexattr_destroy( &attr );
370 # error Unimplemented!
375 /*****************************************************************************
376 * vlc_mutex_destroy: destroy a mutex, inner version
377 *****************************************************************************/
378 void __vlc_mutex_destroy( const char * psz_file, int i_line, vlc_mutex_t *p_mutex )
380 #if defined( UNDER_CE )
381 DeleteCriticalSection( &p_mutex->csection );
383 #elif defined( WIN32 )
385 CloseHandle( p_mutex->mutex );
387 DeleteCriticalSection( &p_mutex->csection );
389 #elif defined( HAVE_KERNEL_SCHEDULER_H )
390 if( p_mutex->init == 9999 )
391 delete_sem( p_mutex->lock );
395 #elif defined( LIBVLC_USE_PTHREAD )
396 int val = pthread_mutex_destroy( &p_mutex->mutex );
397 VLC_THREAD_ASSERT ("destroying mutex");
402 /*****************************************************************************
403 * vlc_cond_init: initialize a condition
404 *****************************************************************************/
405 int __vlc_cond_init( vlc_cond_t *p_condvar )
407 #if defined( UNDER_CE )
408 /* Initialize counter */
409 p_condvar->i_waiting_threads = 0;
411 /* Create an auto-reset event. */
412 p_condvar->event = CreateEvent( NULL, /* no security */
413 FALSE, /* auto-reset event */
414 FALSE, /* start non-signaled */
415 NULL ); /* unnamed */
416 return !p_condvar->event;
418 #elif defined( WIN32 )
419 /* Initialize counter */
420 p_condvar->i_waiting_threads = 0;
423 p_condvar->i_win9x_cv = i_win9x_cv;
424 p_condvar->SignalObjectAndWait = pf_SignalObjectAndWait;
426 if( (p_condvar->SignalObjectAndWait && !b_fast_mutex)
427 || p_condvar->i_win9x_cv == 0 )
429 /* Create an auto-reset event. */
430 p_condvar->event = CreateEvent( NULL, /* no security */
431 FALSE, /* auto-reset event */
432 FALSE, /* start non-signaled */
433 NULL ); /* unnamed */
435 p_condvar->semaphore = NULL;
436 return !p_condvar->event;
440 p_condvar->semaphore = CreateSemaphore( NULL, /* no security */
441 0, /* initial count */
442 0x7fffffff, /* max count */
443 NULL ); /* unnamed */
445 if( p_condvar->i_win9x_cv == 1 )
446 /* Create a manual-reset event initially signaled. */
447 p_condvar->event = CreateEvent( NULL, TRUE, TRUE, NULL );
449 /* Create a auto-reset event. */
450 p_condvar->event = CreateEvent( NULL, FALSE, FALSE, NULL );
452 InitializeCriticalSection( &p_condvar->csection );
454 return !p_condvar->semaphore || !p_condvar->event;
457 #elif defined( HAVE_KERNEL_SCHEDULER_H )
463 if( p_condvar->init == 9999 )
468 p_condvar->thread = -1;
469 p_condvar->init = 9999;
472 #elif defined( LIBVLC_USE_PTHREAD )
473 pthread_condattr_t attr;
476 ret = pthread_condattr_init (&attr);
480 # if !defined (_POSIX_CLOCK_SELECTION)
481 /* Fairly outdated POSIX support (that was defined in 2001) */
482 # define _POSIX_CLOCK_SELECTION (-1)
484 # if (_POSIX_CLOCK_SELECTION >= 0)
485 /* NOTE: This must be the same clock as the one in mtime.c */
486 pthread_condattr_setclock (&attr, CLOCK_MONOTONIC);
489 ret = pthread_cond_init (&p_condvar->cond, &attr);
490 pthread_condattr_destroy (&attr);
496 /*****************************************************************************
497 * vlc_cond_destroy: destroy a condition, inner version
498 *****************************************************************************/
499 void __vlc_cond_destroy( const char * psz_file, int i_line, vlc_cond_t *p_condvar )
501 #if defined( UNDER_CE )
502 CloseHandle( p_condvar->event );
504 #elif defined( WIN32 )
505 if( !p_condvar->semaphore )
506 CloseHandle( p_condvar->event );
509 CloseHandle( p_condvar->event );
510 CloseHandle( p_condvar->semaphore );
513 if( p_condvar->semaphore != NULL )
514 DeleteCriticalSection( &p_condvar->csection );
516 #elif defined( HAVE_KERNEL_SCHEDULER_H )
519 #elif defined( LIBVLC_USE_PTHREAD )
520 int val = pthread_cond_destroy( &p_condvar->cond );
521 VLC_THREAD_ASSERT ("destroying condition");
526 /*****************************************************************************
527 * vlc_tls_create: create a thread-local variable
528 *****************************************************************************/
529 int __vlc_threadvar_create( vlc_threadvar_t *p_tls )
533 #if defined( HAVE_KERNEL_SCHEDULER_H )
534 # error Unimplemented!
535 #elif defined( UNDER_CE ) || defined( WIN32 )
536 #elif defined( WIN32 )
537 p_tls->handle = TlsAlloc();
538 i_ret = !( p_tls->handle == 0xFFFFFFFF );
540 #elif defined( LIBVLC_USE_PTHREAD )
541 i_ret = pthread_key_create( &p_tls->handle, NULL );
546 /*****************************************************************************
547 * vlc_thread_create: create a thread, inner version
548 *****************************************************************************
549 * Note that i_priority is only taken into account on platforms supporting
550 * userland real-time priority threads.
551 *****************************************************************************/
552 int __vlc_thread_create( vlc_object_t *p_this, const char * psz_file, int i_line,
553 const char *psz_name, void * ( *func ) ( void * ),
554 int i_priority, vlc_bool_t b_wait )
557 void *p_data = (void *)p_this;
558 vlc_object_internals_t *p_priv = p_this->p_internals;
560 vlc_mutex_lock( &p_this->object_lock );
562 #if defined( WIN32 ) || defined( UNDER_CE )
564 /* When using the MSVCRT C library you have to use the _beginthreadex
565 * function instead of CreateThread, otherwise you'll end up with
566 * memory leaks and the signal functions not working (see Microsoft
567 * Knowledge Base, article 104641) */
568 #if defined( UNDER_CE )
570 HANDLE hThread = CreateThread( NULL, 0, (LPTHREAD_START_ROUTINE)func,
571 (LPVOID)p_data, CREATE_SUSPENDED,
575 uintptr_t hThread = _beginthreadex( NULL, 0,
576 (LPTHREAD_START_ROUTINE)func,
577 (void*)p_data, CREATE_SUSPENDED,
580 p_priv->thread_id.id = (DWORD)threadId;
581 p_priv->thread_id.hThread = (HANDLE)hThread;
582 ResumeThread((HANDLE)hThread);
585 i_ret = ( p_priv->thread_id.hThread ? 0 : 1 );
587 if( !i_ret && i_priority )
589 if( !SetThreadPriority(p_priv->thread_id.hThread, i_priority) )
591 msg_Warn( p_this, "couldn't set a faster priority" );
596 #elif defined( HAVE_KERNEL_SCHEDULER_H )
597 p_priv->thread_id = spawn_thread( (thread_func)func, psz_name,
598 i_priority, p_data );
599 i_ret = resume_thread( p_priv->thread_id );
601 #elif defined( LIBVLC_USE_PTHREAD )
602 i_ret = pthread_create( &p_priv->thread_id, NULL, func, p_data );
605 if( config_GetInt( p_this, "rt-priority" ) )
608 int i_error, i_policy;
609 struct sched_param param;
611 memset( ¶m, 0, sizeof(struct sched_param) );
612 if( config_GetType( p_this, "rt-offset" ) )
614 i_priority += config_GetInt( p_this, "rt-offset" );
616 if( i_priority <= 0 )
618 param.sched_priority = (-1) * i_priority;
619 i_policy = SCHED_OTHER;
623 param.sched_priority = i_priority;
626 if( (i_error = pthread_setschedparam( p_priv->thread_id,
627 i_policy, ¶m )) )
630 msg_Warn( p_this, "couldn't set thread priority (%s:%d): %m",
648 msg_Dbg( p_this, "waiting for thread completion" );
649 vlc_object_wait( p_this );
652 p_priv->b_thread = VLC_TRUE;
654 #if defined( WIN32 ) || defined( UNDER_CE )
655 msg_Dbg( p_this, "thread %u (%s) created at priority %d (%s:%d)",
656 (unsigned int)p_priv->thread_id.id, psz_name,
657 i_priority, psz_file, i_line );
659 msg_Dbg( p_this, "thread %u (%s) created at priority %d (%s:%d)",
660 (unsigned int)p_priv->thread_id, psz_name, i_priority,
665 vlc_mutex_unlock( &p_this->object_lock );
670 msg_Err( p_this, "%s thread could not be created at %s:%d (%m)",
671 psz_name, psz_file, i_line );
672 vlc_mutex_unlock( &p_this->object_lock );
678 /*****************************************************************************
679 * vlc_thread_set_priority: set the priority of the current thread when we
680 * couldn't set it in vlc_thread_create (for instance for the main thread)
681 *****************************************************************************/
682 int __vlc_thread_set_priority( vlc_object_t *p_this, const char * psz_file,
683 int i_line, int i_priority )
685 vlc_object_internals_t *p_priv = p_this->p_internals;
686 #if defined( WIN32 ) || defined( UNDER_CE )
687 if( !p_priv->thread_id.hThread )
688 p_priv->thread_id.hThread = GetCurrentThread();
689 if( !SetThreadPriority(p_priv->thread_id.hThread, i_priority) )
691 msg_Warn( p_this, "couldn't set a faster priority" );
695 #elif defined( LIBVLC_USE_PTHREAD )
697 if( config_GetInt( p_this, "rt-priority" ) > 0 )
700 int i_error, i_policy;
701 struct sched_param param;
703 memset( ¶m, 0, sizeof(struct sched_param) );
704 if( config_GetType( p_this, "rt-offset" ) )
706 i_priority += config_GetInt( p_this, "rt-offset" );
708 if( i_priority <= 0 )
710 param.sched_priority = (-1) * i_priority;
711 i_policy = SCHED_OTHER;
715 param.sched_priority = i_priority;
718 if( !p_priv->thread_id )
719 p_priv->thread_id = pthread_self();
720 if( (i_error = pthread_setschedparam( p_priv->thread_id,
721 i_policy, ¶m )) )
724 msg_Warn( p_this, "couldn't set thread priority (%s:%d): %m",
734 /*****************************************************************************
735 * vlc_thread_ready: tell the parent thread we were successfully spawned
736 *****************************************************************************/
737 void __vlc_thread_ready( vlc_object_t *p_this )
739 vlc_object_signal( p_this );
742 /*****************************************************************************
743 * vlc_thread_join: wait until a thread exits, inner version
744 *****************************************************************************/
745 void __vlc_thread_join( vlc_object_t *p_this, const char * psz_file, int i_line )
747 vlc_object_internals_t *p_priv = p_this->p_internals;
749 #if defined( UNDER_CE ) || defined( WIN32 )
751 BOOL (WINAPI *OurGetThreadTimes)( HANDLE, FILETIME*, FILETIME*,
752 FILETIME*, FILETIME* );
753 FILETIME create_ft, exit_ft, kernel_ft, user_ft;
754 int64_t real_time, kernel_time, user_time;
758 ** object will close its thread handle when destroyed, duplicate it here
759 ** to be on the safe side
761 if( ! DuplicateHandle(GetCurrentProcess(),
762 p_priv->thread_id.hThread,
767 DUPLICATE_SAME_ACCESS) )
769 msg_Err( p_this, "thread_join(%u) failed at %s:%d (%s)",
770 (unsigned int)p_priv->thread_id.id,
771 psz_file, i_line, GetLastError() );
772 p_priv->b_thread = VLC_FALSE;
776 WaitForSingleObject( hThread, INFINITE );
778 msg_Dbg( p_this, "thread %u joined (%s:%d)",
779 (unsigned int)p_priv->thread_id.id,
781 #if defined( UNDER_CE )
782 hmodule = GetModuleHandle( _T("COREDLL") );
784 hmodule = GetModuleHandle( _T("KERNEL32") );
786 OurGetThreadTimes = (BOOL (WINAPI*)( HANDLE, FILETIME*, FILETIME*,
787 FILETIME*, FILETIME* ))
788 GetProcAddress( hmodule, _T("GetThreadTimes") );
790 if( OurGetThreadTimes &&
791 OurGetThreadTimes( hThread,
792 &create_ft, &exit_ft, &kernel_ft, &user_ft ) )
795 ((((int64_t)exit_ft.dwHighDateTime)<<32)| exit_ft.dwLowDateTime) -
796 ((((int64_t)create_ft.dwHighDateTime)<<32)| create_ft.dwLowDateTime);
800 ((((int64_t)kernel_ft.dwHighDateTime)<<32)|
801 kernel_ft.dwLowDateTime) / 10;
804 ((((int64_t)user_ft.dwHighDateTime)<<32)|
805 user_ft.dwLowDateTime) / 10;
807 msg_Dbg( p_this, "thread times: "
808 "real "I64Fd"m%fs, kernel "I64Fd"m%fs, user "I64Fd"m%fs",
809 real_time/60/1000000,
810 (double)((real_time%(60*1000000))/1000000.0),
811 kernel_time/60/1000000,
812 (double)((kernel_time%(60*1000000))/1000000.0),
813 user_time/60/1000000,
814 (double)((user_time%(60*1000000))/1000000.0) );
816 CloseHandle( hThread );
818 #else /* !defined(WIN32) */
822 #if defined( HAVE_KERNEL_SCHEDULER_H )
824 i_ret = (B_OK == wait_for_thread( p_priv->thread_id, &exit_value ));
826 #elif defined( LIBVLC_USE_PTHREAD )
827 i_ret = pthread_join( p_priv->thread_id, NULL );
834 msg_Err( p_this, "thread_join(%u) failed at %s:%d (%m)",
835 (unsigned int)p_priv->thread_id, psz_file, i_line );
839 msg_Dbg( p_this, "thread %u joined (%s:%d)",
840 (unsigned int)p_priv->thread_id, psz_file, i_line );
845 p_priv->b_thread = VLC_FALSE;