From c08a23169d85b47c28ce8ded06a80b90c02ef8cc Mon Sep 17 00:00:00 2001
From: Vincent Penquerc'h <vincent.penquerch@collabora.co.uk>
Date: Mon, 17 Oct 2011 18:43:06 +0000
Subject: [PATCH] playsink: handle NULL cached caps in getcaps

https://bugzilla.gnome.org/show_bug.cgi?id=661262
---
 gst/playback/gstplaysinkconvertbin.c | 18 ++++++++++++++----
 1 file changed, 14 insertions(+), 4 deletions(-)

diff --git a/gst/playback/gstplaysinkconvertbin.c b/gst/playback/gstplaysinkconvertbin.c
index 349c0a5761..35faf4a5f2 100644
--- a/gst/playback/gstplaysinkconvertbin.c
+++ b/gst/playback/gstplaysinkconvertbin.c
@@ -357,11 +357,17 @@ gst_play_sink_convert_bin_getcaps (GstPad * pad)
     if (peer) {
       GstCaps *peer_caps = gst_pad_get_caps_reffed (peer);
       gst_object_unref (peer);
-      ret = gst_caps_union (peer_caps, self->converter_caps);
-      gst_caps_unref (peer_caps);
+      if (self->converter_caps) {
+        ret = gst_caps_union (peer_caps, self->converter_caps);
+        gst_caps_unref (peer_caps);
+      } else {
+        ret = peer_caps;
+      }
     } else {
       ret = gst_caps_ref (self->converter_caps);
     }
+  } else {
+    ret = gst_caps_new_any ();
   }
   GST_PLAY_SINK_CONVERT_BIN_UNLOCK (self);
 
@@ -389,13 +395,17 @@ gst_play_sink_convert_bin_cache_converter_caps (GstPlaySinkConvertBin * self)
 
   self->converter_caps = NULL;
 
-  if (!self->conversion_elements)
+  if (!self->conversion_elements) {
+    GST_WARNING_OBJECT (self, "No conversion elements");
     return;
+  }
 
   head = GST_ELEMENT (g_list_first (self->conversion_elements)->data);
   pad = gst_element_get_static_pad (head, "sink");
-  if (!pad)
+  if (!pad) {
+    GST_WARNING_OBJECT (self, "No sink pad found");
     return;
+  }
 
   self->converter_caps = gst_pad_get_caps_reffed (pad);
   GST_INFO_OBJECT (self, "Converter caps: %" GST_PTR_FORMAT,