changeset 9108:19a9f8902557 9-b69

8090033: FX application hangs on exit when media gets stuck Reviewed-by: kcr, almatvee
author stayer
date Sun, 14 Jun 2015 19:08:48 +0300
parents 464b8efa2404
children 0013c4cbef9f 2970d02fb978
files modules/media/src/main/native/gstreamer/gstreamer-lite/gstreamer/plugins/elements/gstqueue.c
diffstat 1 files changed, 32 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/modules/media/src/main/native/gstreamer/gstreamer-lite/gstreamer/plugins/elements/gstqueue.c	Fri Jun 12 22:08:33 2015 +0300
+++ b/modules/media/src/main/native/gstreamer/gstreamer-lite/gstreamer/plugins/elements/gstqueue.c	Sun Jun 14 19:08:48 2015 +0300
@@ -216,6 +216,10 @@
 static gboolean gst_queue_is_empty (GstQueue * queue);
 static gboolean gst_queue_is_filled (GstQueue * queue);
 
+#ifdef GSTREAMER_LITE
+static GstStateChangeReturn gst_queue_change_state (GstElement *element, GstStateChange transition);
+#endif
+
 #define GST_TYPE_QUEUE_LEAKY (queue_leaky_get_type ())
 
 static GType
@@ -374,6 +378,10 @@
 
   gobject_class->finalize = gst_queue_finalize;
 
+#ifdef GSTREAMER_LITE
+  GST_ELEMENT_CLASS (klass)->change_state = GST_DEBUG_FUNCPTR(gst_queue_change_state);
+#endif
+
   /* Registering debug symbols for function pointers */
   GST_DEBUG_REGISTER_FUNCPTR (gst_queue_chain);
   GST_DEBUG_REGISTER_FUNCPTR (gst_queue_sink_activate_push);
@@ -1581,3 +1589,27 @@
 
   GST_QUEUE_MUTEX_UNLOCK (queue);
 }
+
+#ifdef GSTREAMER_LITE
+static GstStateChangeReturn gst_queue_change_state (GstElement *element, GstStateChange transition)
+{
+    GstQueue *queue = GST_QUEUE(element);
+    GstStateChangeReturn ret = GST_ELEMENT_CLASS (parent_class)->change_state (element, transition);
+
+    if (ret == GST_STATE_CHANGE_FAILURE)
+        return ret;
+
+    switch (transition)
+    {
+        case GST_STATE_CHANGE_READY_TO_NULL:
+            GST_QUEUE_MUTEX_LOCK (queue);
+            queue->srcresult = GST_FLOW_WRONG_STATE; // make sure we stop _loop task
+            g_cond_signal (queue->item_add);
+            GST_QUEUE_MUTEX_UNLOCK (queue);
+            break;
+        default:
+            break;
+    }
+    return ret;
+}
+#endif