drothlis/stb-tester — pull request #124 by wmanley (2014-03-27 13:34:28+00:00)
Title: stbt.py: Fix teardown hang with BlackMagic Intensity Pro

Since the port to GStreamer 1.0 the BlackMagic Intensity Pro has caused an intermittant hang during pipeline teardown (after the test script has run to completion). While it should be valid to call

source_pipeline.set_state(Gst.State.NULL)

at any time this was hanging.

It seems from the backtraces that the `GstBaseSrc` thread that was associated with `decklinksrc` was blocked calling `gst_task_join`, e.g. waiting for the BlackMagic thread to finish. In turn there was another thread (presumably the target of the join) calling into the proprietary BlackMagic blob which seemed to be just blocked on `poll()`, presumably as part of an event loop. There must be some sort of race condition in there.

Instead we shut the pipeline down more gently by first sending EOS to the source pipeline and then only after receiving EOS from our `appsink` do we precede to state NULL. This way we can be certain that the pipeline is quiescent before attempting the state change. This seems to fix the hang.

Fixes #110