mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-04-26 05:16:13 +00:00
sys/: Fix up the XShm call testing so that we catch errors, and don't cause new ones by attempting to detach from a s...
Original commit message from CVS: * sys/ximage/ximagesink.c: (gst_ximagesink_check_xshm_calls): * sys/xvimage/xvimagesink.c: (gst_xvimagesink_check_xshm_calls): Fix up the XShm call testing so that we catch errors, and don't cause new ones by attempting to detach from a segment we failed to attach to. Fixes #312439.
This commit is contained in:
parent
705122a2c2
commit
6a22f9115b
3 changed files with 66 additions and 23 deletions
|
@ -1,3 +1,11 @@
|
||||||
|
2006-02-12 Jan Schmidt <thaytan@mad.scientist.com>
|
||||||
|
|
||||||
|
* sys/ximage/ximagesink.c: (gst_ximagesink_check_xshm_calls):
|
||||||
|
* sys/xvimage/xvimagesink.c: (gst_xvimagesink_check_xshm_calls):
|
||||||
|
Fix up the XShm call testing so that we catch errors, and don't
|
||||||
|
cause new ones by attempting to detach from a segment we failed
|
||||||
|
to attach to. Fixes #312439.
|
||||||
|
|
||||||
2006-02-10 Edward Hervey <edward@fluendo.com>
|
2006-02-10 Edward Hervey <edward@fluendo.com>
|
||||||
|
|
||||||
* gst/typefind/gsttypefindfunctions.c: (plugin_init):
|
* gst/typefind/gsttypefindfunctions.c: (plugin_init):
|
||||||
|
|
|
@ -304,9 +304,17 @@ gst_ximagesink_check_xshm_calls (GstXImageSink * ximagesink,
|
||||||
size_t size;
|
size_t size;
|
||||||
int (*handler) (Display *, XErrorEvent *);
|
int (*handler) (Display *, XErrorEvent *);
|
||||||
gboolean result = FALSE;
|
gboolean result = FALSE;
|
||||||
|
gboolean did_attach = FALSE;
|
||||||
|
|
||||||
g_return_val_if_fail (xcontext != NULL, FALSE);
|
g_return_val_if_fail (xcontext != NULL, FALSE);
|
||||||
|
|
||||||
|
/* Sync to ensure any older errors are already processed */
|
||||||
|
XSync (xcontext->disp, FALSE);
|
||||||
|
|
||||||
|
/* Set defaults so we don't free these later unnecessarily */
|
||||||
|
SHMInfo.shmaddr = ((void *) -1);
|
||||||
|
SHMInfo.shmid = -1;
|
||||||
|
|
||||||
/* Setting an error handler to catch failure */
|
/* Setting an error handler to catch failure */
|
||||||
error_caught = FALSE;
|
error_caught = FALSE;
|
||||||
handler = XSetErrorHandler (gst_ximagesink_handle_xerror);
|
handler = XSetErrorHandler (gst_ximagesink_handle_xerror);
|
||||||
|
@ -316,7 +324,10 @@ gst_ximagesink_check_xshm_calls (GstXImageSink * ximagesink,
|
||||||
|
|
||||||
ximage = XShmCreateImage (xcontext->disp, xcontext->visual,
|
ximage = XShmCreateImage (xcontext->disp, xcontext->visual,
|
||||||
xcontext->depth, ZPixmap, NULL, &SHMInfo, 1, 1);
|
xcontext->depth, ZPixmap, NULL, &SHMInfo, 1, 1);
|
||||||
if (!ximage) {
|
|
||||||
|
/* Might cause an error, sync to ensure it is noticed */
|
||||||
|
XSync (xcontext->disp, FALSE);
|
||||||
|
if (!ximage || error_caught) {
|
||||||
GST_WARNING ("could not XShmCreateImage a 1x1 image");
|
GST_WARNING ("could not XShmCreateImage a 1x1 image");
|
||||||
goto beach;
|
goto beach;
|
||||||
}
|
}
|
||||||
|
@ -342,27 +353,31 @@ gst_ximagesink_check_xshm_calls (GstXImageSink * ximagesink,
|
||||||
goto beach;
|
goto beach;
|
||||||
}
|
}
|
||||||
|
|
||||||
XSync (xcontext->disp, 0);
|
/* Sync to ensure we see any errors we caused */
|
||||||
|
XSync (xcontext->disp, FALSE);
|
||||||
|
|
||||||
/* Destroy the image */
|
if (!error_caught) {
|
||||||
if (SHMInfo.shmaddr != ((void *) -1)) {
|
did_attach = TRUE;
|
||||||
XShmDetach (xcontext->disp, &SHMInfo);
|
/* store whether we succeeded in result */
|
||||||
XSync (xcontext->disp, 0);
|
result = TRUE;
|
||||||
shmdt (SHMInfo.shmaddr);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
beach:
|
||||||
|
/* Sync to ensure we swallow any errors we caused and reset error_caught */
|
||||||
|
XSync (xcontext->disp, FALSE);
|
||||||
|
error_caught = FALSE;
|
||||||
|
XSetErrorHandler (handler);
|
||||||
|
|
||||||
|
if (did_attach) {
|
||||||
|
XShmDetach (xcontext->disp, &SHMInfo);
|
||||||
|
XSync (xcontext->disp, FALSE);
|
||||||
|
}
|
||||||
|
if (SHMInfo.shmaddr != ((void *) -1))
|
||||||
|
shmdt (SHMInfo.shmaddr);
|
||||||
if (SHMInfo.shmid > 0)
|
if (SHMInfo.shmid > 0)
|
||||||
shmctl (SHMInfo.shmid, IPC_RMID, 0);
|
shmctl (SHMInfo.shmid, IPC_RMID, 0);
|
||||||
if (ximage)
|
if (ximage)
|
||||||
XDestroyImage (ximage);
|
XDestroyImage (ximage);
|
||||||
|
|
||||||
/* store whether we succeeded in result and reset error_caught */
|
|
||||||
result = !error_caught;
|
|
||||||
error_caught = FALSE;
|
|
||||||
|
|
||||||
beach:
|
|
||||||
XSetErrorHandler (handler);
|
|
||||||
|
|
||||||
XSync (xcontext->disp, FALSE);
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
#endif /* HAVE_XSHM */
|
#endif /* HAVE_XSHM */
|
||||||
|
|
|
@ -382,9 +382,17 @@ gst_xvimagesink_check_xshm_calls (GstXContext * xcontext)
|
||||||
gint size;
|
gint size;
|
||||||
int (*handler) (Display *, XErrorEvent *);
|
int (*handler) (Display *, XErrorEvent *);
|
||||||
gboolean result = FALSE;
|
gboolean result = FALSE;
|
||||||
|
gboolean did_attach = FALSE;
|
||||||
|
|
||||||
g_return_val_if_fail (xcontext != NULL, FALSE);
|
g_return_val_if_fail (xcontext != NULL, FALSE);
|
||||||
|
|
||||||
|
/* Sync to ensure any older errors are already processed */
|
||||||
|
XSync (xcontext->disp, FALSE);
|
||||||
|
|
||||||
|
/* Set defaults so we don't free these later unnecessarily */
|
||||||
|
SHMInfo.shmaddr = ((void *) -1);
|
||||||
|
SHMInfo.shmid = -1;
|
||||||
|
|
||||||
/* Setting an error handler to catch failure */
|
/* Setting an error handler to catch failure */
|
||||||
error_caught = FALSE;
|
error_caught = FALSE;
|
||||||
handler = XSetErrorHandler (gst_xvimagesink_handle_xerror);
|
handler = XSetErrorHandler (gst_xvimagesink_handle_xerror);
|
||||||
|
@ -393,7 +401,10 @@ gst_xvimagesink_check_xshm_calls (GstXContext * xcontext)
|
||||||
GST_DEBUG ("XvShmCreateImage of 1x1");
|
GST_DEBUG ("XvShmCreateImage of 1x1");
|
||||||
xvimage = XvShmCreateImage (xcontext->disp, xcontext->xv_port_id,
|
xvimage = XvShmCreateImage (xcontext->disp, xcontext->xv_port_id,
|
||||||
xcontext->im_format, NULL, 1, 1, &SHMInfo);
|
xcontext->im_format, NULL, 1, 1, &SHMInfo);
|
||||||
if (!xvimage) {
|
|
||||||
|
/* Might cause an error, sync to ensure it is noticed */
|
||||||
|
XSync (xcontext->disp, FALSE);
|
||||||
|
if (!xvimage || error_caught) {
|
||||||
GST_WARNING ("could not XvShmCreateImage a 1x1 image");
|
GST_WARNING ("could not XvShmCreateImage a 1x1 image");
|
||||||
goto beach;
|
goto beach;
|
||||||
}
|
}
|
||||||
|
@ -419,19 +430,28 @@ gst_xvimagesink_check_xshm_calls (GstXContext * xcontext)
|
||||||
goto beach;
|
goto beach;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* store whether we succeeded in result and reset error_caught */
|
/* Sync to ensure we see any errors we caused */
|
||||||
result = !error_caught;
|
XSync (xcontext->disp, FALSE);
|
||||||
error_caught = FALSE;
|
|
||||||
|
if (!error_caught) {
|
||||||
|
did_attach = TRUE;
|
||||||
|
/* store whether we succeeded in result */
|
||||||
|
result = TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
beach:
|
beach:
|
||||||
|
/* Sync to ensure we swallow any errors we caused and reset error_caught */
|
||||||
|
XSync (xcontext->disp, FALSE);
|
||||||
|
|
||||||
|
error_caught = FALSE;
|
||||||
XSetErrorHandler (handler);
|
XSetErrorHandler (handler);
|
||||||
|
|
||||||
XSync (xcontext->disp, FALSE);
|
if (did_attach) {
|
||||||
if (SHMInfo.shmaddr != ((void *) -1)) {
|
|
||||||
XShmDetach (xcontext->disp, &SHMInfo);
|
XShmDetach (xcontext->disp, &SHMInfo);
|
||||||
XSync (xcontext->disp, FALSE);
|
XSync (xcontext->disp, FALSE);
|
||||||
shmdt (SHMInfo.shmaddr);
|
|
||||||
}
|
}
|
||||||
|
if (SHMInfo.shmaddr != ((void *) -1))
|
||||||
|
shmdt (SHMInfo.shmaddr);
|
||||||
if (SHMInfo.shmid > 0)
|
if (SHMInfo.shmid > 0)
|
||||||
shmctl (SHMInfo.shmid, IPC_RMID, 0);
|
shmctl (SHMInfo.shmid, IPC_RMID, 0);
|
||||||
if (xvimage)
|
if (xvimage)
|
||||||
|
|
Loading…
Reference in a new issue