summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan Schmidt <thaytan@mad.scientist.com>2006-05-26 11:17:57 +0000
committerJan Schmidt <thaytan@mad.scientist.com>2006-05-26 11:17:57 +0000
commit63bd38cd2ba9f20afe0f4751c87b77954cf68bac (patch)
treeb3a9668fa7c3378f56996307298896400c985270
parent58ae1bccaf51af829ba6c23e0d52d0c9ff23944c (diff)
sys/ximage/ximagesink.c: Improve the errors produced on bad output, including some human readable description strings.
Original commit message from CVS: * sys/ximage/ximagesink.c: (gst_ximagesink_ximage_new), (gst_ximagesink_xcontext_get), (gst_ximagesink_show_frame): Improve the errors produced on bad output, including some human readable description strings. Handle the (theoretical for ximagesink) case where the XServer has a different idea about the size required for a particular frame and gives us too small a memory allocation.
-rw-r--r--ChangeLog10
-rw-r--r--sys/ximage/ximagesink.c45
2 files changed, 43 insertions, 12 deletions
diff --git a/ChangeLog b/ChangeLog
index c55295c3..d8b4e676 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,15 @@
2006-05-26 Jan Schmidt <thaytan@mad.scientist.com>
+ * sys/ximage/ximagesink.c: (gst_ximagesink_ximage_new),
+ (gst_ximagesink_xcontext_get), (gst_ximagesink_show_frame):
+ Improve the errors produced on bad output, including some human
+ readable description strings.
+ Handle the (theoretical for ximagesink) case where the XServer
+ has a different idea about the size required for a particular
+ frame and gives us too small a memory allocation.
+
+2006-05-26 Jan Schmidt <thaytan@mad.scientist.com>
+
* sys/xvimage/xvimagesink.c: (gst_xvimagesink_xvimage_new),
(gst_xvimagesink_get_xv_support), (gst_xvimagesink_xcontext_get),
(gst_xvimagesink_get_format_from_caps), (gst_xvimagesink_setcaps),
diff --git a/sys/ximage/ximagesink.c b/sys/ximage/ximagesink.c
index 23f7c0b9..be01e3fa 100644
--- a/sys/ximage/ximagesink.c
+++ b/sys/ximage/ximagesink.c
@@ -418,8 +418,11 @@ gst_ximagesink_ximage_new (GstXImageSink * ximagesink, GstCaps * caps)
ximagesink->xcontext->depth,
ZPixmap, NULL, &ximage->SHMInfo, ximage->width, ximage->height);
if (!ximage->ximage) {
- GST_ELEMENT_ERROR (ximagesink, RESOURCE, WRITE, (NULL),
- ("could not XShmCreateImage a %dx%d image"));
+ GST_ELEMENT_ERROR (ximagesink, RESOURCE, WRITE,
+ ("Failed to create output image buffer of %dx%d pixels",
+ ximage->width, ximage->height),
+ ("could not XShmCreateImage a %dx%d image",
+ ximage->width, ximage->height));
goto beach;
}
@@ -431,14 +434,18 @@ gst_ximagesink_ximage_new (GstXImageSink * ximagesink, GstCaps * caps)
ximage->SHMInfo.shmid = shmget (IPC_PRIVATE, ximage->size,
IPC_CREAT | 0777);
if (ximage->SHMInfo.shmid == -1) {
- GST_ELEMENT_ERROR (ximagesink, RESOURCE, WRITE, (NULL),
+ GST_ELEMENT_ERROR (ximagesink, RESOURCE, WRITE,
+ ("Failed to create output image buffer of %dx%d pixels",
+ ximage->width, ximage->height),
("could not get shared memory of %d bytes", ximage->size));
goto beach;
}
ximage->SHMInfo.shmaddr = shmat (ximage->SHMInfo.shmid, 0, 0);
if (ximage->SHMInfo.shmaddr == ((void *) -1)) {
- GST_ELEMENT_ERROR (ximagesink, RESOURCE, WRITE, (NULL),
+ GST_ELEMENT_ERROR (ximagesink, RESOURCE, WRITE,
+ ("Failed to create output image buffer of %dx%d pixels",
+ ximage->width, ximage->height),
("Failed to shmat: %s", g_strerror (errno)));
/* Clean up the shared memory segment */
shmctl (ximage->SHMInfo.shmid, IPC_RMID, 0);
@@ -454,8 +461,9 @@ gst_ximagesink_ximage_new (GstXImageSink * ximagesink, GstCaps * caps)
ximage->SHMInfo.readOnly = FALSE;
if (XShmAttach (ximagesink->xcontext->disp, &ximage->SHMInfo) == 0) {
- GST_ELEMENT_ERROR (ximagesink, RESOURCE, WRITE, (NULL),
- ("Failed to XShmAttach"));
+ GST_ELEMENT_ERROR (ximagesink, RESOURCE, WRITE,
+ ("Failed to create output image buffer of %dx%d pixels",
+ ximage->width, ximage->height), ("Failed to XShmAttach"));
goto beach;
}
@@ -469,8 +477,11 @@ gst_ximagesink_ximage_new (GstXImageSink * ximagesink, GstCaps * caps)
ZPixmap, 0, NULL,
ximage->width, ximage->height, ximagesink->xcontext->bpp, 0);
if (!ximage->ximage) {
- GST_ELEMENT_ERROR (ximagesink, RESOURCE, WRITE, (NULL),
- ("could not XCreateImage a %dx%d image"));
+ GST_ELEMENT_ERROR (ximagesink, RESOURCE, WRITE,
+ ("Failed to create output image buffer of %dx%d pixels",
+ ximage->width, ximage->height),
+ ("could not XCreateImage a %dx%d image",
+ ximage->width, ximage->height));
goto beach;
}
@@ -1022,8 +1033,8 @@ gst_ximagesink_xcontext_get (GstXImageSink * ximagesink)
if (!xcontext->disp) {
g_mutex_unlock (ximagesink->x_lock);
g_free (xcontext);
- GST_ELEMENT_ERROR (ximagesink, RESOURCE, WRITE, (NULL),
- ("Could not open display"));
+ GST_ELEMENT_ERROR (ximagesink, RESOURCE, WRITE,
+ ("Could not initialise X output"), ("Could not open display"));
return NULL;
}
@@ -1423,7 +1434,19 @@ gst_ximagesink_show_frame (GstBaseSink * bsink, GstBuffer * buf)
ximagesink->ximage = gst_ximagesink_ximage_new (ximagesink,
GST_BUFFER_CAPS (buf));
if (!ximagesink->ximage)
+ /* The create method should have posted an informative error */
goto no_ximage;
+
+ if (ximagesink->ximage->size < GST_BUFFER_SIZE (buf)) {
+ GST_ELEMENT_ERROR (ximagesink, RESOURCE, WRITE,
+ ("Failed to create output image buffer of %dx%d pixels",
+ ximagesink->ximage->width, ximagesink->ximage->height),
+ ("XServer allocated buffer size did not match input buffer"));
+
+ gst_ximagesink_ximage_destroy (ximagesink, ximagesink->ximage);
+ ximagesink->ximage = NULL;
+ goto no_ximage;
+ }
}
memcpy (GST_BUFFER_DATA (ximagesink->ximage), GST_BUFFER_DATA (buf),
MIN (GST_BUFFER_SIZE (buf), ximagesink->ximage->size));
@@ -1437,8 +1460,6 @@ no_ximage:
{
/* No image available. That's very bad ! */
GST_DEBUG ("could not create image");
- GST_ELEMENT_ERROR (ximagesink, CORE, NEGOTIATION, (NULL),
- ("Failed creating an XImage in ximagesink chain function."));
return GST_FLOW_ERROR;
}
}