omxvideodec: increase the minimum number of allocated buffers
authorGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>
Mon, 3 Jul 2017 14:33:06 +0000 (16:33 +0200)
committerNicolas Dufresne <nicolas.dufresne@collabora.com>
Mon, 3 Jul 2017 15:05:24 +0000 (11:05 -0400)
Ensure that enough buffers are allocated by adding up component's own
minimal plus the number of buffers requested by downstream.
This should prevent buffers starvation problem if downstream elements
are holding some of the buffers they required.

Also simplify the check on the maximum on buffers. What we actually care
about is to make sure the pool can hold the minimum of required buffers.

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

omx/gstomxvideodec.c

index 1b90caa..0f72c9c 100644 (file)
@@ -578,11 +578,11 @@ gst_omx_video_dec_allocate_output_buffers (GstOMXVideoDec * self)
       goto done;
     }
 
-    /* Need at least 2 buffers for anything meaningful */
-    min = MAX (MAX (min, port->port_def.nBufferCountMin), 4);
+    /* Need at least 4 buffers for anything meaningful */
+    min = MAX (min + port->port_def.nBufferCountMin, 4);
     if (max == 0) {
       max = min;
-    } else if (max < port->port_def.nBufferCountMin || max < 2) {
+    } else if (max < min) {
       /* Can't use pool because can't have enough buffers */
       gst_caps_replace (&caps, NULL);
     } else {