summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorWim Taymans <wim.taymans@collabora.co.uk>2012-08-10 11:45:38 +0200
committerWim Taymans <wim.taymans@collabora.co.uk>2012-08-10 12:13:57 +0200
commitda4884a8341fa32ed4a31bb939e286f6d024af0a (patch)
treec8fb1f8d7afd2d360083ebd92e5feb83df97149f /sys
parent0dd2766d834e47f1a410630da106e08f217e7b2e (diff)
x11: don't block in buffer acquire
Don't ever block when acquiring a buffer from the bufferpool in the fallback mode. If we block, we might deadlock when going to PAUSED because we never unlock when going to paused. The acquire can block when there are no more buffers in the pool, this is a sign that the pool is too small. Since we are the only ones using the pool in the fallback case and because we scale the buffer, someone else must be using our pool as well and is doing something bad.
Diffstat (limited to 'sys')
-rw-r--r--sys/ximage/ximagesink.c12
-rw-r--r--sys/xvimage/xvimagesink.c12
2 files changed, 16 insertions, 8 deletions
diff --git a/sys/ximage/ximagesink.c b/sys/ximage/ximagesink.c
index 6fa3a35e6..1540d962d 100644
--- a/sys/ximage/ximagesink.c
+++ b/sys/ximage/ximagesink.c
@@ -1312,6 +1312,7 @@ gst_ximagesink_show_frame (GstVideoSink * vsink, GstBuffer * buf)
res = GST_FLOW_OK;
} else {
GstVideoFrame src, dest;
+ GstBufferPoolAcquireParams params = { 0, };
/* Else we have to copy the data into our private image, */
/* if we have one... */
@@ -1324,8 +1325,11 @@ gst_ximagesink_show_frame (GstVideoSink * vsink, GstBuffer * buf)
if (!gst_buffer_pool_set_active (ximagesink->pool, TRUE))
goto activate_failed;
- /* take a buffer from our pool */
- res = gst_buffer_pool_acquire_buffer (ximagesink->pool, &to_put, NULL);
+ /* take a buffer from our pool, if there is no buffer in the pool something
+ * is seriously wrong, waiting for the pool here might deadlock when we try
+ * to go to PAUSED because we never flush the pool. */
+ params.flags = GST_BUFFER_POOL_ACQUIRE_FLAG_DONTWAIT;
+ res = gst_buffer_pool_acquire_buffer (ximagesink->pool, &to_put, &params);
if (res != GST_FLOW_OK)
goto no_buffer;
@@ -1367,12 +1371,12 @@ no_buffer:
{
/* No image available. That's very bad ! */
GST_WARNING_OBJECT (ximagesink, "could not create image");
- return res;
+ return GST_FLOW_OK;
}
invalid_buffer:
{
/* No Window available to put our image into */
- GST_WARNING_OBJECT (ximagesink, "could map image");
+ GST_WARNING_OBJECT (ximagesink, "could not map image");
res = GST_FLOW_OK;
goto done;
}
diff --git a/sys/xvimage/xvimagesink.c b/sys/xvimage/xvimagesink.c
index e631b2a03..c766d2510 100644
--- a/sys/xvimage/xvimagesink.c
+++ b/sys/xvimage/xvimagesink.c
@@ -1831,6 +1831,7 @@ gst_xvimagesink_show_frame (GstVideoSink * vsink, GstBuffer * buf)
res = GST_FLOW_OK;
} else {
GstVideoFrame src, dest;
+ GstBufferPoolAcquireParams params = { 0, };
/* Else we have to copy the data into our private image, */
/* if we have one... */
@@ -1843,8 +1844,11 @@ gst_xvimagesink_show_frame (GstVideoSink * vsink, GstBuffer * buf)
if (!gst_buffer_pool_set_active (xvimagesink->pool, TRUE))
goto activate_failed;
- /* take a buffer from our pool */
- res = gst_buffer_pool_acquire_buffer (xvimagesink->pool, &to_put, NULL);
+ /* take a buffer from our pool, if there is no buffer in the pool something
+ * is seriously wrong, waiting for the pool here might deadlock when we try
+ * to go to PAUSED because we never flush the pool then. */
+ params.flags = GST_BUFFER_POOL_ACQUIRE_FLAG_DONTWAIT;
+ res = gst_buffer_pool_acquire_buffer (xvimagesink->pool, &to_put, &params);
if (res != GST_FLOW_OK)
goto no_buffer;
@@ -1886,12 +1890,12 @@ no_buffer:
{
/* No image available. That's very bad ! */
GST_WARNING_OBJECT (xvimagesink, "could not create image");
- return res;
+ return GST_FLOW_OK;
}
invalid_buffer:
{
/* No Window available to put our image into */
- GST_WARNING_OBJECT (xvimagesink, "could map image");
+ GST_WARNING_OBJECT (xvimagesink, "could not map image");
res = GST_FLOW_OK;
goto done;
}