return i_result;
#elif defined( WIN32 )
+ /* This creates a recursive mutex. This is OK as fast mutexes have
+ * no defined behavior in case of recursive locking. */
InitializeCriticalSection (&p_mutex->mutex);
- p_mutex->recursive = false;
return 0;
#endif
#elif defined( WIN32 )
InitializeCriticalSection( &p_mutex->mutex );
- p_mutex->owner = 0; /* the error value for GetThreadId()! */
- p_mutex->recursion = 0;
- p_mutex->recursive = true;
return 0;
#endif
VLC_THREAD_ASSERT ("locking mutex");
#elif defined( WIN32 )
- if (p_mutex->recursive)
- {
- DWORD self = GetCurrentThreadId ();
-
- if ((DWORD)InterlockedCompareExchange (&p_mutex->owner, self,
- self) == self)
- { /* We already locked this recursive mutex */
- p_mutex->recursion++;
- return;
- }
-
- /* We need to lock this recursive mutex */
- EnterCriticalSection (&p_mutex->mutex);
- self = InterlockedExchange (&p_mutex->owner, self);
- assert (self == 0); /* no previous owner */
- return;
- }
- /* Non-recursive mutex */
EnterCriticalSection (&p_mutex->mutex);
#endif
VLC_THREAD_ASSERT ("unlocking mutex");
#elif defined( WIN32 )
- if (p_mutex->recursive)
- {
- if (p_mutex->recursion != 0)
- {
- p_mutex->recursion--;
- return; /* We still own this mutex */
- }
-
- /* We release the mutex */
- InterlockedExchange (&p_mutex->owner, 0);
- /* fall through */
- }
LeaveCriticalSection (&p_mutex->mutex);
#endif
#elif defined( WIN32 )
DWORD result;
- assert (!p_mutex->recursive);
do
{
vlc_testcancel ();
#elif defined( WIN32 )
DWORD result;
- assert (!p_mutex->recursive);
do
{
vlc_testcancel ();