mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-02-02 04:22:27 +00:00
x11: delay pool activation
don't activate the pool we return in the ALLOCATION query because upstream might still want to configure it
This commit is contained in:
parent
426ec86be0
commit
8fbdac9fc6
2 changed files with 29 additions and 36 deletions
|
@ -1133,9 +1133,6 @@ gst_ximagesink_setcaps (GstBaseSink * bsink, GstCaps * caps)
|
||||||
if (!gst_buffer_pool_set_config (newpool, structure))
|
if (!gst_buffer_pool_set_config (newpool, structure))
|
||||||
goto config_failed;
|
goto config_failed;
|
||||||
|
|
||||||
if (!gst_buffer_pool_set_active (newpool, TRUE))
|
|
||||||
goto activate_failed;
|
|
||||||
|
|
||||||
oldpool = ximagesink->pool;
|
oldpool = ximagesink->pool;
|
||||||
ximagesink->pool = newpool;
|
ximagesink->pool = newpool;
|
||||||
|
|
||||||
|
@ -1177,13 +1174,6 @@ config_failed:
|
||||||
g_mutex_unlock (ximagesink->flow_lock);
|
g_mutex_unlock (ximagesink->flow_lock);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
activate_failed:
|
|
||||||
{
|
|
||||||
GST_ERROR_OBJECT (ximagesink, "failed to activate bufferpool.");
|
|
||||||
g_mutex_unlock (ximagesink->flow_lock);
|
|
||||||
gst_object_unref (newpool);
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static GstStateChangeReturn
|
static GstStateChangeReturn
|
||||||
|
@ -1284,8 +1274,7 @@ gst_ximagesink_show_frame (GstVideoSink * vsink, GstBuffer * buf)
|
||||||
GstFlowReturn res;
|
GstFlowReturn res;
|
||||||
GstXImageSink *ximagesink;
|
GstXImageSink *ximagesink;
|
||||||
GstMetaXImage *meta;
|
GstMetaXImage *meta;
|
||||||
GstBuffer *temp;
|
GstBuffer *to_put = NULL;
|
||||||
gboolean unref;
|
|
||||||
|
|
||||||
ximagesink = GST_XIMAGESINK (vsink);
|
ximagesink = GST_XIMAGESINK (vsink);
|
||||||
|
|
||||||
|
@ -1295,8 +1284,8 @@ gst_ximagesink_show_frame (GstVideoSink * vsink, GstBuffer * buf)
|
||||||
/* If this buffer has been allocated using our buffer management we simply
|
/* If this buffer has been allocated using our buffer management we simply
|
||||||
put the ximage which is in the PRIVATE pointer */
|
put the ximage which is in the PRIVATE pointer */
|
||||||
GST_LOG_OBJECT (ximagesink, "buffer from our pool, writing directly");
|
GST_LOG_OBJECT (ximagesink, "buffer from our pool, writing directly");
|
||||||
|
to_put = buf;
|
||||||
res = GST_FLOW_OK;
|
res = GST_FLOW_OK;
|
||||||
unref = FALSE;
|
|
||||||
} else {
|
} else {
|
||||||
guint8 *data;
|
guint8 *data;
|
||||||
gsize size;
|
gsize size;
|
||||||
|
@ -1309,29 +1298,28 @@ gst_ximagesink_show_frame (GstVideoSink * vsink, GstBuffer * buf)
|
||||||
if (ximagesink->pool == NULL)
|
if (ximagesink->pool == NULL)
|
||||||
goto no_pool;
|
goto no_pool;
|
||||||
|
|
||||||
|
if (!gst_buffer_pool_set_active (ximagesink->pool, TRUE))
|
||||||
|
goto activate_failed;
|
||||||
|
|
||||||
/* take a buffer form our pool */
|
/* take a buffer form our pool */
|
||||||
res = gst_buffer_pool_acquire_buffer (ximagesink->pool, &temp, NULL);
|
res = gst_buffer_pool_acquire_buffer (ximagesink->pool, &to_put, NULL);
|
||||||
if (res != GST_FLOW_OK)
|
if (res != GST_FLOW_OK)
|
||||||
goto no_buffer;
|
goto no_buffer;
|
||||||
|
|
||||||
unref = TRUE;
|
if (gst_buffer_get_size (to_put) < gst_buffer_get_size (buf))
|
||||||
|
|
||||||
if (gst_buffer_get_size (temp) < gst_buffer_get_size (buf))
|
|
||||||
goto wrong_size;
|
goto wrong_size;
|
||||||
|
|
||||||
data = gst_buffer_map (temp, &size, NULL, GST_MAP_WRITE);
|
data = gst_buffer_map (to_put, &size, NULL, GST_MAP_WRITE);
|
||||||
gst_buffer_extract (buf, 0, data, size);
|
gst_buffer_extract (buf, 0, data, size);
|
||||||
gst_buffer_unmap (temp, data, size);
|
gst_buffer_unmap (to_put, data, size);
|
||||||
|
|
||||||
buf = temp;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!gst_ximagesink_ximage_put (ximagesink, buf))
|
if (!gst_ximagesink_ximage_put (ximagesink, to_put))
|
||||||
goto no_window;
|
goto no_window;
|
||||||
|
|
||||||
done:
|
done:
|
||||||
if (unref)
|
if (to_put != buf)
|
||||||
gst_buffer_unref (buf);
|
gst_buffer_unref (to_put);
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
|
|
||||||
|
@ -1354,7 +1342,7 @@ wrong_size:
|
||||||
GST_ELEMENT_ERROR (ximagesink, RESOURCE, WRITE,
|
GST_ELEMENT_ERROR (ximagesink, RESOURCE, WRITE,
|
||||||
("Failed to create output image buffer"),
|
("Failed to create output image buffer"),
|
||||||
("XServer allocated buffer size did not match input buffer %"
|
("XServer allocated buffer size did not match input buffer %"
|
||||||
G_GSIZE_FORMAT " - %" G_GSIZE_FORMAT, gst_buffer_get_size (temp),
|
G_GSIZE_FORMAT " - %" G_GSIZE_FORMAT, gst_buffer_get_size (to_put),
|
||||||
gst_buffer_get_size (buf)));
|
gst_buffer_get_size (buf)));
|
||||||
res = GST_FLOW_ERROR;
|
res = GST_FLOW_ERROR;
|
||||||
goto done;
|
goto done;
|
||||||
|
@ -1366,6 +1354,12 @@ no_window:
|
||||||
res = GST_FLOW_ERROR;
|
res = GST_FLOW_ERROR;
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
activate_failed:
|
||||||
|
{
|
||||||
|
GST_ERROR_OBJECT (ximagesink, "failed to activate bufferpool.");
|
||||||
|
res = GST_FLOW_ERROR;
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
|
|
|
@ -1668,9 +1668,6 @@ gst_xvimagesink_setcaps (GstBaseSink * bsink, GstCaps * caps)
|
||||||
if (!gst_buffer_pool_set_config (newpool, structure))
|
if (!gst_buffer_pool_set_config (newpool, structure))
|
||||||
goto config_failed;
|
goto config_failed;
|
||||||
|
|
||||||
if (!gst_buffer_pool_set_active (newpool, TRUE))
|
|
||||||
goto activate_failed;
|
|
||||||
|
|
||||||
oldpool = xvimagesink->pool;
|
oldpool = xvimagesink->pool;
|
||||||
xvimagesink->pool = newpool;
|
xvimagesink->pool = newpool;
|
||||||
g_mutex_unlock (xvimagesink->flow_lock);
|
g_mutex_unlock (xvimagesink->flow_lock);
|
||||||
|
@ -1714,13 +1711,6 @@ config_failed:
|
||||||
g_mutex_unlock (xvimagesink->flow_lock);
|
g_mutex_unlock (xvimagesink->flow_lock);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
activate_failed:
|
|
||||||
{
|
|
||||||
GST_ERROR_OBJECT (xvimagesink, "failed to activate bufferpool.");
|
|
||||||
g_mutex_unlock (xvimagesink->flow_lock);
|
|
||||||
gst_object_unref (newpool);
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static GstStateChangeReturn
|
static GstStateChangeReturn
|
||||||
|
@ -1835,8 +1825,8 @@ gst_xvimagesink_show_frame (GstVideoSink * vsink, GstBuffer * buf)
|
||||||
put the ximage which is in the PRIVATE pointer */
|
put the ximage which is in the PRIVATE pointer */
|
||||||
GST_LOG_OBJECT (xvimagesink, "buffer %p from our pool, writing directly",
|
GST_LOG_OBJECT (xvimagesink, "buffer %p from our pool, writing directly",
|
||||||
buf);
|
buf);
|
||||||
res = GST_FLOW_OK;
|
|
||||||
to_put = buf;
|
to_put = buf;
|
||||||
|
res = GST_FLOW_OK;
|
||||||
} else {
|
} else {
|
||||||
guint8 *data;
|
guint8 *data;
|
||||||
gsize size;
|
gsize size;
|
||||||
|
@ -1849,6 +1839,9 @@ gst_xvimagesink_show_frame (GstVideoSink * vsink, GstBuffer * buf)
|
||||||
if (xvimagesink->pool == NULL)
|
if (xvimagesink->pool == NULL)
|
||||||
goto no_pool;
|
goto no_pool;
|
||||||
|
|
||||||
|
if (!gst_buffer_pool_set_active (xvimagesink->pool, TRUE))
|
||||||
|
goto activate_failed;
|
||||||
|
|
||||||
/* take a buffer form our pool */
|
/* take a buffer form our pool */
|
||||||
res = gst_buffer_pool_acquire_buffer (xvimagesink->pool, &to_put, NULL);
|
res = gst_buffer_pool_acquire_buffer (xvimagesink->pool, &to_put, NULL);
|
||||||
if (res != GST_FLOW_OK)
|
if (res != GST_FLOW_OK)
|
||||||
|
@ -1905,6 +1898,12 @@ no_window:
|
||||||
res = GST_FLOW_ERROR;
|
res = GST_FLOW_ERROR;
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
activate_failed:
|
||||||
|
{
|
||||||
|
GST_ERROR_OBJECT (xvimagesink, "failed to activate bufferpool.");
|
||||||
|
res = GST_FLOW_ERROR;
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
|
|
Loading…
Reference in a new issue