aboutsummaryrefslogtreecommitdiffstats
path: root/src/native/linux
diff options
context:
space:
mode:
authorSebastien Vincent <seb@jitsi.org>2010-01-29 08:10:44 +0000
committerSebastien Vincent <seb@jitsi.org>2010-01-29 08:10:44 +0000
commit2fb6d32983741202ab7ee4f12d86081ef0802117 (patch)
tree630cc44356ce5775eb42f8584d3de8c0aafa6555 /src/native/linux
parent74cb044ffba0729213fe1b97ed47f3bd4d47aa64 (diff)
downloadjitsi-2fb6d32983741202ab7ee4f12d86081ef0802117.zip
jitsi-2fb6d32983741202ab7ee4f12d86081ef0802117.tar.gz
jitsi-2fb6d32983741202ab7ee4f12d86081ef0802117.tar.bz2
Fallback to XGetImage if XShm failed to grab screen capture.
Diffstat (limited to 'src/native/linux')
-rw-r--r--src/native/linux/screencapture/net_java_sip_communicator_impl_neomedia_imgstreaming_UnixScreenCapture.c34
1 files changed, 22 insertions, 12 deletions
diff --git a/src/native/linux/screencapture/net_java_sip_communicator_impl_neomedia_imgstreaming_UnixScreenCapture.c b/src/native/linux/screencapture/net_java_sip_communicator_impl_neomedia_imgstreaming_UnixScreenCapture.c
index d20d2c1..4d3e4d3 100644
--- a/src/native/linux/screencapture/net_java_sip_communicator_impl_neomedia_imgstreaming_UnixScreenCapture.c
+++ b/src/native/linux/screencapture/net_java_sip_communicator_impl_neomedia_imgstreaming_UnixScreenCapture.c
@@ -96,11 +96,11 @@ static int x11_grab_screen(const char* x11display, int32_t* data, int32_t x, int
/* test is XServer support SHM */
shm_support = XShmQueryExtension(display);
- /* fprintf(stdout, "Display=%s width=%d height=%d depth=%d SHM=%s\n", display_str, width, height, depth, shm_support ? "true" : "false"); */
+ /* fprintf(stderr, "Display=%s width=%d height=%d depth=%d SHM=%s\n", display_str, width, height, depth, shm_support ? "true" : "false"); */
if(shm_support)
{
- /* fprintf(stdout, "Use XShmGetImage\n"); */
+ /* fprintf(stderr, "Use XShmGetImage\n"); */
/* create image for SHM use */
img = XShmCreateImage(display, visual, depth, ZPixmap, NULL, &shm_info, w, h);
@@ -119,27 +119,37 @@ static int x11_grab_screen(const char* x11display, int32_t* data, int32_t x, int
shmctl(shm_info.shmid, IPC_RMID, NULL);
shm_info.readOnly = 0;
+ /* attach segment and grab screen */
if((shm_info.shmaddr == (void*)-1) || !XShmAttach(display, &shm_info))
{
/* fprintf(stderr, "Cannot use shared memory!\n"); */
- XCloseDisplay(display);
- return -1;
+ if(shm_info.shmaddr != (void*)-1)
+ {
+ shmdt(shm_info.shmaddr);
+ }
+
+ img->data = NULL;
+ XDestroyImage(img);
+ img = NULL;
+ shm_support = 0;
}
-
- /* grab screen */
- if(!XShmGetImage(display, root_window, img, x, y, 0xffffffff))
+ else if(!XShmGetImage(display, root_window, img, x, y, 0xffffffff))
{
/* fprintf(stderr, "Cannot grab image!\n"); */
XShmDetach(display, &shm_info);
shmdt(shm_info.shmaddr);
- XCloseDisplay(display);
- return -1;
+ XDestroyImage(img);
+ img = NULL;
+ shm_support = 0;
}
}
- else
+
+ /* if XSHM is not available or has failed
+ * use XGetImage
+ */
+ if(!img)
{
- /* fprintf(stdout, "Use XGetImage\n"); */
- /* no SHM */
+ /* fprintf(stderr, "Use XGetImage\n"); */
img = XGetImage(display, root_window, x, y, w, h, 0xffffffff, ZPixmap);
if(!img)