gstpad: Avoid stream-dead-lock on deactivation
authorEdward Hervey <edward@centricular.com>
Tue, 16 Jan 2018 09:17:58 +0000 (10:17 +0100)
committerEdward Hervey <bilboed@bilboed.com>
Tue, 16 Jan 2018 09:29:18 +0000 (10:29 +0100)
commit31383e441315353f93941e96f08194e11b4fe0b2
tree51d8bea175448b21ae5e189d1d9c8066e4129a8d
parent6cd783b9fc150c060d2f7ac6924e9cd914a9b4ff
gstpad: Avoid stream-dead-lock on deactivation

The following case can happen when two thread try to activate and
deactivate a pad at the same time:
T1: starts to deactivate, calls pre_activate(), sets in_activation
    to TRUE and carries on
T2: starts to activate, calls pre_activate(), in_activation is TRUE
    so it waits on the GCond
T1: calls post_activate(), tries to acquire the streaming lock ..
    but can't because T2 is currently holding it

With this patch, the deadlock will no longer happen but does not
solve the problem that:
T2: will resume activation of the pad, set the pad mode to the target
   one (PUSH or PULL) and eventually the streaming lock gets released.
T1: is able to finish calling post_activate() ... but ... the pad
   wasn't deactivated (T2 was the last one to "activate" the pad.

https://bugzilla.gnome.org/show_bug.cgi?id=792341
gst/gstpad.c