* ./src/misc/darwin_specific.c, ./src/misc/extras.c: moved our custom
[vlc.git] / include / vlc_threads.h
1 /*****************************************************************************
2  * threads.h : threads implementation for the VideoLAN client
3  * This header provides a portable threads implementation.
4  *****************************************************************************
5  * Copyright (C) 1999, 2000 VideoLAN
6  * $Id: vlc_threads.h,v 1.4 2002/07/05 11:18:56 sam Exp $
7  *
8  * Authors: Jean-Marc Dressler <polux@via.ecp.fr>
9  *          Samuel Hocevar <sam@via.ecp.fr>
10  *          Gildas Bazin <gbazin@netcourrier.com>
11  *
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.
16  * 
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.
21  *
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., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
25  *****************************************************************************/
26
27 #include <stdio.h>
28
29 #if defined(GPROF) || defined(DEBUG)
30 #   include <sys/time.h>
31 #endif
32
33 #if defined( PTH_INIT_IN_PTH_H )                                  /* GNU Pth */
34 #   include <pth.h>
35
36 #elif defined( ST_INIT_IN_ST_H )                            /* State threads */
37 #   include <st.h>
38
39 #elif defined( WIN32 )                                          /* Win32 API */
40 #   include <process.h>
41
42 #elif defined( PTHREAD_COND_T_IN_PTHREAD_H )  /* pthreads (like Linux & BSD) */
43 #   include <pthread.h>
44 #   ifdef DEBUG
45         /* Needed for pthread_cond_timedwait */
46 #       include <errno.h>
47 #   endif
48     /* This is not prototyped under Linux, though it exists. */
49     int pthread_mutexattr_setkind_np( pthread_mutexattr_t *attr, int kind );
50
51 #elif defined( HAVE_CTHREADS_H )                                  /* GNUMach */
52 #   include <cthreads.h>
53
54 #elif defined( HAVE_KERNEL_SCHEDULER_H )                             /* BeOS */
55 #   include <kernel/OS.h>
56 #   include <kernel/scheduler.h>
57 #   include <byteorder.h>
58
59 #else
60 #   error no threads available on your system !
61
62 #endif
63
64 /*****************************************************************************
65  * Constants
66  *****************************************************************************
67  * These constants are used by all threads in *_CreateThread() and
68  * *_DestroyThreads() functions. Since those calls are non-blocking, an integer
69  * value is used as a shared flag to represent the status of the thread.
70  *****************************************************************************/
71
72 /* Void status - this value can be used to make sure no operation is currently
73  * in progress on the concerned thread in an array of recorded threads */
74 #define THREAD_NOP          0                            /* nothing happened */
75
76 /* Creation status */
77 #define THREAD_CREATE       10                     /* thread is initializing */
78 #define THREAD_START        11                          /* thread has forked */
79 #define THREAD_READY        19                            /* thread is ready */
80
81 /* Destructions status */
82 #define THREAD_DESTROY      20            /* destruction order has been sent */
83 #define THREAD_END          21        /* destruction order has been received */
84 #define THREAD_OVER         29             /* thread does not exist any more */
85
86 /* Error status */
87 #define THREAD_ERROR        30                           /* an error occured */
88 #define THREAD_FATAL        31  /* an fatal error occured - program must end */
89
90 /*****************************************************************************
91  * Type definitions
92  *****************************************************************************/
93
94 #if defined( PTH_INIT_IN_PTH_H )
95 typedef pth_t            vlc_thread_t;
96 typedef pth_mutex_t      vlc_mutex_t;
97 typedef pth_cond_t       vlc_cond_t;
98
99 #elif defined( ST_INIT_IN_ST_H )
100 typedef st_thread_t *    vlc_thread_t;
101 typedef st_mutex_t *     vlc_mutex_t;
102 typedef st_cond_t *      vlc_cond_t;
103
104 #elif defined( WIN32 )
105 typedef HANDLE vlc_thread_t;
106 typedef BOOL (WINAPI *SIGNALOBJECTANDWAIT) ( HANDLE, HANDLE, DWORD, BOOL );
107 typedef unsigned (__stdcall *PTHREAD_START) (void *);
108
109 typedef struct
110 {
111     /* WinNT/2K/XP implementation */
112     HANDLE              mutex;
113     /* Win95/98/ME implementation */
114     CRITICAL_SECTION    csection;
115 } vlc_mutex_t;
116
117 typedef struct
118 {
119     int                 i_waiting_threads;
120     /* WinNT/2K/XP implementation */
121     HANDLE              semaphore;
122     HANDLE              signal;
123     vlc_bool_t          b_broadcast;
124     SIGNALOBJECTANDWAIT SignalObjectAndWait;
125     /* Win95/98/ME implementation */
126     HANDLE              p_events[2];
127 } vlc_cond_t;
128
129 #elif defined( PTHREAD_COND_T_IN_PTHREAD_H )
130 typedef pthread_t        vlc_thread_t;
131 typedef pthread_mutex_t  vlc_mutex_t;
132 typedef pthread_cond_t   vlc_cond_t;
133
134 #elif defined( HAVE_CTHREADS_H )
135 typedef cthread_t        vlc_thread_t;
136
137 /* Those structs are the ones defined in /include/cthreads.h but we need
138  * to handle (&foo) where foo is a (mutex_t) while they handle (foo) where
139  * foo is a (mutex_t*) */
140 typedef struct
141 {
142     spin_lock_t held;
143     spin_lock_t lock;
144     char *name;
145     struct cthread_queue queue;
146 } vlc_mutex_t;
147
148 typedef struct
149 {
150     spin_lock_t lock;
151     struct cthread_queue queue;
152     char *name;
153     struct cond_imp *implications;
154 } vlc_cond_t;
155
156 #elif defined( HAVE_KERNEL_SCHEDULER_H )
157 /* This is the BeOS implementation of the vlc threads, note that the mutex is
158  * not a real mutex and the cond_var is not like a pthread cond_var but it is
159  * enough for what wee need */
160
161 typedef thread_id vlc_thread_t;
162
163 typedef struct
164 {
165     int32           init;
166     sem_id          lock;
167 } vlc_mutex_t;
168
169 typedef struct
170 {
171     int32           init;
172     thread_id       thread;
173 } vlc_cond_t;
174
175 #endif
176
177 /*****************************************************************************
178  * Function definitions
179  *****************************************************************************/
180 VLC_EXPORT( int,  __vlc_threads_init,  ( vlc_object_t * ) );
181 VLC_EXPORT( int,    vlc_threads_end,   ( void ) );
182 VLC_EXPORT( int,  __vlc_mutex_init,    ( vlc_object_t *, vlc_mutex_t * ) );
183 VLC_EXPORT( int,  __vlc_mutex_destroy, ( char *, int, vlc_mutex_t * ) );
184 VLC_EXPORT( int,  __vlc_cond_init,     ( vlc_object_t *, vlc_cond_t * ) );
185 VLC_EXPORT( int,  __vlc_cond_destroy,  ( char *, int, vlc_cond_t * ) );
186 VLC_EXPORT( int,  __vlc_thread_create, ( vlc_object_t *, char *, int, char *, void * ( * ) ( void * ), vlc_bool_t ) );
187 VLC_EXPORT( void, __vlc_thread_ready,  ( vlc_object_t * ) );
188 VLC_EXPORT( void, __vlc_thread_join,   ( vlc_object_t *, char *, int ) );
189
190 /*****************************************************************************
191  * vlc_threads_init: initialize threads system
192  *****************************************************************************/
193 #define vlc_threads_init( P_THIS )                                          \
194     __vlc_threads_init( CAST_TO_VLC_OBJECT(P_THIS) )
195
196 /*****************************************************************************
197  * vlc_mutex_init: initialize a mutex
198  *****************************************************************************/
199 #define vlc_mutex_init( P_THIS, P_MUTEX )                                   \
200     __vlc_mutex_init( CAST_TO_VLC_OBJECT(P_THIS), P_MUTEX )
201
202 /*****************************************************************************
203  * vlc_mutex_lock: lock a mutex
204  *****************************************************************************/
205 #ifdef DEBUG
206 #   define vlc_mutex_lock( P_MUTEX )                                        \
207         __vlc_mutex_lock( __FILE__, __LINE__, P_MUTEX )
208 #else
209 #   define vlc_mutex_lock( P_MUTEX )                                        \
210         __vlc_mutex_lock( "(unknown)", 0, P_MUTEX )
211 #endif
212
213 static inline int __vlc_mutex_lock( char * psz_file, int i_line,
214                                     vlc_mutex_t *p_mutex )
215 {
216 #if defined( PTH_INIT_IN_PTH_H )
217     return pth_mutex_acquire( p_mutex, TRUE, NULL );
218
219 #elif defined( ST_INIT_IN_ST_H )
220     return st_mutex_lock( *p_mutex );
221
222 #elif defined( WIN32 )
223     if( p_mutex->mutex )
224     {
225         WaitForSingleObject( p_mutex->mutex, INFINITE );
226     }
227     else
228     {
229         EnterCriticalSection( &p_mutex->csection );
230     }
231     return 0;
232
233 #elif defined( PTHREAD_COND_T_IN_PTHREAD_H )
234     int i_return = pthread_mutex_lock( p_mutex );
235     if( i_return )
236     {
237 //        msg_Err( "thread %d: mutex_lock failed at %s:%d (%s)",
238 //                 pthread_self(), psz_file, i_line, strerror(i_return) );
239     }
240     return i_return;
241
242 #elif defined( HAVE_CTHREADS_H )
243     mutex_lock( p_mutex );
244     return 0;
245
246 #elif defined( HAVE_KERNEL_SCHEDULER_H )
247     status_t err;
248
249     if( !p_mutex )
250     {
251         return B_BAD_VALUE;
252     }
253
254     if( p_mutex->init < 2000 )
255     {
256         return B_NO_INIT;
257     }
258
259     err = acquire_sem( p_mutex->lock );
260     return err;
261
262 #endif
263 }
264
265 /*****************************************************************************
266  * vlc_mutex_unlock: unlock a mutex
267  *****************************************************************************/
268 #ifdef DEBUG
269 #   define vlc_mutex_unlock( P_MUTEX )                                      \
270         __vlc_mutex_unlock( __FILE__, __LINE__, P_MUTEX )
271 #else
272 #   define vlc_mutex_unlock( P_MUTEX )                                      \
273         __vlc_mutex_unlock( "(unknown)", 0, P_MUTEX )
274 #endif
275
276 static inline int __vlc_mutex_unlock( char * psz_file, int i_line,
277                                       vlc_mutex_t *p_mutex )
278 {
279 #if defined( PTH_INIT_IN_PTH_H )
280     return pth_mutex_release( p_mutex );
281
282 #elif defined( ST_INIT_IN_ST_H )
283     return st_mutex_unlock( *p_mutex );
284
285 #elif defined( WIN32 )
286     if( p_mutex->mutex )
287     {
288         ReleaseMutex( p_mutex->mutex );
289     }
290     else
291     {
292         LeaveCriticalSection( &p_mutex->csection );
293     }
294     return 0;
295
296 #elif defined( PTHREAD_COND_T_IN_PTHREAD_H )
297     int i_return = pthread_mutex_unlock( p_mutex );
298     if( i_return )
299     {
300 //        msg_Err( "thread %d: mutex_unlock failed at %s:%d (%s)",
301 //                 pthread_self(), psz_file, i_line, strerror(i_return) );
302     }
303     return i_return;
304
305 #elif defined( HAVE_CTHREADS_H )
306     mutex_unlock( p_mutex );
307     return 0;
308
309 #elif defined( HAVE_KERNEL_SCHEDULER_H )
310     if( !p_mutex)
311     {
312         return B_BAD_VALUE;
313     }
314
315     if( p_mutex->init < 2000 )
316     {
317         return B_NO_INIT;
318     }
319
320     release_sem( p_mutex->lock );
321     return B_OK;
322
323 #endif
324 }
325
326 /*****************************************************************************
327  * vlc_mutex_destroy: destroy a mutex
328  *****************************************************************************/
329 #ifdef DEBUG
330 #   define vlc_mutex_destroy( P_MUTEX )                                     \
331         __vlc_mutex_destroy( __FILE__, __LINE__, P_MUTEX )
332 #else
333 #   define vlc_mutex_destroy( P_MUTEX )                                     \
334         __vlc_mutex_destroy( "(unknown)", 0, P_MUTEX )
335 #endif
336
337 /*****************************************************************************
338  * vlc_cond_init: initialize a condition
339  *****************************************************************************/
340 #define vlc_cond_init( P_THIS, P_COND )                                   \
341     __vlc_cond_init( CAST_TO_VLC_OBJECT(P_THIS), P_COND )
342
343 /*****************************************************************************
344  * vlc_cond_signal: start a thread on condition completion
345  *****************************************************************************/
346 static inline int vlc_cond_signal( vlc_cond_t *p_condvar )
347 {
348 #if defined( PTH_INIT_IN_PTH_H )
349     return pth_cond_notify( p_condvar, FALSE );
350
351 #elif defined( ST_INIT_IN_ST_H )
352     return st_cond_signal( *p_condvar );
353
354 #elif defined( WIN32 )
355     /* Release one waiting thread if one is available. */
356     /* For this trick to work properly, the vlc_cond_signal must be surrounded
357      * by a mutex. This will prevent another thread from stealing the signal */
358     if( p_condvar->i_waiting_threads )
359     {
360         if( p_condvar->signal )
361         {
362             ReleaseSemaphore( p_condvar->semaphore, 1, 0 );
363         }
364         else
365         {
366             SetEvent( p_condvar->p_events[0/*signal*/] );
367         }
368     }
369     return 0;
370
371 #elif defined( PTHREAD_COND_T_IN_PTHREAD_H )
372     return pthread_cond_signal( p_condvar );
373
374 #elif defined( HAVE_CTHREADS_H )
375     /* condition_signal() */
376     if ( p_condvar->queue.head || p_condvar->implications )
377     {
378         cond_signal( (condition_t)p_condvar );
379     }
380     return 0;
381
382 #elif defined( HAVE_KERNEL_SCHEDULER_H )
383     if( !p_condvar )
384     {
385         return B_BAD_VALUE;
386     }
387
388     if( p_condvar->init < 2000 )
389     {
390         return B_NO_INIT;
391     }
392
393     while( p_condvar->thread != -1 )
394     {
395         thread_info info;
396         if( get_thread_info(p_condvar->thread, &info) == B_BAD_VALUE )
397         {
398             return 0;
399         }
400
401         if( info.state != B_THREAD_SUSPENDED )
402         {
403             /* The  waiting thread is not suspended so it could
404              * have been interrupted beetwen the unlock and the
405              * suspend_thread line. That is why we sleep a little
406              * before retesting p_condver->thread. */
407             snooze( 10000 );
408         }
409         else
410         {
411             /* Ok, we have to wake up that thread */
412             resume_thread( p_condvar->thread );
413             return 0;
414         }
415     }
416     return 0;
417
418 #endif
419 }
420
421 /*****************************************************************************
422  * vlc_cond_broadcast: start all threads waiting on condition completion
423  *****************************************************************************/
424 /*
425  * FIXME FIXME FIXME FIXME FIXME FIXME FIXME FIXME FIXME FIXME FIXME FIXME
426  * Only works with pthreads, you need to adapt it for others
427  * FIXME FIXME FIXME FIXME FIXME FIXME FIXME FIXME FIXME FIXME FIXME FIXME
428  */
429 static inline int vlc_cond_broadcast( vlc_cond_t *p_condvar )
430 {
431 #if defined( PTH_INIT_IN_PTH_H )
432     return pth_cond_notify( p_condvar, FALSE );
433
434 #elif defined( ST_INIT_IN_ST_H )
435     return st_cond_broadcast( p_condvar );
436
437 #elif defined( WIN32 )
438     /* Release all waiting threads. */
439     if( p_condvar->i_waiting_threads )
440     {
441         if( p_condvar->signal )
442         {
443             p_condvar->b_broadcast = 1;
444             /* This call is atomic */
445             ReleaseSemaphore( p_condvar->semaphore,
446                               p_condvar->i_waiting_threads, 0 );
447             /* Wait for all threads to get the semaphore */
448             WaitForSingleObject( p_condvar->signal, INFINITE );
449             p_condvar->b_broadcast = 0;
450         }
451         else
452         {
453             SetEvent( p_condvar->p_events[1/*broadcast*/] );
454         }
455     }
456     return 0;
457
458 #elif defined( PTHREAD_COND_T_IN_PTHREAD_H )
459     return pthread_cond_broadcast( p_condvar );
460
461 #elif defined( HAVE_CTHREADS_H )
462     /* condition_signal() */
463     if ( p_condvar->queue.head || p_condvar->implications )
464     {
465         cond_signal( (condition_t)p_condvar );
466     }
467     return 0;
468
469 #elif defined( HAVE_KERNEL_SCHEDULER_H )
470     if( !p_condvar )
471     {
472         return B_BAD_VALUE;
473     }
474
475     if( p_condvar->init < 2000 )
476     {
477         return B_NO_INIT;
478     }
479
480     while( p_condvar->thread != -1 )
481     {
482         thread_info info;
483         if( get_thread_info(p_condvar->thread, &info) == B_BAD_VALUE )
484         {
485             return 0;
486         }
487
488         if( info.state != B_THREAD_SUSPENDED )
489         {
490             /* The  waiting thread is not suspended so it could
491              * have been interrupted beetwen the unlock and the
492              * suspend_thread line. That is why we sleep a little
493              * before retesting p_condver->thread. */
494             snooze( 10000 );
495         }
496         else
497         {
498             /* Ok, we have to wake up that thread */
499             resume_thread( p_condvar->thread );
500             return 0;
501         }
502     }
503     return 0;
504
505 #endif
506 }
507
508 /*****************************************************************************
509  * vlc_cond_wait: wait until condition completion
510  *****************************************************************************/
511 #ifdef DEBUG
512 #   define vlc_cond_wait( P_COND, P_MUTEX )                                   \
513         __vlc_cond_wait( __FILE__, __LINE__, P_COND, P_MUTEX  )
514 #else
515 #   define vlc_cond_wait( P_COND, P_MUTEX )                                   \
516         __vlc_cond_wait( "(unknown)", 0, P_COND, P_MUTEX )
517 #endif
518
519 static inline int __vlc_cond_wait( char * psz_file, int i_line,
520                                    vlc_cond_t *p_condvar, vlc_mutex_t *p_mutex )
521 {
522 #if defined( PTH_INIT_IN_PTH_H )
523     return pth_cond_await( p_condvar, p_mutex, NULL );
524
525 #elif defined( ST_INIT_IN_ST_H )
526     int i_ret;
527
528     st_mutex_unlock( *p_mutex );
529     i_ret = st_cond_wait( *p_condvar );
530     st_mutex_lock( *p_mutex );
531
532     return i_ret;
533
534 #elif defined( WIN32 )
535     /* Increase our wait count */
536     p_condvar->i_waiting_threads++;
537
538     if( p_condvar->signal )
539     {
540         /* It is only possible to atomically release the mutex and initiate the
541          * waiting on WinNT/2K/XP. Win9x doesn't have SignalObjectAndWait(). */
542         p_condvar->SignalObjectAndWait( p_mutex->mutex, p_condvar->semaphore,
543                                         INFINITE, FALSE );
544         /* XXX: we should protect i_waiting_threads with a mutex, but
545          * is it really worth it ? */
546         p_condvar->i_waiting_threads--;
547
548         if( p_condvar->b_broadcast
549              && p_condvar->i_waiting_threads == 0 )
550         {
551             p_condvar->SignalObjectAndWait( p_condvar->signal, p_mutex->mutex,
552                                             INFINITE, FALSE );
553         }
554         else
555         {
556             /* Just take back the lock */
557             WaitForSingleObject( p_mutex->mutex, INFINITE );
558         }
559         return 0;
560     }
561     else
562     {
563         int i_ret;
564
565         /* Release the mutex, wait, and reacquire. */
566         LeaveCriticalSection( &p_mutex->csection );
567         i_ret = WaitForMultipleObjects( 2, p_condvar->p_events,
568                                         FALSE, INFINITE );
569         EnterCriticalSection( &p_mutex->csection );
570
571         /* Decrease our wait count */
572         p_condvar->i_waiting_threads--;
573
574         /* If we are the last waiter and it was a broadcast signal, reset
575          * the broadcast event. */
576         if( i_ret == WAIT_OBJECT_0 + 1/*broadcast*/
577              && p_condvar->i_waiting_threads == 0 )
578         {
579             ResetEvent( p_condvar->p_events[1/*broadcast*/] );
580         }
581
582         return( i_ret == WAIT_FAILED );
583     }
584
585 #elif defined( PTHREAD_COND_T_IN_PTHREAD_H )
586
587 #   ifdef DEBUG
588     /* In debug mode, timeout */
589     struct timeval now;
590     struct timespec timeout;
591     int    i_result;
592
593     for( ; ; )
594     {
595         gettimeofday( &now, NULL );
596         timeout.tv_sec = now.tv_sec + THREAD_COND_TIMEOUT;
597         timeout.tv_nsec = now.tv_usec * 1000;
598
599         i_result = pthread_cond_timedwait( p_condvar, p_mutex, &timeout );
600
601         if( i_result == ETIMEDOUT )
602         {
603 //X            msg_Warn( "thread %d: possible deadlock detected "
604 //X                      "in cond_wait at %s:%d (%s)", pthread_self(),
605 //X                      psz_file, i_line, strerror(i_result) );
606             continue;
607         }
608
609         if( i_result )
610         {
611 //X            msg_Err( "thread %d: cond_wait failed at %s:%d (%s)",
612 //X                     pthread_self(), psz_file, i_line, strerror(i_result) );
613         }
614         return( i_result );
615     }
616 #   else
617     return pthread_cond_wait( p_condvar, p_mutex );
618 #   endif
619
620 #elif defined( HAVE_CTHREADS_H )
621     condition_wait( (condition_t)p_condvar, (mutex_t)p_mutex );
622     return 0;
623
624 #elif defined( HAVE_KERNEL_SCHEDULER_H )
625     if( !p_condvar )
626     {
627         return B_BAD_VALUE;
628     }
629
630     if( !p_mutex )
631     {
632         return B_BAD_VALUE;
633     }
634
635     if( p_condvar->init < 2000 )
636     {
637         return B_NO_INIT;
638     }
639
640     /* The p_condvar->thread var is initialized before the unlock because
641      * it enables to identify when the thread is interrupted beetwen the
642      * unlock line and the suspend_thread line */
643     p_condvar->thread = find_thread( NULL );
644     vlc_mutex_unlock( p_mutex );
645     suspend_thread( p_condvar->thread );
646     p_condvar->thread = -1;
647
648     vlc_mutex_lock( p_mutex );
649     return 0;
650
651 #endif
652 }
653
654 /*****************************************************************************
655  * vlc_cond_destroy: destroy a condition
656  *****************************************************************************/
657 #ifdef DEBUG
658 #   define vlc_cond_destroy( P_COND )                                       \
659         __vlc_cond_destroy( __FILE__, __LINE__, P_COND )
660 #else
661 #   define vlc_cond_destroy( P_COND )                                       \
662         __vlc_cond_destroy( "(unknown)", 0, P_COND )
663 #endif
664
665 /*****************************************************************************
666  * vlc_thread_create: create a thread
667  *****************************************************************************/
668 #   define vlc_thread_create( P_THIS, PSZ_NAME, FUNC, WAIT )                \
669         __vlc_thread_create( CAST_TO_VLC_OBJECT(P_THIS), __FILE__, __LINE__, PSZ_NAME, (void * ( * ) ( void * ))FUNC, WAIT )
670
671 /*****************************************************************************
672  * vlc_thread_ready: tell the parent thread we were successfully spawned
673  *****************************************************************************/
674 #   define vlc_thread_ready( P_THIS )                                       \
675         __vlc_thread_ready( CAST_TO_VLC_OBJECT(P_THIS) )
676
677 /*****************************************************************************
678  * vlc_thread_join: wait until a thread exits
679  *****************************************************************************/
680 #ifdef DEBUG
681 #   define vlc_thread_join( P_THIS )                                        \
682         __vlc_thread_join( CAST_TO_VLC_OBJECT(P_THIS), __FILE__, __LINE__ ) 
683 #else
684 #   define vlc_thread_join( P_THIS )                                        \
685         __vlc_thread_join( CAST_TO_VLC_OBJECT(P_THIS), "(unknown)", 0 ) 
686 #endif