pulse audio sink report server is dead when doing audio track switching
Submitted by Jian Li
This issue is reproduced by switch two audio track with different sample rate repeatly, finally will report:" Error: Disconnected: Bad state"
It's from function gst_pulsering_is_dead().
The reason is two threads race condition, when switch two audio track with differnt caps, audio base will set new caps to pulsesink, then two threads will have race condition.
The first thread is gst_pulsesink_get_time(), the other is gst_audio_base_sink_setcaps(). In gst_audio_base_sink_setcaps, it will release audio ring buffer, which will finally release pulse audio stream. But in gst_pulsesink_get_time(), it will call gst_pulsering_is_dead() to check if pbuf->stream is still valid, if invalid will report server is dead.
So need to check if pa stream is still alive in gst_pulsesink_get_time().
Patch is attached.