OSDN Git Service

ffmpeg-extractor: Fix deadlock when stopping the reader thread
authorChristopher R. Palmer <crpalmer@gmail.com>
Mon, 31 Aug 2015 12:07:19 +0000 (08:07 -0400)
committerChristopher R. Palmer <crpalmer@gmail.com>
Mon, 31 Aug 2015 12:11:27 +0000 (08:11 -0400)
commitdc2a013b9bf296d1554b86763d052442ff591f90
tree4bcbb0e6b2d597237fc0b81faa80fe54d2aae321
parentb384c5f85561c4878e92450cde88c658d73ab1e6
ffmpeg-extractor: Fix deadlock when stopping the reader thread

You cannot hold the lock used by the reader thread when trying
to join to the reader thread!

For example, if we start and then stop the reader thread
before it gets a chance to execute, one thread will be in
stopReaderThread calling pthread_thread_join (and holding mLock).
Then the reader thread will execute and immediately block on
mLock (it gets the lock immediately on startup).

Instead, release the lock while we wait for the thread to exit
and then reacquire the lock.

Change-Id: I9247ae48586c18f4eb7a4f74e188b9d4f88824e2
extractor/FFmpegExtractor.cpp