stbt.Display.teardown doesn't hang when No Video
stbt.Display.teardown doesn't hang when No Video

When NoVideo was raised at the very beginning of the test, "teardown"
completed without error but the EOS event was never received from the
pipeline, so "on_eos" was never called, so the application didn't exit
because the GLib main loop's thread was a non-daemon thread.[1]

[1] http://docs.python.org/2/library/threading.html#thread-objects

When NoVideo was raised halfway through a test (video was initially
available but was then lost), "teardown" raised the following error
(presumably because "self.source_bin" was "None" because we were halfway
through a source restart) and the application also never exited:

    stbt-run: teardown: Sending eos
    Traceback (most recent call last):
      File "./stbt-run", line 50, in <module>
        stbt.teardown_run()
      File "/home/stb-tester/stb-tester/stbt.py", line 648, in teardown_run
        _display.teardown()
      File "/home/stb-tester/stb-tester/stbt.py", line 858, in teardown
        gst.element_unlink_many(self.source_bin, self.sink_bin)
    TypeError: argument must be a GstElement

This commit fixes both cases, by remembering if NoVideo was raised. We
mark the GLib main loop's thread as a daemon thread, and (if there *is*
video) we explicitly wait for the thread to complete (with a timeout
just in case anything unforeseen goes wrong).

martynjarvis/stb-tester,martynjarvis/stb-tester,stb-tester/stb-tester,stb-tester/stb-tester,LewisHaley/stb-tester,LewisHaley/stb-tester,wmanley/stb-tester,martynjarvis/stb-tester,stb-tester/stb-tester,martynjarvis/stb-tester,LewisHaley/stb-tester,LewisHaley/stb-tester,wmanley/stb-tester,wmanley/stb-tester,LewisHaley/stb-tester,martynjarvis/stb-tester,stb-tester/stb-tester,martynjarvis/stb-tester,wmanley/stb-tester,martynjarvis/stb-tester,LewisHaley/stb-tester,wmanley/stb-tester,LewisHaley/stb-tester