mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-02-20 04:56:24 +00:00
sys/: it's not legal to ask the
Original commit message from CVS: * sys/ximage/ximagesink.c: (gst_ximagesink_check_xshm_calls), (gst_ximagesink_ximage_new): * sys/xvimage/xvimagesink.c: (gst_xvimagesink_check_xshm_calls), (gst_xvimagesink_xvimage_new): Apparently on Solaris and OS/X (at least), it's not legal to ask the X server to attach to a shared memory segment after we've deleted it, with the result that MIT-SHM is disabled. Instead, remove it only after X succeeds in attaching too.
This commit is contained in:
parent
cc74285d12
commit
6d641640bb
3 changed files with 51 additions and 24 deletions
12
ChangeLog
12
ChangeLog
|
@ -1,3 +1,15 @@
|
||||||
|
2008-07-17 Jan Schmidt <Jan.Schmidt@sun.com>
|
||||||
|
|
||||||
|
* sys/ximage/ximagesink.c: (gst_ximagesink_check_xshm_calls),
|
||||||
|
(gst_ximagesink_ximage_new):
|
||||||
|
* sys/xvimage/xvimagesink.c: (gst_xvimagesink_check_xshm_calls),
|
||||||
|
(gst_xvimagesink_xvimage_new):
|
||||||
|
|
||||||
|
Apparently on Solaris and OS/X (at least), it's not legal to ask the
|
||||||
|
X server to attach to a shared memory segment after we've deleted it,
|
||||||
|
with the result that MIT-SHM is disabled. Instead, remove it only after
|
||||||
|
X succeeds in attaching too.
|
||||||
|
|
||||||
2008-07-16 David Schleef <ds@schleef.org>
|
2008-07-16 David Schleef <ds@schleef.org>
|
||||||
|
|
||||||
* gst/audiotestsrc/gstaudiotestsrc.c:
|
* gst/audiotestsrc/gstaudiotestsrc.c:
|
||||||
|
|
|
@ -361,22 +361,24 @@ gst_ximagesink_check_xshm_calls (GstXImageSink * ximagesink,
|
||||||
goto beach;
|
goto beach;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Delete the shared memory segment as soon as we manage to attach.
|
|
||||||
* This way, it will be deleted as soon as we detach later, and not
|
|
||||||
* leaked if we crash. */
|
|
||||||
shmctl (SHMInfo.shmid, IPC_RMID, NULL);
|
|
||||||
|
|
||||||
ximage->data = SHMInfo.shmaddr;
|
ximage->data = SHMInfo.shmaddr;
|
||||||
SHMInfo.readOnly = FALSE;
|
SHMInfo.readOnly = FALSE;
|
||||||
|
|
||||||
if (XShmAttach (xcontext->disp, &SHMInfo) == 0) {
|
if (XShmAttach (xcontext->disp, &SHMInfo) == 0) {
|
||||||
GST_WARNING ("Failed to XShmAttach");
|
GST_WARNING ("Failed to XShmAttach");
|
||||||
|
/* Clean up shm seg */
|
||||||
|
shmctl (SHMInfo.shmid, IPC_RMID, NULL);
|
||||||
goto beach;
|
goto beach;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Sync to ensure we see any errors we caused */
|
/* Sync to ensure we see any errors we caused */
|
||||||
XSync (xcontext->disp, FALSE);
|
XSync (xcontext->disp, FALSE);
|
||||||
|
|
||||||
|
/* Delete the shared memory segment as soon as everyone is attached.
|
||||||
|
* This way, it will be deleted as soon as we detach later, and not
|
||||||
|
* leaked if we crash. */
|
||||||
|
shmctl (SHMInfo.shmid, IPC_RMID, NULL);
|
||||||
|
|
||||||
if (!error_caught) {
|
if (!error_caught) {
|
||||||
did_attach = TRUE;
|
did_attach = TRUE;
|
||||||
/* store whether we succeeded in result */
|
/* store whether we succeeded in result */
|
||||||
|
@ -480,15 +482,13 @@ gst_ximagesink_ximage_new (GstXImageSink * ximagesink, GstCaps * caps)
|
||||||
goto beach;
|
goto beach;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Now that we've attached, we can delete the shared memory segment.
|
|
||||||
* This way, it will be deleted as soon as we detach later, and not
|
|
||||||
* leaked if we crash. */
|
|
||||||
shmctl (ximage->SHMInfo.shmid, IPC_RMID, NULL);
|
|
||||||
|
|
||||||
ximage->ximage->data = ximage->SHMInfo.shmaddr;
|
ximage->ximage->data = ximage->SHMInfo.shmaddr;
|
||||||
ximage->SHMInfo.readOnly = FALSE;
|
ximage->SHMInfo.readOnly = FALSE;
|
||||||
|
|
||||||
if (XShmAttach (ximagesink->xcontext->disp, &ximage->SHMInfo) == 0) {
|
if (XShmAttach (ximagesink->xcontext->disp, &ximage->SHMInfo) == 0) {
|
||||||
|
/* Clean up shm seg */
|
||||||
|
shmctl (ximage->SHMInfo.shmid, IPC_RMID, NULL);
|
||||||
|
|
||||||
g_mutex_unlock (ximagesink->x_lock);
|
g_mutex_unlock (ximagesink->x_lock);
|
||||||
GST_ELEMENT_ERROR (ximagesink, RESOURCE, WRITE,
|
GST_ELEMENT_ERROR (ximagesink, RESOURCE, WRITE,
|
||||||
("Failed to create output image buffer of %dx%d pixels",
|
("Failed to create output image buffer of %dx%d pixels",
|
||||||
|
@ -497,6 +497,12 @@ gst_ximagesink_ximage_new (GstXImageSink * ximagesink, GstCaps * caps)
|
||||||
}
|
}
|
||||||
|
|
||||||
XSync (ximagesink->xcontext->disp, FALSE);
|
XSync (ximagesink->xcontext->disp, FALSE);
|
||||||
|
|
||||||
|
/* Now that everyone has attached, we can delete the shared memory segment.
|
||||||
|
* This way, it will be deleted as soon as we detach later, and not
|
||||||
|
* leaked if we crash. */
|
||||||
|
shmctl (ximage->SHMInfo.shmid, IPC_RMID, NULL);
|
||||||
|
|
||||||
} else
|
} else
|
||||||
#endif /* HAVE_XSHM */
|
#endif /* HAVE_XSHM */
|
||||||
{
|
{
|
||||||
|
|
|
@ -426,9 +426,9 @@ gst_xvimagesink_check_xshm_calls (GstXContext * xcontext)
|
||||||
handler = XSetErrorHandler (gst_xvimagesink_handle_xerror);
|
handler = XSetErrorHandler (gst_xvimagesink_handle_xerror);
|
||||||
|
|
||||||
/* Trying to create a 1x1 picture */
|
/* Trying to create a 1x1 picture */
|
||||||
GST_DEBUG ("XvShmCreateImage of 1x1");
|
GST_DEBUG ("XvShmCreateImage of 100x100");
|
||||||
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, 100, 100, &SHMInfo);
|
||||||
|
|
||||||
/* Might cause an error, sync to ensure it is noticed */
|
/* Might cause an error, sync to ensure it is noticed */
|
||||||
XSync (xcontext->disp, FALSE);
|
XSync (xcontext->disp, FALSE);
|
||||||
|
@ -452,29 +452,34 @@ gst_xvimagesink_check_xshm_calls (GstXContext * xcontext)
|
||||||
goto beach;
|
goto beach;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Delete the shared memory segment as soon as we manage to attach.
|
|
||||||
* This way, it will be deleted as soon as we detach later, and not
|
|
||||||
* leaked if we crash. */
|
|
||||||
shmctl (SHMInfo.shmid, IPC_RMID, NULL);
|
|
||||||
|
|
||||||
xvimage->data = SHMInfo.shmaddr;
|
xvimage->data = SHMInfo.shmaddr;
|
||||||
SHMInfo.readOnly = FALSE;
|
SHMInfo.readOnly = FALSE;
|
||||||
|
|
||||||
if (XShmAttach (xcontext->disp, &SHMInfo) == 0) {
|
if (XShmAttach (xcontext->disp, &SHMInfo) == 0) {
|
||||||
GST_WARNING ("Failed to XShmAttach");
|
GST_WARNING ("Failed to XShmAttach");
|
||||||
|
/* Clean up the shared memory segment */
|
||||||
|
shmctl (SHMInfo.shmid, IPC_RMID, NULL);
|
||||||
goto beach;
|
goto beach;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Sync to ensure we see any errors we caused */
|
/* Sync to ensure we see any errors we caused */
|
||||||
XSync (xcontext->disp, FALSE);
|
XSync (xcontext->disp, FALSE);
|
||||||
|
|
||||||
GST_DEBUG ("XServer ShmAttached to 0x%x, id 0x%lx", SHMInfo.shmid,
|
/* Delete the shared memory segment as soon as everyone is attached.
|
||||||
SHMInfo.shmseg);
|
* This way, it will be deleted as soon as we detach later, and not
|
||||||
|
* leaked if we crash. */
|
||||||
|
shmctl (SHMInfo.shmid, IPC_RMID, NULL);
|
||||||
|
|
||||||
if (!error_caught) {
|
if (!error_caught) {
|
||||||
|
GST_DEBUG ("XServer ShmAttached to 0x%x, id 0x%lx", SHMInfo.shmid,
|
||||||
|
SHMInfo.shmseg);
|
||||||
|
|
||||||
did_attach = TRUE;
|
did_attach = TRUE;
|
||||||
/* store whether we succeeded in result */
|
/* store whether we succeeded in result */
|
||||||
result = TRUE;
|
result = TRUE;
|
||||||
|
} else {
|
||||||
|
GST_WARNING ("MIT-SHM extension check failed at XShmAttach. "
|
||||||
|
"Not using shared memory.");
|
||||||
}
|
}
|
||||||
|
|
||||||
beach:
|
beach:
|
||||||
|
@ -626,15 +631,13 @@ gst_xvimagesink_xvimage_new (GstXvImageSink * xvimagesink, GstCaps * caps)
|
||||||
goto beach_unlocked;
|
goto beach_unlocked;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Delete the shared memory segment as soon as we manage to attach.
|
|
||||||
* This way, it will be deleted as soon as we detach later, and not
|
|
||||||
* leaked if we crash. */
|
|
||||||
shmctl (xvimage->SHMInfo.shmid, IPC_RMID, NULL);
|
|
||||||
|
|
||||||
xvimage->xvimage->data = xvimage->SHMInfo.shmaddr;
|
xvimage->xvimage->data = xvimage->SHMInfo.shmaddr;
|
||||||
xvimage->SHMInfo.readOnly = FALSE;
|
xvimage->SHMInfo.readOnly = FALSE;
|
||||||
|
|
||||||
if (XShmAttach (xvimagesink->xcontext->disp, &xvimage->SHMInfo) == 0) {
|
if (XShmAttach (xvimagesink->xcontext->disp, &xvimage->SHMInfo) == 0) {
|
||||||
|
/* Clean up the shared memory segment */
|
||||||
|
shmctl (xvimage->SHMInfo.shmid, IPC_RMID, NULL);
|
||||||
|
|
||||||
g_mutex_unlock (xvimagesink->x_lock);
|
g_mutex_unlock (xvimagesink->x_lock);
|
||||||
GST_ELEMENT_ERROR (xvimagesink, RESOURCE, WRITE,
|
GST_ELEMENT_ERROR (xvimagesink, RESOURCE, WRITE,
|
||||||
("Failed to create output image buffer of %dx%d pixels",
|
("Failed to create output image buffer of %dx%d pixels",
|
||||||
|
@ -643,6 +646,12 @@ gst_xvimagesink_xvimage_new (GstXvImageSink * xvimagesink, GstCaps * caps)
|
||||||
}
|
}
|
||||||
|
|
||||||
XSync (xvimagesink->xcontext->disp, FALSE);
|
XSync (xvimagesink->xcontext->disp, FALSE);
|
||||||
|
|
||||||
|
/* Delete the shared memory segment as soon as we everyone is attached.
|
||||||
|
* This way, it will be deleted as soon as we detach later, and not
|
||||||
|
* leaked if we crash. */
|
||||||
|
shmctl (xvimage->SHMInfo.shmid, IPC_RMID, NULL);
|
||||||
|
|
||||||
GST_DEBUG_OBJECT (xvimagesink, "XServer ShmAttached to 0x%x, id 0x%lx",
|
GST_DEBUG_OBJECT (xvimagesink, "XServer ShmAttached to 0x%x, id 0x%lx",
|
||||||
xvimage->SHMInfo.shmid, xvimage->SHMInfo.shmseg);
|
xvimage->SHMInfo.shmid, xvimage->SHMInfo.shmseg);
|
||||||
} else
|
} else
|
||||||
|
|
Loading…
Reference in a new issue