Actual code change to go along with:

Original commit message from CVS:
Actual code change to go along with:

2007-10-12  Jan Schmidt  <Jan.Schmidt@sun.com>

* sys/xvimage/xvimagesink.c: (gst_xvimagesink_xwindow_decorate),
(gst_xvimagesink_xwindow_new),
(gst_xvimagesink_update_colorbalance),
(gst_xvimagesink_handle_xevents), (gst_xvimagesink_xcontext_get):

Fix handling of some of the X atoms. If the last parameter is True,
XInternAtom won't create the atom if it doesn't exist, and therefore
might return None. This causes X errors on Xv implementations that
don't provide the colour balance attributes.
This commit is contained in:
Jan Schmidt 2007-10-12 10:52:18 +00:00
parent efb9c3be09
commit 8ab5292f13

View file

@ -846,7 +846,8 @@ gst_xvimagesink_xwindow_decorate (GstXvImageSink * xvimagesink,
g_mutex_lock (xvimagesink->x_lock); g_mutex_lock (xvimagesink->x_lock);
hints_atom = XInternAtom (xvimagesink->xcontext->disp, "_MOTIF_WM_HINTS", 1); hints_atom = XInternAtom (xvimagesink->xcontext->disp, "_MOTIF_WM_HINTS",
True);
if (hints_atom == None) { if (hints_atom == None) {
g_mutex_unlock (xvimagesink->x_lock); g_mutex_unlock (xvimagesink->x_lock);
return FALSE; return FALSE;
@ -908,10 +909,12 @@ gst_xvimagesink_xwindow_new (GstXvImageSink * xvimagesink,
/* Tell the window manager we'd like delete client messages instead of /* Tell the window manager we'd like delete client messages instead of
* being killed */ * being killed */
wm_delete = XInternAtom (xvimagesink->xcontext->disp, wm_delete = XInternAtom (xvimagesink->xcontext->disp,
"WM_DELETE_WINDOW", False); "WM_DELETE_WINDOW", True);
if (wm_delete != None) {
(void) XSetWMProtocols (xvimagesink->xcontext->disp, xwindow->win, (void) XSetWMProtocols (xvimagesink->xcontext->disp, xwindow->win,
&wm_delete, 1); &wm_delete, 1);
} }
}
xwindow->gc = XCreateGC (xvimagesink->xcontext->disp, xwindow->gc = XCreateGC (xvimagesink->xcontext->disp,
xwindow->win, 0, &values); xwindow->win, 0, &values);
@ -1019,6 +1022,7 @@ gst_xvimagesink_update_colorbalance (GstXvImageSink * xvimagesink)
while (channels) { while (channels) {
if (channels->data && GST_IS_COLOR_BALANCE_CHANNEL (channels->data)) { if (channels->data && GST_IS_COLOR_BALANCE_CHANNEL (channels->data)) {
GstColorBalanceChannel *channel = NULL; GstColorBalanceChannel *channel = NULL;
Atom prop_atom;
gint value = 0; gint value = 0;
gdouble convert_coef; gdouble convert_coef;
@ -1047,9 +1051,12 @@ gst_xvimagesink_update_colorbalance (GstXvImageSink * xvimagesink)
/* Committing to Xv port */ /* Committing to Xv port */
g_mutex_lock (xvimagesink->x_lock); g_mutex_lock (xvimagesink->x_lock);
prop_atom =
XInternAtom (xvimagesink->xcontext->disp, channel->label, True);
if (prop_atom != None) {
XvSetPortAttribute (xvimagesink->xcontext->disp, XvSetPortAttribute (xvimagesink->xcontext->disp,
xvimagesink->xcontext->xv_port_id, xvimagesink->xcontext->xv_port_id, prop_atom, value);
XInternAtom (xvimagesink->xcontext->disp, channel->label, 1), value); }
g_mutex_unlock (xvimagesink->x_lock); g_mutex_unlock (xvimagesink->x_lock);
g_object_unref (channel); g_object_unref (channel);
@ -1198,8 +1205,8 @@ gst_xvimagesink_handle_xevents (GstXvImageSink * xvimagesink)
Atom wm_delete; Atom wm_delete;
wm_delete = XInternAtom (xvimagesink->xcontext->disp, wm_delete = XInternAtom (xvimagesink->xcontext->disp,
"WM_DELETE_WINDOW", False); "WM_DELETE_WINDOW", True);
if (wm_delete == (Atom) e.xclient.data.l[0]) { if (wm_delete != None && wm_delete == (Atom) e.xclient.data.l[0]) {
/* Handle window deletion by posting an error on the bus */ /* Handle window deletion by posting an error on the bus */
GST_ELEMENT_ERROR (xvimagesink, RESOURCE, NOT_FOUND, GST_ELEMENT_ERROR (xvimagesink, RESOURCE, NOT_FOUND,
("Output window was closed"), (NULL)); ("Output window was closed"), (NULL));
@ -1594,6 +1601,7 @@ gst_xvimagesink_xcontext_get (GstXvImageSink * xvimagesink)
XPixmapFormatValues *px_formats = NULL; XPixmapFormatValues *px_formats = NULL;
gint nb_formats = 0, i, j, N_attr; gint nb_formats = 0, i, j, N_attr;
XvAttribute *xv_attr; XvAttribute *xv_attr;
Atom prop_atom;
char *channels[4] = { "XV_HUE", "XV_SATURATION", char *channels[4] = { "XV_HUE", "XV_SATURATION",
"XV_BRIGHTNESS", "XV_CONTRAST" "XV_BRIGHTNESS", "XV_CONTRAST"
}; };
@ -1701,6 +1709,12 @@ gst_xvimagesink_xcontext_get (GstXvImageSink * xvimagesink)
for (i = 0; i < (sizeof (channels) / sizeof (char *)); i++) { for (i = 0; i < (sizeof (channels) / sizeof (char *)); i++) {
XvAttribute *matching_attr = NULL; XvAttribute *matching_attr = NULL;
/* Retrieve the property atom if it exists. If it doesn't exist,
* the attribute itself must not either, so we can skip */
prop_atom = XInternAtom (xcontext->disp, channels[i], True);
if (prop_atom == None)
continue;
if (xv_attr != NULL) { if (xv_attr != NULL) {
for (j = 0; j < N_attr && matching_attr == NULL; ++j) for (j = 0; j < N_attr && matching_attr == NULL; ++j)
if (!g_ascii_strcasecmp (channels[i], xv_attr[j].name)) if (!g_ascii_strcasecmp (channels[i], xv_attr[j].name))
@ -1724,7 +1738,7 @@ gst_xvimagesink_xcontext_get (GstXvImageSink * xvimagesink)
gint val; gint val;
XvGetPortAttribute (xcontext->disp, xcontext->xv_port_id, XvGetPortAttribute (xcontext->disp, xcontext->xv_port_id,
XInternAtom (xcontext->disp, channel->label, 1), &val); prop_atom, &val);
/* Normalize val to [-1000, 1000] */ /* Normalize val to [-1000, 1000] */
val = -1000 + 2000 * (val - channel->min_value) / val = -1000 + 2000 * (val - channel->min_value) /
(channel->max_value - channel->min_value); (channel->max_value - channel->min_value);