-/* xscreensaver, Copyright (c) 1997 Jamie Zawinski <jwz@netscape.com>
+/* xscreensaver, Copyright (c) 1997, 1998 Jamie Zawinski <jwz@jwz.org>
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
#include "utils.h"
#include "sgivideo.h"
#include "resources.h"
+#include "visual.h"
#ifdef HAVE_SGI_VIDEO /* whole file */
static Bool install_video_frame(unsigned long *image, int width, int height,
Screen *screen, Visual *visual, Drawable dest);
+#ifdef DEBUG
+static void
+describe_input(const char *prefix, VLServer server, int camera)
+{
+ VLDevList dl;
+ int i, j;
+
+ if (camera == VL_ANY)
+ {
+ printf("%s: %s VL_ANY\n", progname, prefix);
+ return;
+ }
+
+ vlGetDeviceList(server, &dl);
+ for (i = 0; i < dl.numDevices; i++)
+ {
+ VLDevice *d = &dl.devices[i];
+ for (j = 0; j < d->numNodes; j++)
+ if (d->nodes[j].number == camera)
+ {
+ printf("%s: %s %d, \"%s\"\n", progname, prefix,
+ d->nodes[j].number,
+ d->nodes[j].name);
+ return;
+ }
+ }
+
+ /* else... */
+ printf("%s: %s %d (???)\n", progname, prefix, camera);
+}
+#endif /* DEBUG */
+
+
static Bool
grab_frame_1(Screen *screen, Visual *visual, Drawable dest, int camera)
{
goto DONE;
}
+#ifdef DEBUG
+ describe_input("trying device", server, camera);
+#endif /* DEBUG */
+
input = vlGetNode (server, VL_SRC, VL_VIDEO, camera);
output = vlGetNode (server, VL_DRN, VL_MEM, VL_ANY);
goto DONE;
}
+#ifdef DEBUG
+ describe_input("read device", server, camera);
+#endif /* DEBUG */
+
if (dark_image_p(image, width, height))
goto DONE;
else
{
int i;
+ VLServer server = vlOpenVideo (NULL);
+
+ if (!server) return False;
+
for (i = 0; i < 5; i++) /* if we get all black images, retry up to
five times. */
{
- VLServer server = vlOpenVideo (NULL);
VLDevList dl;
int j;
- vlGetDeviceList(server, &dl);
- vlCloseVideo (server);
+
+ j = vlGetDeviceList(server, &dl);
+ vlCloseVideo(server);
+ if (j < 0) return False;
+
for (j = 0; j < dl.numDevices; j++)
{
VLDevice *d = &dl.devices[j];
d->nodes[k].kind == VL_VIDEO)
if (grab_frame_1(screen, visual, dest, d->nodes[k].number))
return True;
+ /* nothing yet? go around and try again... */
}
- /* nothing yet? go around and try again... */
}
}
#ifdef DEBUG
XGCValues gcv;
GC gc;
XImage *ximage = 0;
+ int image_depth;
Bool free_data = False;
int vblank_kludge = 3; /* lose the closed-captioning blips... */
gcv.foreground = BlackPixelOfScreen(screen);
gc = XCreateGC (dpy, dest, GCFunction|GCForeground, &gcv);
- ximage = XCreateImage (dpy, visual, 32, ZPixmap, 0, (char *) image,
+ image_depth = visual_depth(screen, visual);
+ if (image_depth < 24)
+ image_depth = 24; /* We'll dither */
+
+ ximage = XCreateImage (dpy, visual, image_depth, ZPixmap, 0, (char *) image,
width, height, 8, 0);
XInitImage(ximage);
if (!ximage)
return False;
- if (ximage->depth == 32 && d == 24)
- ximage->depth = d;
-
-
if (gain > 0.0) /* Pump up the volume */
{
unsigned char *end = (unsigned char *) (image + (width * height));