]> git.sesse.net Git - ffmpeg/commit
pthread_frame: do not attempt to unlock a mutex on the wrong thread
authorwm4 <nfxjfg@googlemail.com>
Thu, 23 Mar 2017 12:18:16 +0000 (13:18 +0100)
committerwm4 <nfxjfg@googlemail.com>
Mon, 27 Mar 2017 11:21:15 +0000 (13:21 +0200)
commit9e703ae30f911d4df3f80647266e65d3b2dcf30d
tree85038571cc93f144555c1a39f8f879fd0d7a14fc
parentddef3d902f0e4cbd6be6b3e5df7ec158ce51488b
pthread_frame: do not attempt to unlock a mutex on the wrong thread

async_mutex has is used in a very strange but intentional way: it is
locked by default, and unlocked only in regions that can be run
concurrently.

If the user was calling API functions to the same context from different
threads (in a safe way), this could unintentionally unlock the mutex on
a different thread than the previous lock operation. It's not allowed by
the pthread API.

Fix this by emulating a binary semaphore using a mutex and condition
variable. (Posix semaphores are not available on all platforms.)

Tested-by: Michael Niedermayer <michael@niedermayer.cc>
Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
libavcodec/pthread_frame.c