From: Jian <Jian.Li@freescale.com>
Date: Tue, 3 Feb 2015 17:08:40 +0800
Subject: [PATCH] Need to check if pa stream is still valid

Fixed the issue that will report pulse server is dead
when doing audio track switching.
Need to check if pa stream is valid as it may be released
by caps change.

Upstream Status: Submitted
https://bugzilla.gnome.org/show_bug.cgi?id=743912

Signed-off-by: Jian <Jian.Li@freescale.com>
Signed-off-by: Lyon Wang <lyon.wang@freescale.com>
---
 ext/pulse/pulsesink.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/ext/pulse/pulsesink.c b/ext/pulse/pulsesink.c
index c88fa965b0ee..2f3bc603f447 100644
--- a/ext/pulse/pulsesink.c
+++ b/ext/pulse/pulsesink.c
@@ -2023,6 +2023,13 @@ gst_pulsesink_get_time (GstClock * clock, GstAudioBaseSink * sink)
   }
 
   pa_threaded_mainloop_lock (mainloop);
+
+  /* Need to check if pa stream is valid as it may be released by caps change*/
+  if (!pbuf->stream) {
+    pa_threaded_mainloop_unlock (mainloop);
+    return GST_CLOCK_TIME_NONE;
+  }
+
   if (gst_pulsering_is_dead (psink, pbuf, TRUE))
     goto server_dead;
 
