diff av_opts.c @ 30795:1001c606f94c

Make emulated Win32 critical sections thread safe. Earlier, cs->locked was accessed outside the mutex to get around the problem that default pthread mutexes are not recursive (ie., you cannot do a double-lock from the same thread), causing a thread-safety problem, as both detected by Helgrind and showing up in some multithreaded codecs. The ideal solution here would be to simply use recursive pthread mutexes, but there were concerns about reduced debuggability and possibly portability. Thus, instead, rewrite the critical sections to be a simple lock count (with owner) protected by a regular mutex. Whenever a thread wants to enter the critical section and lock_count is not 0, it sleeps on a special event that tells it when the critical section is available.
author sesse
date Thu, 04 Mar 2010 15:57:08 +0000
parents 321e9ea69b9f
children 203789464176
line wrap: on
line diff