mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-02 14:36:41 +00:00
sys/xvimage/xvimagesink.c: call GST_ELEMENT_ERROR whenever get_xcontext fails. Includes assorted cleanup fixes.
Original commit message from CVS: * sys/xvimage/xvimagesink.c: (gst_xvimagesink_get_xv_support), (gst_xvimagesink_xcontext_get), (gst_xvimagesink_change_state), (gst_xvimagesink_set_xwindow_id): call GST_ELEMENT_ERROR whenever get_xcontext fails. Includes assorted cleanup fixes.
This commit is contained in:
parent
4bdad4d6a9
commit
0d88bf0a00
3 changed files with 113 additions and 91 deletions
|
@ -1,3 +1,11 @@
|
||||||
|
2004-04-17 Benjamin Otte <otte@gnome.org>
|
||||||
|
|
||||||
|
* sys/xvimage/xvimagesink.c: (gst_xvimagesink_get_xv_support),
|
||||||
|
(gst_xvimagesink_xcontext_get), (gst_xvimagesink_change_state),
|
||||||
|
(gst_xvimagesink_set_xwindow_id):
|
||||||
|
call GST_ELEMENT_ERROR whenever get_xcontext fails. Includes
|
||||||
|
assorted cleanup fixes.
|
||||||
|
|
||||||
2004-04-16 David Schleef <ds@schleef.org>
|
2004-04-16 David Schleef <ds@schleef.org>
|
||||||
|
|
||||||
* sys/ximage/ximagesink.h: Compile fix for FreeBSD. (bug #140268)
|
* sys/ximage/ximagesink.h: Compile fix for FreeBSD. (bug #140268)
|
||||||
|
|
2
common
2
common
|
@ -1 +1 @@
|
||||||
Subproject commit d03e4388098656fa65df4d3a29e40fc556173d2d
|
Subproject commit e55182f6eece70ff99e33b9800b27a926670dbdd
|
|
@ -565,25 +565,33 @@ gst_xvimagesink_handle_xevents (GstXvImageSink * xvimagesink, GstPad * pad)
|
||||||
|
|
||||||
/* This function generates a caps with all supported format by the first
|
/* This function generates a caps with all supported format by the first
|
||||||
Xv grabable port we find. We store each one of the supported formats in a
|
Xv grabable port we find. We store each one of the supported formats in a
|
||||||
format list and append the format to a newly created caps that we return */
|
format list and append the format to a newly created caps that we return
|
||||||
|
If this function does not return NULL because of an error, it also grabs
|
||||||
|
the port via XvGrabPort */
|
||||||
static GstCaps *
|
static GstCaps *
|
||||||
gst_xvimagesink_get_xv_support (GstXContext * xcontext)
|
gst_xvimagesink_get_xv_support (GstXvImageSink * xvimagesink,
|
||||||
|
GstXContext * xcontext)
|
||||||
{
|
{
|
||||||
gint i, nb_adaptors;
|
gint i, nb_adaptors;
|
||||||
XvAdaptorInfo *adaptors;
|
XvAdaptorInfo *adaptors;
|
||||||
|
gint nb_formats;
|
||||||
|
XvImageFormatValues *formats = NULL;
|
||||||
|
GstCaps *caps = NULL;
|
||||||
|
|
||||||
g_return_val_if_fail (xcontext != NULL, NULL);
|
g_return_val_if_fail (xcontext != NULL, NULL);
|
||||||
|
|
||||||
/* First let's check that XVideo extension is available */
|
/* First let's check that XVideo extension is available */
|
||||||
if (!XQueryExtension (xcontext->disp, "XVideo", &i, &i, &i)) {
|
if (!XQueryExtension (xcontext->disp, "XVideo", &i, &i, &i)) {
|
||||||
GST_DEBUG ("XVideo extension is not available");
|
GST_ELEMENT_ERROR (xvimagesink, RESOURCE, TOO_LAZY, (NULL),
|
||||||
|
("XVideo extension is not available"));
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Then we get adaptors list */
|
/* Then we get adaptors list */
|
||||||
if (Success != XvQueryAdaptors (xcontext->disp, xcontext->root,
|
if (Success != XvQueryAdaptors (xcontext->disp, xcontext->root,
|
||||||
&nb_adaptors, &adaptors)) {
|
&nb_adaptors, &adaptors)) {
|
||||||
GST_DEBUG ("Failed getting XV adaptors list");
|
GST_ELEMENT_ERROR (xvimagesink, RESOURCE, TOO_LAZY, (NULL),
|
||||||
|
("Failed getting XV adaptors list"));
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -611,10 +619,11 @@ gst_xvimagesink_get_xv_support (GstXContext * xcontext)
|
||||||
}
|
}
|
||||||
XvFreeAdaptorInfo (adaptors);
|
XvFreeAdaptorInfo (adaptors);
|
||||||
|
|
||||||
if (xcontext->xv_port_id) {
|
if (!xcontext->xv_port_id) {
|
||||||
gint nb_formats;
|
GST_ELEMENT_ERROR (xvimagesink, RESOURCE, TOO_LAZY, (NULL),
|
||||||
XvImageFormatValues *formats = NULL;
|
("No port available"));
|
||||||
GstCaps *caps = NULL;
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
/* We get all image formats supported by our port */
|
/* We get all image formats supported by our port */
|
||||||
formats = XvListImageFormats (xcontext->disp,
|
formats = XvListImageFormats (xcontext->disp,
|
||||||
|
@ -678,12 +687,17 @@ gst_xvimagesink_get_xv_support (GstXContext * xcontext)
|
||||||
if (formats)
|
if (formats)
|
||||||
XFree (formats);
|
XFree (formats);
|
||||||
|
|
||||||
GST_DEBUG ("Generated the following caps: " GST_PTR_FORMAT, caps);
|
GST_DEBUG ("Generated the following caps: %" GST_PTR_FORMAT, caps);
|
||||||
|
|
||||||
return caps;
|
if (gst_caps_is_empty (caps)) {
|
||||||
|
gst_caps_free (caps);
|
||||||
|
XvUngrabPort (xcontext->disp, xcontext->xv_port_id, 0);
|
||||||
|
GST_ELEMENT_ERROR (xvimagesink, RESOURCE, TOO_LAZY, (NULL),
|
||||||
|
("No supported format found"));
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
return NULL;
|
return caps;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* This function get the X Display and global infos about it. Everything is
|
/* This function get the X Display and global infos about it. Everything is
|
||||||
|
@ -732,6 +746,8 @@ gst_xvimagesink_xcontext_get (GstXvImageSink * xvimagesink)
|
||||||
XCloseDisplay (xcontext->disp);
|
XCloseDisplay (xcontext->disp);
|
||||||
g_mutex_unlock (xvimagesink->x_lock);
|
g_mutex_unlock (xvimagesink->x_lock);
|
||||||
g_free (xcontext);
|
g_free (xcontext);
|
||||||
|
GST_ELEMENT_ERROR (xvimagesink, RESOURCE, TOO_LAZY, (NULL),
|
||||||
|
("Could not get pixel formats"));
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -761,12 +777,13 @@ gst_xvimagesink_xcontext_get (GstXvImageSink * xvimagesink)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
xcontext->caps = gst_xvimagesink_get_xv_support (xcontext);
|
xcontext->caps = gst_xvimagesink_get_xv_support (xvimagesink, xcontext);
|
||||||
|
|
||||||
if (!xcontext->caps) {
|
if (!xcontext->caps) {
|
||||||
XCloseDisplay (xcontext->disp);
|
XCloseDisplay (xcontext->disp);
|
||||||
g_mutex_unlock (xvimagesink->x_lock);
|
g_mutex_unlock (xvimagesink->x_lock);
|
||||||
g_free (xcontext);
|
g_free (xcontext);
|
||||||
|
/* GST_ELEMENT_ERROR is thrown by gst_xvimagesink_get_xv_support */
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
#ifdef HAVE_XSHM
|
#ifdef HAVE_XSHM
|
||||||
|
@ -775,11 +792,12 @@ gst_xvimagesink_xcontext_get (GstXvImageSink * xvimagesink)
|
||||||
gst_xvimagesink_check_xshm_calls (xcontext)) {
|
gst_xvimagesink_check_xshm_calls (xcontext)) {
|
||||||
xcontext->use_xshm = TRUE;
|
xcontext->use_xshm = TRUE;
|
||||||
GST_DEBUG ("xvimagesink is using XShm extension");
|
GST_DEBUG ("xvimagesink is using XShm extension");
|
||||||
} else {
|
} else
|
||||||
|
#endif /* HAVE_XSHM */
|
||||||
|
{
|
||||||
xcontext->use_xshm = FALSE;
|
xcontext->use_xshm = FALSE;
|
||||||
GST_DEBUG ("xvimagesink is not using XShm extension");
|
GST_DEBUG ("xvimagesink is not using XShm extension");
|
||||||
}
|
}
|
||||||
#endif /* HAVE_XSHM */
|
|
||||||
|
|
||||||
xv_attr = XvQueryPortAttributes (xcontext->disp,
|
xv_attr = XvQueryPortAttributes (xcontext->disp,
|
||||||
xcontext->xv_port_id, &N_attr);
|
xcontext->xv_port_id, &N_attr);
|
||||||
|
@ -1058,11 +1076,9 @@ gst_xvimagesink_change_state (GstElement * element)
|
||||||
switch (GST_STATE_TRANSITION (element)) {
|
switch (GST_STATE_TRANSITION (element)) {
|
||||||
case GST_STATE_NULL_TO_READY:
|
case GST_STATE_NULL_TO_READY:
|
||||||
/* Initializing the XContext */
|
/* Initializing the XContext */
|
||||||
if (!xvimagesink->xcontext)
|
if (!xvimagesink->xcontext &&
|
||||||
xvimagesink->xcontext = gst_xvimagesink_xcontext_get (xvimagesink);
|
!(xvimagesink->xcontext = gst_xvimagesink_xcontext_get (xvimagesink)))
|
||||||
if (!xvimagesink->xcontext)
|
|
||||||
return GST_STATE_FAILURE;
|
return GST_STATE_FAILURE;
|
||||||
else /* If context initialized correctly let's commit our colorbalance */
|
|
||||||
gst_xvimagesink_update_colorbalance (xvimagesink);
|
gst_xvimagesink_update_colorbalance (xvimagesink);
|
||||||
break;
|
break;
|
||||||
case GST_STATE_READY_TO_PAUSED:
|
case GST_STATE_READY_TO_PAUSED:
|
||||||
|
@ -1305,13 +1321,11 @@ gst_xvimagesink_set_xwindow_id (GstXOverlay * overlay, XID xwindow_id)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
/* If the element has not initialized the X11 context try to do so */
|
/* If the element has not initialized the X11 context try to do so */
|
||||||
if (!xvimagesink->xcontext)
|
if (!xvimagesink->xcontext &&
|
||||||
xvimagesink->xcontext = gst_xvimagesink_xcontext_get (xvimagesink);
|
!(xvimagesink->xcontext = gst_xvimagesink_xcontext_get (xvimagesink)))
|
||||||
|
/* we have thrown a GST_ELEMENT_ERROR now */
|
||||||
if (!xvimagesink->xcontext) {
|
|
||||||
g_warning ("xvimagesink was unable to obtain the X11 context.");
|
|
||||||
return;
|
return;
|
||||||
} else /* If context initialized correctly let's commit our colorbalance */
|
|
||||||
gst_xvimagesink_update_colorbalance (xvimagesink);
|
gst_xvimagesink_update_colorbalance (xvimagesink);
|
||||||
|
|
||||||
/* Clear image pool as the images are unusable anyway */
|
/* Clear image pool as the images are unusable anyway */
|
||||||
|
|
Loading…
Reference in a new issue