ftp://ftp.krokus.ru/pub/OpenBSD/distfiles/xscreensaver-4.22.tar.gz
[xscreensaver] / hacks / analogtv.c
index 85ced09c9a1a14dd8829e96c9a86d5f8bf6ec0c4..3bd9d46085aebdaab049663aa24b5be075a33034 100644 (file)
@@ -1,4 +1,4 @@
-/* analogtv, Copyright (c) 2003 Trevor Blackwell <tlb@tlb.org>
+/* analogtv, Copyright (c) 2003, 2004 Trevor Blackwell <tlb@tlb.org>
  *
  * Permission to use, copy, modify, distribute, and sell this software and its
  * documentation for any purpose is hereby granted without fee, provided that
@@ -264,8 +264,9 @@ analogtv_alloc_image(analogtv *it)
   if (!it->image) {
     it->image = XCreateImage(it->dpy, it->xgwa.visual, it->xgwa.depth, ZPixmap, 0, 0,
                              it->usewidth, it->useheight, 8, 0);
-    it->image->data = (char *)calloc(it->image->height, it->image->bytes_per_line);
+    it->image->data = (char *)malloc(it->image->height * it->image->bytes_per_line);
   }
+  memset (it->image->data, 0, it->image->height * it->image->bytes_per_line);
 }
 
 
@@ -851,7 +852,7 @@ void
 analogtv_setup_sync(analogtv_input *input, int do_cb, int do_ssavi)
 {
   int i,lineno,vsync;
-  char *sig;
+  signed char *sig;
 
   int synclevel = do_ssavi ? ANALOGTV_WHITE_LEVEL : ANALOGTV_SYNC_LEVEL;
 
@@ -886,7 +887,7 @@ analogtv_sync(analogtv *it)
 {
   int cur_hsync=it->cur_hsync;
   int cur_vsync=it->cur_vsync;
-  int lineno;
+  int lineno = 0;
   int i,j;
   double osc,filt;
   double *sp;
@@ -1565,6 +1566,9 @@ analogtv_draw(analogtv *it)
 #endif
 
   XSync(it->dpy,0);
+
+  /* Small delay to avoid hogging the CPU. */
+  usleep (10000);
 }
 
 analogtv_input *
@@ -1719,9 +1723,9 @@ void analogtv_add_signal(analogtv *it, analogtv_reception *rec)
   double *ps=it->rx_signal;
   double *pe=it->rx_signal + ANALOGTV_SIGNAL_LEN;
   double *p=ps;
-  char *ss=&inp->signal[0][0];
-  char *se=&inp->signal[0][0] + ANALOGTV_SIGNAL_LEN;
-  char *s=ss + ((unsigned)rec->ofs % ANALOGTV_SIGNAL_LEN);
+  signed char *ss=&inp->signal[0][0];
+  signed char *se=&inp->signal[0][0] + ANALOGTV_SIGNAL_LEN;
+  signed char *s=ss + ((unsigned)rec->ofs % ANALOGTV_SIGNAL_LEN);
   int i;
   int ec=it->channel_change_cycles;
   double level=rec->level;