xbmc/xbmc — pull request #2289 by fritsch (2013-02-23 10:22:21+00:00)
Title: AE: Fix segfault after indirection patches

After the indirection patches, we don't wait unitl OpenSink() is finished. So there can be race conditions, when we remove the master stream. Basically, when removing such a stream and deleting it, it must be set to NULL - as every other check in e.g. outputrawstage won't work correctly.

The first idea to use "boolean guards" (TM) was not really smart and only made it harder to reproduce - as it helped sometimes.

Basically:
FreeStream has a streamlock, it deletes / removes the stream there, sets it to NULL. OutputRawstream has the same lock, so comes in before or afterwards.

Having a dangeling pointer, e.g. not setting m_masterstream = NULL was just bad.
A nice good morning ping from germany goes to @davilla @wsnipex @pike @ronie