pad-monitor: add lots of locking
authorThiago Santos <thiago.sousa.santos@collabora.com>
Wed, 24 Jul 2013 19:04:03 +0000 (16:04 -0300)
committerThiago Santos <thiago.sousa.santos@collabora.com>
Wed, 24 Jul 2013 19:16:07 +0000 (16:16 -0300)
commit4a3f06885af4dbe7aeb22b3c39443f0d61c64fe0
treea8665d3f8537fd74f98ad12d1e7a76e0b18adcde
parent48c49f5071639806731391278bdf00259c0afc11
pad-monitor: add lots of locking

When handling elements that spawn multiple threads (hardware
enc/decoders), the pad monitor has to protect its variables specially
because some checks involve iterating over internally linked pads to
add/get some data for comparison (expected events, timestamp ranges,
caps).

Aside from locking its own mutex, the pad monitor can also lock the
parent's mutex when it needs to use data from its internally linked
pads. The locking order should always be parent and then individual
pad-monitor mutexes. This should prevent deadlocks when multiple
pad-monitors from the same element start doing checks at the same time
from different threads.
validate/gst/qa/gst-qa-pad-monitor.c