omxvideodec: Implement pipeline draining to support adaptive scenarios
authorJosep Torra <n770galaxy@gmail.com>
Mon, 10 Mar 2014 16:43:50 +0000 (17:43 +0100)
committerJulien Isorce <julien.isorce@collabora.co.uk>
Fri, 28 Mar 2014 11:40:20 +0000 (11:40 +0000)
When draining due a format change also drain
the pipeline to reclaim back all buffers.

https://bugzilla.gnome.org/show_bug.cgi?id=726107

examples/egl/testegl.c
omx/gstomxvideodec.c

index a8d61ca..73d4374 100644 (file)
@@ -1275,7 +1275,8 @@ query_cb (GstPad * pad, GstPadProbeInfo * info, gpointer user_data)
   GstQuery *query = GST_PAD_PROBE_INFO_QUERY (info);
 
   switch (GST_QUERY_TYPE (query)) {
-    case GST_QUERY_ALLOCATION:{
+    case GST_QUERY_ALLOCATION:
+    {
       GstBufferPool *pool;
       GstStructure *config;
       GstCaps *caps;
@@ -1378,8 +1379,13 @@ query_cb (GstPad * pad, GstPadProbeInfo * info, gpointer user_data)
 
       GST_DEBUG ("done alocation");
       return GST_PAD_PROBE_OK;
+      break;
     }
+    case GST_QUERY_DRAIN:
+    {
+      flush_internal (state);
       break;
+    }
     default:
       break;
   }
index 682ac8f..357e236 100644 (file)
@@ -1445,6 +1445,10 @@ eos:
   {
     g_mutex_lock (&self->drain_lock);
     if (self->draining) {
+      /* Drain the pipeline to reclaim all memories back to the pool */
+      gst_pad_peer_query (GST_VIDEO_DECODER_SRC_PAD (self),
+          gst_query_new_drain ());
+
       GST_DEBUG_OBJECT (self, "Drained");
       self->draining = FALSE;
       g_cond_broadcast (&self->drain_cond);
@@ -1759,15 +1763,9 @@ gst_omx_video_dec_set_format (GstVideoDecoder * decoder,
     GST_DEBUG_OBJECT (self, "Need to disable and drain decoder");
 
     gst_omx_video_dec_drain (self, FALSE);
+    gst_omx_video_dec_flush (decoder);
     gst_omx_port_set_flushing (out_port, 5 * GST_SECOND, TRUE);
 
-    /* Wait until the srcpad loop is finished,
-     * unlock GST_VIDEO_DECODER_STREAM_LOCK to prevent deadlocks
-     * caused by using this lock from inside the loop function */
-    GST_VIDEO_DECODER_STREAM_UNLOCK (self);
-    gst_pad_stop_task (GST_VIDEO_DECODER_SRC_PAD (decoder));
-    GST_VIDEO_DECODER_STREAM_LOCK (self);
-
     if (klass->cdata.hacks & GST_OMX_HACK_NO_COMPONENT_RECONFIGURE) {
       GST_VIDEO_DECODER_STREAM_UNLOCK (self);
       gst_omx_video_dec_stop (GST_VIDEO_DECODER (self));
@@ -1929,13 +1927,7 @@ gst_omx_video_dec_set_format (GstVideoDecoder * decoder,
     return FALSE;
   }
 
-  /* Start the srcpad loop again */
-  GST_DEBUG_OBJECT (self, "Starting task again");
-
   self->downstream_flow_ret = GST_FLOW_OK;
-  gst_pad_start_task (GST_VIDEO_DECODER_SRC_PAD (self),
-      (GstTaskFunction) gst_omx_video_dec_loop, decoder, NULL);
-
   return TRUE;
 }