ximagesink->xcontext->depth,
ZPixmap, NULL, &ximage->SHMInfo, ximage->width, ximage->height);
if (!ximage->ximage) {
+ g_mutex_unlock (ximagesink->x_lock);
GST_ELEMENT_ERROR (ximagesink, RESOURCE, WRITE,
("Failed to create output image buffer of %dx%d pixels",
ximage->width, ximage->height),
ximage->SHMInfo.shmid = shmget (IPC_PRIVATE, ximage->size,
IPC_CREAT | 0777);
if (ximage->SHMInfo.shmid == -1) {
+ g_mutex_unlock (ximagesink->x_lock);
GST_ELEMENT_ERROR (ximagesink, RESOURCE, WRITE,
("Failed to create output image buffer of %dx%d pixels",
ximage->width, ximage->height),
ximage->SHMInfo.shmaddr = shmat (ximage->SHMInfo.shmid, 0, 0);
if (ximage->SHMInfo.shmaddr == ((void *) -1)) {
+ g_mutex_unlock (ximagesink->x_lock);
GST_ELEMENT_ERROR (ximagesink, RESOURCE, WRITE,
("Failed to create output image buffer of %dx%d pixels",
ximage->width, ximage->height),
ximage->SHMInfo.readOnly = FALSE;
if (XShmAttach (ximagesink->xcontext->disp, &ximage->SHMInfo) == 0) {
+ g_mutex_unlock (ximagesink->x_lock);
GST_ELEMENT_ERROR (ximagesink, RESOURCE, WRITE,
("Failed to create output image buffer of %dx%d pixels",
ximage->width, ximage->height), ("Failed to XShmAttach"));
ZPixmap, 0, NULL,
ximage->width, ximage->height, ximagesink->xcontext->bpp, 0);
if (!ximage->ximage) {
+ g_mutex_unlock (ximagesink->x_lock);
GST_ELEMENT_ERROR (ximagesink, RESOURCE, WRITE,
("Failed to create output image buffer of %dx%d pixels",
ximage->width, ximage->height),
/* Keep a ref to our sink */
ximage->ximagesink = gst_object_ref (ximagesink);
-beach:
g_mutex_unlock (ximagesink->x_lock);
-
+beach:
if (!succeeded) {
gst_ximage_buffer_free (ximage);
ximage = NULL;
{
GstXImageSink *ximagesink;
GstStateChangeReturn ret = GST_STATE_CHANGE_SUCCESS;
+ GstXContext *xcontext = NULL;
ximagesink = GST_XIMAGESINK (element);
switch (transition) {
case GST_STATE_CHANGE_NULL_TO_READY:
- GST_OBJECT_LOCK (ximagesink);
- ximagesink->running = TRUE;
/* Initializing the XContext */
if (!ximagesink->xcontext)
- ximagesink->xcontext = gst_ximagesink_xcontext_get (ximagesink);
+ xcontext = gst_ximagesink_xcontext_get (ximagesink);
+
+ GST_OBJECT_LOCK (ximagesink);
+ ximagesink->running = TRUE;
+ if (xcontext)
+ ximagesink->xcontext = xcontext;
GST_OBJECT_UNLOCK (ximagesink);
if (!ximagesink->xcontext) {
xvimage->im_format, NULL,
xvimage->width, xvimage->height, &xvimage->SHMInfo);
if (!xvimage->xvimage) {
+ g_mutex_unlock (xvimagesink->x_lock);
GST_ELEMENT_ERROR (xvimagesink, RESOURCE, WRITE,
("Failed to create output image buffer of %dx%d pixels",
xvimage->width, xvimage->height),
("could not XvShmCreateImage a %dx%d image",
xvimage->width, xvimage->height));
- goto beach;
+ goto beach_unlocked;
}
/* we have to use the returned data_size for our shm size */
xvimage->SHMInfo.shmid = shmget (IPC_PRIVATE, xvimage->size,
IPC_CREAT | 0777);
if (xvimage->SHMInfo.shmid == -1) {
+ g_mutex_unlock (xvimagesink->x_lock);
GST_ELEMENT_ERROR (xvimagesink, RESOURCE, WRITE,
("Failed to create output image buffer of %dx%d pixels",
xvimage->width, xvimage->height),
("could not get shared memory of %d bytes", xvimage->size));
- goto beach;
+ goto beach_unlocked;
}
xvimage->SHMInfo.shmaddr = shmat (xvimage->SHMInfo.shmid, 0, 0);
if (xvimage->SHMInfo.shmaddr == ((void *) -1)) {
+ g_mutex_unlock (xvimagesink->x_lock);
GST_ELEMENT_ERROR (xvimagesink, RESOURCE, WRITE,
("Failed to create output image buffer of %dx%d pixels",
xvimage->width, xvimage->height),
("Failed to shmat: %s", g_strerror (errno)));
/* Clean up the shared memory segment */
shmctl (xvimage->SHMInfo.shmid, IPC_RMID, 0);
- goto beach;
+ goto beach_unlocked;
}
/* Delete the shared memory segment as soon as we manage to attach.
xvimage->SHMInfo.readOnly = FALSE;
if (XShmAttach (xvimagesink->xcontext->disp, &xvimage->SHMInfo) == 0) {
+ g_mutex_unlock (xvimagesink->x_lock);
GST_ELEMENT_ERROR (xvimagesink, RESOURCE, WRITE,
("Failed to create output image buffer of %dx%d pixels",
xvimage->width, xvimage->height), ("Failed to XShmAttach"));
- goto beach;
+ goto beach_unlocked;
}
XSync (xvimagesink->xcontext->disp, FALSE);
xvimagesink->xcontext->xv_port_id,
xvimage->im_format, NULL, xvimage->width, xvimage->height);
if (!xvimage->xvimage) {
+ g_mutex_unlock (xvimagesink->x_lock);
GST_ELEMENT_ERROR (xvimagesink, RESOURCE, WRITE,
("Failed to create outputimage buffer of %dx%d pixels",
xvimage->width, xvimage->height),
("could not XvCreateImage a %dx%d image",
xvimage->width, xvimage->height));
- goto beach;
+ goto beach_unlocked;
}
/* we have to use the returned data_size for our image size */
GST_BUFFER_DATA (xvimage) = (guchar *) xvimage->xvimage->data;
GST_BUFFER_SIZE (xvimage) = xvimage->size;
-beach:
- g_mutex_unlock (xvimagesink->x_lock);
-
beach_unlocked:
if (!succeeded) {
gst_xvimage_buffer_free (xvimage);
{
GstStateChangeReturn ret = GST_STATE_CHANGE_SUCCESS;
GstXvImageSink *xvimagesink;
+ GstXContext *xcontext = NULL;
xvimagesink = GST_XVIMAGESINK (element);
switch (transition) {
case GST_STATE_CHANGE_NULL_TO_READY:
- GST_OBJECT_LOCK (xvimagesink);
- xvimagesink->running = TRUE;
/* Initializing the XContext */
- if (!xvimagesink->xcontext &&
- !(xvimagesink->xcontext =
- gst_xvimagesink_xcontext_get (xvimagesink))) {
- GST_OBJECT_UNLOCK (xvimagesink);
- return GST_STATE_CHANGE_FAILURE;
+ if (xvimagesink->xcontext == NULL) {
+ xcontext = gst_xvimagesink_xcontext_get (xvimagesink);
+ if (xcontext == NULL)
+ return GST_STATE_CHANGE_FAILURE;
}
+
+ GST_OBJECT_LOCK (xvimagesink);
+ xvimagesink->running = TRUE;
+ if (xcontext)
+ xvimagesink->xcontext = xcontext;
GST_OBJECT_UNLOCK (xvimagesink);
/* update object's par with calculated one if not set yet */