mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-04-26 04:36:20 +00:00
ximage: more fixes
This commit is contained in:
parent
15c49a4d63
commit
518ededd16
2 changed files with 45 additions and 15 deletions
|
@ -1164,7 +1164,8 @@ gst_ximagesink_change_state (GstElement * element, GstStateChange transition)
|
||||||
GST_VIDEO_SINK_WIDTH (ximagesink) = 0;
|
GST_VIDEO_SINK_WIDTH (ximagesink) = 0;
|
||||||
GST_VIDEO_SINK_HEIGHT (ximagesink) = 0;
|
GST_VIDEO_SINK_HEIGHT (ximagesink) = 0;
|
||||||
g_mutex_lock (ximagesink->flow_lock);
|
g_mutex_lock (ximagesink->flow_lock);
|
||||||
gst_buffer_pool_set_active (ximagesink->pool, FALSE);
|
if (ximagesink->pool)
|
||||||
|
gst_buffer_pool_set_active (ximagesink->pool, FALSE);
|
||||||
g_mutex_unlock (ximagesink->flow_lock);
|
g_mutex_unlock (ximagesink->flow_lock);
|
||||||
break;
|
break;
|
||||||
case GST_STATE_CHANGE_READY_TO_NULL:
|
case GST_STATE_CHANGE_READY_TO_NULL:
|
||||||
|
@ -1206,6 +1207,8 @@ gst_ximagesink_show_frame (GstVideoSink * vsink, GstBuffer * buf)
|
||||||
GstFlowReturn res;
|
GstFlowReturn res;
|
||||||
GstXImageSink *ximagesink;
|
GstXImageSink *ximagesink;
|
||||||
GstMetaXImage *meta;
|
GstMetaXImage *meta;
|
||||||
|
GstBuffer *temp;
|
||||||
|
gboolean unref;
|
||||||
|
|
||||||
ximagesink = GST_XIMAGESINK (vsink);
|
ximagesink = GST_XIMAGESINK (vsink);
|
||||||
|
|
||||||
|
@ -1216,8 +1219,8 @@ gst_ximagesink_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 (ximagesink, "buffer from our pool, writing directly");
|
GST_LOG_OBJECT (ximagesink, "buffer from our pool, writing directly");
|
||||||
res = GST_FLOW_OK;
|
res = GST_FLOW_OK;
|
||||||
|
unref = FALSE;
|
||||||
} else {
|
} else {
|
||||||
GstBuffer *temp;
|
|
||||||
guint8 *data;
|
guint8 *data;
|
||||||
gsize size;
|
gsize size;
|
||||||
|
|
||||||
|
@ -1234,6 +1237,8 @@ gst_ximagesink_show_frame (GstVideoSink * vsink, GstBuffer * buf)
|
||||||
if (res != GST_FLOW_OK)
|
if (res != GST_FLOW_OK)
|
||||||
goto no_buffer;
|
goto no_buffer;
|
||||||
|
|
||||||
|
unref = TRUE;
|
||||||
|
|
||||||
if (gst_buffer_get_size (temp) < gst_buffer_get_size (buf))
|
if (gst_buffer_get_size (temp) < gst_buffer_get_size (buf))
|
||||||
goto wrong_size;
|
goto wrong_size;
|
||||||
|
|
||||||
|
@ -1247,6 +1252,10 @@ gst_ximagesink_show_frame (GstVideoSink * vsink, GstBuffer * buf)
|
||||||
if (!gst_ximagesink_ximage_put (ximagesink, buf))
|
if (!gst_ximagesink_ximage_put (ximagesink, buf))
|
||||||
goto no_window;
|
goto no_window;
|
||||||
|
|
||||||
|
done:
|
||||||
|
if (unref)
|
||||||
|
gst_buffer_unref (buf);
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
|
|
||||||
/* ERRORS */
|
/* ERRORS */
|
||||||
|
@ -1267,14 +1276,18 @@ 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 %"
|
||||||
return GST_FLOW_ERROR;
|
G_GSIZE_FORMAT " - %" G_GSIZE_FORMAT, gst_buffer_get_size (temp),
|
||||||
|
gst_buffer_get_size (buf)));
|
||||||
|
res = GST_FLOW_ERROR;
|
||||||
|
goto done;
|
||||||
}
|
}
|
||||||
no_window:
|
no_window:
|
||||||
{
|
{
|
||||||
/* No Window available to put our image into */
|
/* No Window available to put our image into */
|
||||||
GST_WARNING_OBJECT (ximagesink, "could not output image - no window");
|
GST_WARNING_OBJECT (ximagesink, "could not output image - no window");
|
||||||
return GST_FLOW_ERROR;
|
res = GST_FLOW_ERROR;
|
||||||
|
goto done;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1727,8 +1727,10 @@ gst_xvimagesink_change_state (GstElement * element, GstStateChange transition)
|
||||||
/* Initializing the XContext */
|
/* Initializing the XContext */
|
||||||
if (xvimagesink->xcontext == NULL) {
|
if (xvimagesink->xcontext == NULL) {
|
||||||
xcontext = gst_xvimagesink_xcontext_get (xvimagesink);
|
xcontext = gst_xvimagesink_xcontext_get (xvimagesink);
|
||||||
if (xcontext == NULL)
|
if (xcontext == NULL) {
|
||||||
return GST_STATE_CHANGE_FAILURE;
|
ret = GST_STATE_CHANGE_FAILURE;
|
||||||
|
goto beach;
|
||||||
|
}
|
||||||
GST_OBJECT_LOCK (xvimagesink);
|
GST_OBJECT_LOCK (xvimagesink);
|
||||||
if (xcontext)
|
if (xcontext)
|
||||||
xvimagesink->xcontext = xcontext;
|
xvimagesink->xcontext = xcontext;
|
||||||
|
@ -1769,8 +1771,9 @@ gst_xvimagesink_change_state (GstElement * element, GstStateChange transition)
|
||||||
GST_VIDEO_SINK_WIDTH (xvimagesink) = 0;
|
GST_VIDEO_SINK_WIDTH (xvimagesink) = 0;
|
||||||
GST_VIDEO_SINK_HEIGHT (xvimagesink) = 0;
|
GST_VIDEO_SINK_HEIGHT (xvimagesink) = 0;
|
||||||
g_mutex_lock (xvimagesink->flow_lock);
|
g_mutex_lock (xvimagesink->flow_lock);
|
||||||
gst_buffer_pool_set_active (xvimagesink->pool, FALSE);
|
if (xvimagesink->pool)
|
||||||
g_mutex_lock (xvimagesink->flow_lock);
|
gst_buffer_pool_set_active (xvimagesink->pool, FALSE);
|
||||||
|
g_mutex_unlock (xvimagesink->flow_lock);
|
||||||
break;
|
break;
|
||||||
case GST_STATE_CHANGE_READY_TO_NULL:
|
case GST_STATE_CHANGE_READY_TO_NULL:
|
||||||
gst_xvimagesink_reset (xvimagesink);
|
gst_xvimagesink_reset (xvimagesink);
|
||||||
|
@ -1779,6 +1782,7 @@ gst_xvimagesink_change_state (GstElement * element, GstStateChange transition)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
beach:
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1810,6 +1814,8 @@ gst_xvimagesink_show_frame (GstVideoSink * vsink, GstBuffer * buf)
|
||||||
GstFlowReturn res;
|
GstFlowReturn res;
|
||||||
GstXvImageSink *xvimagesink;
|
GstXvImageSink *xvimagesink;
|
||||||
GstMetaXvImage *meta;
|
GstMetaXvImage *meta;
|
||||||
|
GstBuffer *temp;
|
||||||
|
gboolean unref;
|
||||||
|
|
||||||
xvimagesink = GST_XVIMAGESINK (vsink);
|
xvimagesink = GST_XVIMAGESINK (vsink);
|
||||||
|
|
||||||
|
@ -1820,13 +1826,11 @@ 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 from our pool, writing directly");
|
GST_LOG_OBJECT (xvimagesink, "buffer from our pool, writing directly");
|
||||||
res = GST_FLOW_OK;
|
res = GST_FLOW_OK;
|
||||||
|
unref = FALSE;
|
||||||
} else {
|
} else {
|
||||||
GstBuffer *temp;
|
|
||||||
guint8 *data;
|
guint8 *data;
|
||||||
gsize size;
|
gsize size;
|
||||||
|
|
||||||
GST_CAT_LOG_OBJECT (GST_CAT_PERFORMANCE, xvimagesink,
|
|
||||||
"slow copy into bufferpool buffer %p", buf);
|
|
||||||
/* Else we have to copy the data into our private image, */
|
/* Else we have to copy the data into our private image, */
|
||||||
/* if we have one... */
|
/* if we have one... */
|
||||||
GST_LOG_OBJECT (xvimagesink, "buffer not from our pool, copying");
|
GST_LOG_OBJECT (xvimagesink, "buffer not from our pool, copying");
|
||||||
|
@ -1840,6 +1844,11 @@ gst_xvimagesink_show_frame (GstVideoSink * vsink, GstBuffer * buf)
|
||||||
if (res != GST_FLOW_OK)
|
if (res != GST_FLOW_OK)
|
||||||
goto no_buffer;
|
goto no_buffer;
|
||||||
|
|
||||||
|
GST_CAT_LOG_OBJECT (GST_CAT_PERFORMANCE, xvimagesink,
|
||||||
|
"slow copy into bufferpool buffer %p", temp);
|
||||||
|
|
||||||
|
unref = TRUE;
|
||||||
|
|
||||||
if (gst_buffer_get_size (temp) < gst_buffer_get_size (buf))
|
if (gst_buffer_get_size (temp) < gst_buffer_get_size (buf))
|
||||||
goto wrong_size;
|
goto wrong_size;
|
||||||
|
|
||||||
|
@ -1853,6 +1862,10 @@ gst_xvimagesink_show_frame (GstVideoSink * vsink, GstBuffer * buf)
|
||||||
if (!gst_xvimagesink_xvimage_put (xvimagesink, buf))
|
if (!gst_xvimagesink_xvimage_put (xvimagesink, buf))
|
||||||
goto no_window;
|
goto no_window;
|
||||||
|
|
||||||
|
done:
|
||||||
|
if (unref)
|
||||||
|
gst_buffer_unref (buf);
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
|
|
||||||
/* ERRORS */
|
/* ERRORS */
|
||||||
|
@ -1873,14 +1886,18 @@ wrong_size:
|
||||||
{
|
{
|
||||||
GST_ELEMENT_ERROR (xvimagesink, RESOURCE, WRITE,
|
GST_ELEMENT_ERROR (xvimagesink, 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 %"
|
||||||
return GST_FLOW_ERROR;
|
G_GSIZE_FORMAT " - %" G_GSIZE_FORMAT, gst_buffer_get_size (temp),
|
||||||
|
gst_buffer_get_size (buf)));
|
||||||
|
res = GST_FLOW_ERROR;
|
||||||
|
goto done;
|
||||||
}
|
}
|
||||||
no_window:
|
no_window:
|
||||||
{
|
{
|
||||||
/* No Window available to put our image into */
|
/* No Window available to put our image into */
|
||||||
GST_WARNING_OBJECT (xvimagesink, "could not output image - no window");
|
GST_WARNING_OBJECT (xvimagesink, "could not output image - no window");
|
||||||
return GST_FLOW_ERROR;
|
res = GST_FLOW_ERROR;
|
||||||
|
goto done;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue