annotate simpletv.c @ 7:210d197c77f9

Tolerate LIRC going away.
author darius
date Sun, 21 Aug 2005 12:35:01 +0000
parents f0cbbe964629
children fc60aa65d85f
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1
769b155a34f9 Initial revision
darius
parents:
diff changeset
1 /* Capture and store a 24 bit RGB image as a PPM file */
769b155a34f9 Initial revision
darius
parents:
diff changeset
2 /* Copyright (c) 2000 Randall Hopper
769b155a34f9 Initial revision
darius
parents:
diff changeset
3 *
769b155a34f9 Initial revision
darius
parents:
diff changeset
4 * Based on a grab.c from Roger Hardiman, which was
769b155a34f9 Initial revision
darius
parents:
diff changeset
5 * based on an original program by Mark Tinguely and Jim Lowe .
769b155a34f9 Initial revision
darius
parents:
diff changeset
6 *
769b155a34f9 Initial revision
darius
parents:
diff changeset
7 * All rights reserved.
769b155a34f9 Initial revision
darius
parents:
diff changeset
8 *
769b155a34f9 Initial revision
darius
parents:
diff changeset
9 * Redistribution and use in source and binary forms, with or without
769b155a34f9 Initial revision
darius
parents:
diff changeset
10 * modification, are permitted provided that the following conditions
769b155a34f9 Initial revision
darius
parents:
diff changeset
11 * are met:
769b155a34f9 Initial revision
darius
parents:
diff changeset
12 * 1. Redistributions of source code must retain the above copyright
769b155a34f9 Initial revision
darius
parents:
diff changeset
13 * notice, this list of conditions and the following disclaimer.
769b155a34f9 Initial revision
darius
parents:
diff changeset
14 * 2. Redistributions in binary form must reproduce the above copyright
769b155a34f9 Initial revision
darius
parents:
diff changeset
15 * notice, this list of conditions and the following disclaimer in the
769b155a34f9 Initial revision
darius
parents:
diff changeset
16 * documentation and/or other materials provided with the distribution.
769b155a34f9 Initial revision
darius
parents:
diff changeset
17 * 3. All advertising materials mentioning features or use of this software
769b155a34f9 Initial revision
darius
parents:
diff changeset
18 * must display the following acknowledgement:
769b155a34f9 Initial revision
darius
parents:
diff changeset
19 * This product includes software developed by Mark Tinguely and Jim Lowe
769b155a34f9 Initial revision
darius
parents:
diff changeset
20 * 4. The name of the author may not be used to endorse or promote products
769b155a34f9 Initial revision
darius
parents:
diff changeset
21 * derived from this software without specific prior written permission.
769b155a34f9 Initial revision
darius
parents:
diff changeset
22 *
769b155a34f9 Initial revision
darius
parents:
diff changeset
23 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
769b155a34f9 Initial revision
darius
parents:
diff changeset
24 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
769b155a34f9 Initial revision
darius
parents:
diff changeset
25 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
769b155a34f9 Initial revision
darius
parents:
diff changeset
26 * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
769b155a34f9 Initial revision
darius
parents:
diff changeset
27 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
769b155a34f9 Initial revision
darius
parents:
diff changeset
28 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
769b155a34f9 Initial revision
darius
parents:
diff changeset
29 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
769b155a34f9 Initial revision
darius
parents:
diff changeset
30 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
769b155a34f9 Initial revision
darius
parents:
diff changeset
31 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
769b155a34f9 Initial revision
darius
parents:
diff changeset
32 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
769b155a34f9 Initial revision
darius
parents:
diff changeset
33 * POSSIBILITY OF SUCH DAMAGE.
769b155a34f9 Initial revision
darius
parents:
diff changeset
34 */
769b155a34f9 Initial revision
darius
parents:
diff changeset
35
769b155a34f9 Initial revision
darius
parents:
diff changeset
36 #include <assert.h>
769b155a34f9 Initial revision
darius
parents:
diff changeset
37 #include <stdio.h>
769b155a34f9 Initial revision
darius
parents:
diff changeset
38 #include <unistd.h>
769b155a34f9 Initial revision
darius
parents:
diff changeset
39 #include <string.h>
769b155a34f9 Initial revision
darius
parents:
diff changeset
40 #include <stdlib.h>
769b155a34f9 Initial revision
darius
parents:
diff changeset
41 #include <errno.h>
769b155a34f9 Initial revision
darius
parents:
diff changeset
42 #include <sys/types.h>
769b155a34f9 Initial revision
darius
parents:
diff changeset
43 #include <poll.h>
769b155a34f9 Initial revision
darius
parents:
diff changeset
44 #include <sys/mman.h>
769b155a34f9 Initial revision
darius
parents:
diff changeset
45 #include <sys/fcntl.h>
769b155a34f9 Initial revision
darius
parents:
diff changeset
46 #include <sys/time.h>
769b155a34f9 Initial revision
darius
parents:
diff changeset
47 #include <libgen.h>
769b155a34f9 Initial revision
darius
parents:
diff changeset
48 #include <sys/soundcard.h>
5
8b6b46a1261d - Move to 5.x+ includes
darius
parents: 3
diff changeset
49 #include <dev/bktr/ioctl_bt848.h>
8b6b46a1261d - Move to 5.x+ includes
darius
parents: 3
diff changeset
50 #include <dev/bktr/ioctl_meteor.h>
1
769b155a34f9 Initial revision
darius
parents:
diff changeset
51 #include <machine/param.h>
769b155a34f9 Initial revision
darius
parents:
diff changeset
52 #include <sys/types.h>
769b155a34f9 Initial revision
darius
parents:
diff changeset
53 #include <sys/ipc.h>
769b155a34f9 Initial revision
darius
parents:
diff changeset
54 #include <sys/shm.h>
769b155a34f9 Initial revision
darius
parents:
diff changeset
55 #include <X11/Xlib.h>
769b155a34f9 Initial revision
darius
parents:
diff changeset
56 #include <X11/Xutil.h>
769b155a34f9 Initial revision
darius
parents:
diff changeset
57 #include <X11/extensions/XShm.h>
769b155a34f9 Initial revision
darius
parents:
diff changeset
58 #include <X11/extensions/Xvlib.h>
769b155a34f9 Initial revision
darius
parents:
diff changeset
59 #ifndef USE_XVIMAGES
769b155a34f9 Initial revision
darius
parents:
diff changeset
60 #include "Hermes/Hermes.h"
769b155a34f9 Initial revision
darius
parents:
diff changeset
61 #endif
769b155a34f9 Initial revision
darius
parents:
diff changeset
62
769b155a34f9 Initial revision
darius
parents:
diff changeset
63 #include <lirc/lirc_client.h>
769b155a34f9 Initial revision
darius
parents:
diff changeset
64
769b155a34f9 Initial revision
darius
parents:
diff changeset
65 /* Some BT848/BT878 cards have gain control hardware which takes
769b155a34f9 Initial revision
darius
parents:
diff changeset
66 1 or 2 seconds to settle. If you get a washed out / too bright
769b155a34f9 Initial revision
darius
parents:
diff changeset
67 image, change the GRABBER_SETTLE_TIME from 0 to either 1 or 2
769b155a34f9 Initial revision
darius
parents:
diff changeset
68 */
769b155a34f9 Initial revision
darius
parents:
diff changeset
69 /*#define GRABBER_SETTLE_TIME 10*/
769b155a34f9 Initial revision
darius
parents:
diff changeset
70 #define GRABBER_SETTLE_TIME 0
769b155a34f9 Initial revision
darius
parents:
diff changeset
71
769b155a34f9 Initial revision
darius
parents:
diff changeset
72
769b155a34f9 Initial revision
darius
parents:
diff changeset
73 #define PAL 1
769b155a34f9 Initial revision
darius
parents:
diff changeset
74 #define NTSC 2
769b155a34f9 Initial revision
darius
parents:
diff changeset
75
769b155a34f9 Initial revision
darius
parents:
diff changeset
76 /* PAL is 768 x 576. NTSC is 640 x 480 */
769b155a34f9 Initial revision
darius
parents:
diff changeset
77 #define PAL_HEIGHT 576
769b155a34f9 Initial revision
darius
parents:
diff changeset
78 #define NTSC_HEIGHT 480
769b155a34f9 Initial revision
darius
parents:
diff changeset
79
3
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
80 int bktr_fd;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
81 int tuner_fd;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
82 unsigned char *bktr_buffer;
1
769b155a34f9 Initial revision
darius
parents:
diff changeset
83 #if 1
3
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
84 int width = 320;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
85 int height = 240;
1
769b155a34f9 Initial revision
darius
parents:
diff changeset
86 #else
7
210d197c77f9 Tolerate LIRC going away.
darius
parents: 6
diff changeset
87 int width = 720;
210d197c77f9 Tolerate LIRC going away.
darius
parents: 6
diff changeset
88 int height = 576;
1
769b155a34f9 Initial revision
darius
parents:
diff changeset
89 #endif
769b155a34f9 Initial revision
darius
parents:
diff changeset
90
769b155a34f9 Initial revision
darius
parents:
diff changeset
91 #ifndef USE_XVIMAGES
3
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
92 static XImage *rgb_image;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
93 static Pixmap pmap;
1
769b155a34f9 Initial revision
darius
parents:
diff changeset
94 #endif
769b155a34f9 Initial revision
darius
parents:
diff changeset
95 static XShmSegmentInfo shminfo;
769b155a34f9 Initial revision
darius
parents:
diff changeset
96 static Display *disp;
3
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
97 static Window win;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
98 static Visual *vis;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
99 static int scr;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
100 static GC gc;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
101 static int depth;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
102 static Colormap cmap;
1
769b155a34f9 Initial revision
darius
parents:
diff changeset
103 static XVisualInfo *vi;
3
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
104 static int bits_per_pixel;
1
769b155a34f9 Initial revision
darius
parents:
diff changeset
105 static XvImage *yuv_image;
769b155a34f9 Initial revision
darius
parents:
diff changeset
106 static XvAdaptorInfo *xv_adaptors;
3
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
107 static int xv_num_adaptors;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
108 static int xv_adaptor;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
109 static int xv_format_id;
1
769b155a34f9 Initial revision
darius
parents:
diff changeset
110
3
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
111 static int channel;
1
769b155a34f9 Initial revision
darius
parents:
diff changeset
112
769b155a34f9 Initial revision
darius
parents:
diff changeset
113 #define DO_IOCTL_GERR(str) fprintf(stderr, "ioctl(%s) failed: %s\n", \
769b155a34f9 Initial revision
darius
parents:
diff changeset
114 str, strerror(errno) )
7
210d197c77f9 Tolerate LIRC going away.
darius
parents: 6
diff changeset
115 #define DO_IOCTL_SERR(str,arg) fprintf(stderr, "ioctl(%s, %ld) failed: %s\n", \
1
769b155a34f9 Initial revision
darius
parents:
diff changeset
116 str, (long)arg, strerror(errno) )
769b155a34f9 Initial revision
darius
parents:
diff changeset
117 /*--------------------------------------------------------------------------*/
769b155a34f9 Initial revision
darius
parents:
diff changeset
118
3
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
119 void
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
120 Close() {
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
121 close(tuner_fd);
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
122 close(bktr_fd);
1
769b155a34f9 Initial revision
darius
parents:
diff changeset
123 }
769b155a34f9 Initial revision
darius
parents:
diff changeset
124
3
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
125 void
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
126 Open() {
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
127 struct meteor_geomet geo;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
128 int buffer_size, format, source, c;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
129 char *device_name;
1
769b155a34f9 Initial revision
darius
parents:
diff changeset
130
3
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
131 format = PAL; /* default value */
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
132 source = 1; /* default value */
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
133 device_name = "/dev/bktr0"; /* default value */
1
769b155a34f9 Initial revision
darius
parents:
diff changeset
134
3
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
135 /* Open the Meteor or Bt848/Bt878 grabber */
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
136 if ((bktr_fd = open(device_name, O_RDONLY)) < 0) {
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
137 printf("open failed: %d\n", errno);
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
138 exit(1);
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
139 }
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
140 if ((tuner_fd = open("/dev/tuner0", O_RDONLY)) < 0) {
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
141 printf("open failed: %d\n", errno);
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
142 exit(1);
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
143 }
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
144 /* set up the capture type and size */
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
145 geo.rows = height;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
146 geo.columns = width;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
147 geo.frames = 1;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
148 #ifdef USE_XVIMAGES
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
149 /* Should be YUV_12, but 422 actually gives a synced picture. Though */
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
150 geo.oformat = METEOR_GEO_YUV_422 | METEOR_GEO_YUV_12;
7
210d197c77f9 Tolerate LIRC going away.
darius
parents: 6
diff changeset
151
1
769b155a34f9 Initial revision
darius
parents:
diff changeset
152 #else
3
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
153 geo.oformat = METEOR_GEO_RGB24;
1
769b155a34f9 Initial revision
darius
parents:
diff changeset
154 #endif
769b155a34f9 Initial revision
darius
parents:
diff changeset
155
3
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
156 /* switch from interlaced capture to single field capture if */
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
157 /* the grab height is less than half the normal TV height */
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
158 /* this gives better quality captures when the object in the TV */
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
159 /* picture is moving */
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
160 if ((format == PAL) && (height <= (PAL_HEIGHT / 2)))
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
161 geo.oformat |= METEOR_GEO_ODD_ONLY;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
162 if ((format == NTSC) && (height <= (NTSC_HEIGHT / 2)))
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
163 geo.oformat |= METEOR_GEO_ODD_ONLY;
1
769b155a34f9 Initial revision
darius
parents:
diff changeset
164
3
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
165 if (ioctl(bktr_fd, METEORSETGEO, &geo) < 0) {
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
166 printf("METEORSETGEO ioctl failed: %d\n", errno);
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
167 exit(1);
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
168 }
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
169 /* Select PAL or NTSC */
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
170 switch (format) {
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
171 case PAL:
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
172 c = METEOR_FMT_PAL;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
173 break;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
174 case NTSC:
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
175 c = METEOR_FMT_NTSC;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
176 break;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
177 default:
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
178 c = METEOR_FMT_NTSC;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
179 break;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
180 }
1
769b155a34f9 Initial revision
darius
parents:
diff changeset
181
3
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
182 c = BT848_IFORM_F_PALBDGHI;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
183 if (ioctl(bktr_fd, BT848SFMT, &c) < 0) {
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
184 DO_IOCTL_SERR("BT848SFMT", c);
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
185 return;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
186 }
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
187 c = AUDIO_TUNER;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
188 if (ioctl(tuner_fd, BT848_SAUDIO, &c) < 0) {
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
189 DO_IOCTL_SERR("BT848SFMT", c);
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
190 return;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
191 }
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
192 c = CHNLSET_AUSTRALIA;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
193 if (ioctl(tuner_fd, TVTUNER_SETTYPE, &c) < 0) {
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
194 DO_IOCTL_SERR("TVTUNER_SETTYPE", c);
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
195 return;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
196 }
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
197 if (ioctl(tuner_fd, TVTUNER_SETCHNL, &channel) < 0) {
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
198 DO_IOCTL_SERR("TVTUNER_SETCHNL", channel);
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
199 return;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
200 }
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
201 /* Select the Video Source */
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
202 /* Video In, Tuner, S-Video */
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
203 switch (source) {
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
204 case 0:
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
205 c = METEOR_INPUT_DEV0;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
206 break;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
207 case 1:
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
208 c = METEOR_INPUT_DEV1;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
209 break;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
210 case 2:
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
211 c = METEOR_INPUT_DEV2;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
212 break;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
213 case 3:
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
214 c = METEOR_INPUT_DEV3;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
215 break;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
216 default:
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
217 c = METEOR_INPUT_DEV0;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
218 break;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
219 }
1
769b155a34f9 Initial revision
darius
parents:
diff changeset
220
3
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
221 printf("Input - %x\n", c);
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
222 if (ioctl(bktr_fd, METEORSINPUT, &c) < 0) {
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
223 printf("ioctl failed: %d\n", errno);
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
224 exit(1);
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
225 }
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
226 /* Use mmap to Map the drivers grab buffer */
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
227 buffer_size = width * height * 4; /* R,G,B,spare */
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
228 bktr_buffer = (unsigned char *)mmap((caddr_t) 0, buffer_size, PROT_READ,
7
210d197c77f9 Tolerate LIRC going away.
darius
parents: 6
diff changeset
229 MAP_SHARED, bktr_fd, (off_t) 0);
1
769b155a34f9 Initial revision
darius
parents:
diff changeset
230
3
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
231 if (bktr_buffer == (unsigned char *)MAP_FAILED)
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
232 exit(1);
1
769b155a34f9 Initial revision
darius
parents:
diff changeset
233
769b155a34f9 Initial revision
darius
parents:
diff changeset
234
3
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
235 /* We may need to wait for a short time to allow the grabber */
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
236 /* brightness to settle down */
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
237 sleep(GRABBER_SETTLE_TIME);
1
769b155a34f9 Initial revision
darius
parents:
diff changeset
238 }
769b155a34f9 Initial revision
darius
parents:
diff changeset
239
769b155a34f9 Initial revision
darius
parents:
diff changeset
240 /*--------------------------------------------------------------------------*/
769b155a34f9 Initial revision
darius
parents:
diff changeset
241
3
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
242 void
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
243 Capture() {
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
244 int c;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
245
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
246 /* Perform a single frame capture */
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
247 c = METEOR_CAP_SINGLE;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
248 ioctl(bktr_fd, METEORCAPTUR, &c);
1
769b155a34f9 Initial revision
darius
parents:
diff changeset
249 }
769b155a34f9 Initial revision
darius
parents:
diff changeset
250
769b155a34f9 Initial revision
darius
parents:
diff changeset
251 /*--------------------------------------------------------------------------*/
769b155a34f9 Initial revision
darius
parents:
diff changeset
252
3
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
253 void
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
254 SaveImage() {
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
255 unsigned char *line_buffer;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
256 int o , w, h;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
257 unsigned char *p;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
258 unsigned char header[30];
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
259 char *filename = "t.ppm" /* argv[3] */ ;
1
769b155a34f9 Initial revision
darius
parents:
diff changeset
260
3
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
261 /* Create the output file */
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
262 if ((o = open(filename, O_WRONLY | O_CREAT, 0644)) < 0) {
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
263 printf("ppm open failed: %d\n", errno);
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
264 exit(1);
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
265 }
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
266 /* make PPM header and save to file */
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
267 sprintf(header, "P6\n%d\n%d\n255\n", width, height);
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
268 write(o, header, strlen(header));
1
769b155a34f9 Initial revision
darius
parents:
diff changeset
269
3
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
270 /* save the RGB data to PPM file */
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
271 /* save this one line at a time */
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
272 line_buffer = (unsigned char *)malloc(width * 3 * sizeof(unsigned char));
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
273 p = bktr_buffer;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
274 for (h = 0; h < height; h++) {
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
275 for (w = 0; w < width; w++) {
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
276 line_buffer[(w * 3) + 2] = *p++; /* blue */
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
277 line_buffer[(w * 3) + 1] = *p++; /* green */
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
278 line_buffer[(w * 3) + 0] = *p++; /* red */
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
279 p++; /* NULL byte */
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
280 }
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
281 write(o, line_buffer, width * 3);
1
769b155a34f9 Initial revision
darius
parents:
diff changeset
282 }
3
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
283 close(o);
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
284 free(line_buffer);
1
769b155a34f9 Initial revision
darius
parents:
diff changeset
285 }
769b155a34f9 Initial revision
darius
parents:
diff changeset
286
3
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
287 void
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
288 X_ShowCursor(void) {
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
289 XDefineCursor(disp, win, 0);
1
769b155a34f9 Initial revision
darius
parents:
diff changeset
290 }
769b155a34f9 Initial revision
darius
parents:
diff changeset
291
3
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
292 void
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
293 X_HideCursor(void) {
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
294 Cursor no_ptr;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
295 Pixmap bm_no;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
296 XColor black , dummy;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
297 Colormap colormap;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
298 static unsigned char bm_no_data[] = {0, 0, 0, 0, 0, 0, 0, 0};
1
769b155a34f9 Initial revision
darius
parents:
diff changeset
299
3
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
300 colormap = DefaultColormap(disp, DefaultScreen(disp));
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
301 XAllocNamedColor(disp, colormap, "black", &black, &dummy);
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
302 bm_no = XCreateBitmapFromData(disp, win, bm_no_data, 8, 8);
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
303 no_ptr = XCreatePixmapCursor(disp, bm_no, bm_no, &black, &black, 0, 0);
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
304
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
305 XDefineCursor(disp, win, no_ptr);
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
306 XFreeCursor(disp, no_ptr);
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
307 if (bm_no != None)
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
308 XFreePixmap(disp, bm_no);
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
309
1
769b155a34f9 Initial revision
darius
parents:
diff changeset
310 }
769b155a34f9 Initial revision
darius
parents:
diff changeset
311
769b155a34f9 Initial revision
darius
parents:
diff changeset
312 /*
769b155a34f9 Initial revision
darius
parents:
diff changeset
313 * Sends the EWMH fullscreen state event.
3
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
314 *
1
769b155a34f9 Initial revision
darius
parents:
diff changeset
315 * action: could be on of _NET_WM_STATE_REMOVE -- remove state
769b155a34f9 Initial revision
darius
parents:
diff changeset
316 * _NET_WM_STATE_ADD -- add state
769b155a34f9 Initial revision
darius
parents:
diff changeset
317 * _NET_WM_STATE_TOGGLE -- toggle
769b155a34f9 Initial revision
darius
parents:
diff changeset
318 */
3
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
319 #define _NET_WM_STATE_REMOVE 0 /* remove/unset property */
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
320 #define _NET_WM_STATE_ADD 1 /* add/set property */
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
321 #define _NET_WM_STATE_TOGGLE 2 /* toggle property */
1
769b155a34f9 Initial revision
darius
parents:
diff changeset
322 void
769b155a34f9 Initial revision
darius
parents:
diff changeset
323 vo_x11_ewmh_fullscreen(int action) {
3
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
324 XEvent xev;
1
769b155a34f9 Initial revision
darius
parents:
diff changeset
325
3
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
326 assert(action == _NET_WM_STATE_REMOVE ||
7
210d197c77f9 Tolerate LIRC going away.
darius
parents: 6
diff changeset
327 action == _NET_WM_STATE_ADD || action == _NET_WM_STATE_TOGGLE);
1
769b155a34f9 Initial revision
darius
parents:
diff changeset
328
769b155a34f9 Initial revision
darius
parents:
diff changeset
329
3
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
330 /* init X event structure for _NET_WM_FULLSCREEN client msg */
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
331 xev.xclient.type = ClientMessage;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
332 xev.xclient.serial = 0;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
333 xev.xclient.send_event = True;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
334 xev.xclient.message_type = XInternAtom(disp, "_NET_WM_STATE", False);
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
335 xev.xclient.window = win;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
336 xev.xclient.format = 32;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
337 xev.xclient.data.l[0] = action;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
338 xev.xclient.data.l[1] = XInternAtom(disp, "_NET_WM_STATE_FULLSCREEN", False);
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
339 xev.xclient.data.l[2] = 0;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
340 xev.xclient.data.l[3] = 0;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
341 xev.xclient.data.l[4] = 0;
1
769b155a34f9 Initial revision
darius
parents:
diff changeset
342
3
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
343 /* finally send that damn thing */
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
344 if (!XSendEvent(disp, DefaultRootWindow(disp), False,
7
210d197c77f9 Tolerate LIRC going away.
darius
parents: 6
diff changeset
345 SubstructureRedirectMask | SubstructureNotifyMask,
210d197c77f9 Tolerate LIRC going away.
darius
parents: 6
diff changeset
346 &xev)) {
3
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
347 fprintf(stderr, "Failed to send fullscreen command\n");
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
348 }
1
769b155a34f9 Initial revision
darius
parents:
diff changeset
349 }
769b155a34f9 Initial revision
darius
parents:
diff changeset
350
769b155a34f9 Initial revision
darius
parents:
diff changeset
351
3
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
352 void
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
353 X_Setup(int w, int h) {
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
354 XGCValues gcvals;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
355 Window root;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
356 XVisualInfo vinfo_pref;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
357 int num_vis;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
358 XPixmapFormatValues *pf;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
359 int num_pf , pfi, i, j;
5
8b6b46a1261d - Move to 5.x+ includes
darius
parents: 3
diff changeset
360 XSizeHints sz_hint;
8b6b46a1261d - Move to 5.x+ includes
darius
parents: 3
diff changeset
361
3
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
362 disp = XOpenDisplay(NULL);
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
363 if (!disp) {
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
364 fprintf(stderr, "X-Error: unable to connect to display\n");
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
365 exit(1);
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
366 }
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
367 XSynchronize(disp, True);
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
368
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
369 scr = DefaultScreen(disp);
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
370 vis = DefaultVisual(disp, scr);
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
371 root = DefaultRootWindow(disp);
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
372 depth = DefaultDepth(disp, scr);
1
769b155a34f9 Initial revision
darius
parents:
diff changeset
373
3
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
374 vinfo_pref.screen = scr;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
375 vinfo_pref.visualid = XVisualIDFromVisual(vis);
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
376 vi = XGetVisualInfo(disp, VisualScreenMask | VisualIDMask,
7
210d197c77f9 Tolerate LIRC going away.
darius
parents: 6
diff changeset
377 &vinfo_pref, &num_vis);
3
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
378 assert(num_vis == 1);
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
379
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
380 win = XCreateSimpleWindow(disp, root, 0, 0, w, h, 0, 0, 0);
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
381 gc = XCreateGC(disp, win, (unsigned long)0, &gcvals);
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
382 XSetForeground(disp, gc, 0);
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
383 XSetBackground(disp, gc, 1);
1
769b155a34f9 Initial revision
darius
parents:
diff changeset
384
3
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
385 XMapWindow(disp, win);
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
386 cmap = DefaultColormap(disp, scr);
5
8b6b46a1261d - Move to 5.x+ includes
darius
parents: 3
diff changeset
387
8b6b46a1261d - Move to 5.x+ includes
darius
parents: 3
diff changeset
388 sz_hint.flags = PAspect;
8b6b46a1261d - Move to 5.x+ includes
darius
parents: 3
diff changeset
389 sz_hint.min_aspect.x = width;
8b6b46a1261d - Move to 5.x+ includes
darius
parents: 3
diff changeset
390 sz_hint.min_aspect.y = height;
8b6b46a1261d - Move to 5.x+ includes
darius
parents: 3
diff changeset
391 sz_hint.max_aspect.x = width;
8b6b46a1261d - Move to 5.x+ includes
darius
parents: 3
diff changeset
392 sz_hint.max_aspect.y = height;
8b6b46a1261d - Move to 5.x+ includes
darius
parents: 3
diff changeset
393
8b6b46a1261d - Move to 5.x+ includes
darius
parents: 3
diff changeset
394 /* set min height/width to 4 to avoid off by one errors */
8b6b46a1261d - Move to 5.x+ includes
darius
parents: 3
diff changeset
395 sz_hint.min_width = sz_hint.min_height = 4;
8b6b46a1261d - Move to 5.x+ includes
darius
parents: 3
diff changeset
396 sz_hint.flags |= PMinSize;
8b6b46a1261d - Move to 5.x+ includes
darius
parents: 3
diff changeset
397 XSetWMNormalHints(disp, win, &sz_hint);
8b6b46a1261d - Move to 5.x+ includes
darius
parents: 3
diff changeset
398
3
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
399 XSync(disp, False);
1
769b155a34f9 Initial revision
darius
parents:
diff changeset
400
3
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
401 /* Setup with Xv extension */
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
402 xv_adaptor = -1;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
403 xv_format_id = -1;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
404 XvQueryAdaptors(disp, root, &xv_num_adaptors, &xv_adaptors);
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
405 for (i = 0; i < xv_num_adaptors; i++) {
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
406 XvAdaptorInfo *adaptor = &xv_adaptors[i];
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
407 int takes_images;
1
769b155a34f9 Initial revision
darius
parents:
diff changeset
408
3
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
409 takes_images = adaptor->type & (XvInputMask | XvImageMask);
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
410 if (takes_images) {
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
411 XvImageFormatValues *formats;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
412 int num_formats;
1
769b155a34f9 Initial revision
darius
parents:
diff changeset
413
3
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
414 formats = XvListImageFormats(disp, adaptor->base_id, &num_formats);
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
415 for (j = 0; j < num_formats; j++)
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
416 if (formats[j].type == XvYUV && formats[j].format == XvPlanar &&
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
417 strcmp(formats[j].guid, "YV12") == 0)
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
418 break;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
419 if (j < num_formats) {
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
420 xv_adaptor = i;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
421 xv_format_id = formats[j].id;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
422 break;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
423 }
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
424 }
1
769b155a34f9 Initial revision
darius
parents:
diff changeset
425 }
3
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
426 assert(xv_adaptor >= 0);
1
769b155a34f9 Initial revision
darius
parents:
diff changeset
427
3
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
428 /* Create an image to captured frames */
1
769b155a34f9 Initial revision
darius
parents:
diff changeset
429 #ifdef USE_XVIMAGES
5
8b6b46a1261d - Move to 5.x+ includes
darius
parents: 3
diff changeset
430 yuv_image = XvShmCreateImage(disp, xv_adaptors[xv_adaptor].base_id,
7
210d197c77f9 Tolerate LIRC going away.
darius
parents: 6
diff changeset
431 xv_format_id, 0, w, h, &shminfo);
3
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
432 if (!yuv_image)
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
433 fprintf(stderr, "X-Error: unable to create XvShm XImage\n");
1
769b155a34f9 Initial revision
darius
parents:
diff changeset
434
3
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
435 shminfo.shmid = shmget(IPC_PRIVATE, yuv_image->data_size, IPC_CREAT | 0777);
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
436 if (shminfo.shmid == -1)
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
437 fprintf(stderr, "SharedMemory Error: unable to get identifier\n");
1
769b155a34f9 Initial revision
darius
parents:
diff changeset
438
3
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
439 shminfo.shmaddr = yuv_image->data = shmat(shminfo.shmid, 0, 0);
5
8b6b46a1261d - Move to 5.x+ includes
darius
parents: 3
diff changeset
440 yuv_image->data = shminfo.shmaddr;
1
769b155a34f9 Initial revision
darius
parents:
diff changeset
441 #else
3
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
442 rgb_image = XShmCreateImage(disp, vis, depth, ZPixmap, NULL, &shminfo, w, h);
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
443 if (!rgb_image)
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
444 fprintf(stderr, "X-Error: unable to create XShm XImage\n");
1
769b155a34f9 Initial revision
darius
parents:
diff changeset
445
3
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
446 shminfo.shmid = shmget(IPC_PRIVATE,
7
210d197c77f9 Tolerate LIRC going away.
darius
parents: 6
diff changeset
447 rgb_image->bytes_per_line * rgb_image->height,
210d197c77f9 Tolerate LIRC going away.
darius
parents: 6
diff changeset
448 IPC_CREAT | 0777);
3
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
449 if (shminfo.shmid == -1)
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
450 fprintf(stderr, "SharedMemory Error: unable to get identifier\n");
1
769b155a34f9 Initial revision
darius
parents:
diff changeset
451
3
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
452 shminfo.shmaddr = rgb_image->data = shmat(shminfo.shmid, 0, 0);
1
769b155a34f9 Initial revision
darius
parents:
diff changeset
453 #endif
769b155a34f9 Initial revision
darius
parents:
diff changeset
454
3
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
455 if (!XShmAttach(disp, &shminfo))
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
456 fprintf(stderr, "X-Error: unable to attach XShm Shared Memory Segment\n");
1
769b155a34f9 Initial revision
darius
parents:
diff changeset
457
3
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
458 /* Create a pixmap for the window background */
1
769b155a34f9 Initial revision
darius
parents:
diff changeset
459 #ifdef OLD
3
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
460 pmap = XShmCreatePixmap(disp, win, shminfo.shmaddr, &shminfo, w, h, depth);
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
461 if (!pmap)
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
462 fprintf(stderr, "Unable to create pixmap\n");
1
769b155a34f9 Initial revision
darius
parents:
diff changeset
463 #endif
769b155a34f9 Initial revision
darius
parents:
diff changeset
464
3
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
465 /* Determine bits-per-pixel for pixmaps */
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
466 pf = XListPixmapFormats(disp, &num_pf);
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
467 assert(pf);
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
468 for (pfi = 0; pfi < num_pf; pfi++)
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
469 if (pf[pfi].depth == vi->depth)
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
470 break;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
471 assert(pfi < num_pf);
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
472 bits_per_pixel = pf[pfi].bits_per_pixel;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
473 XFree(pf);
1
769b155a34f9 Initial revision
darius
parents:
diff changeset
474
769b155a34f9 Initial revision
darius
parents:
diff changeset
475 #ifdef OLD
3
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
476 XSetWindowBackgroundPixmap(disp, win, pmap);
1
769b155a34f9 Initial revision
darius
parents:
diff changeset
477 #endif
769b155a34f9 Initial revision
darius
parents:
diff changeset
478 }
769b155a34f9 Initial revision
darius
parents:
diff changeset
479
769b155a34f9 Initial revision
darius
parents:
diff changeset
480 /*--------------------------------------------------------------------------*/
769b155a34f9 Initial revision
darius
parents:
diff changeset
481
3
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
482 void
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
483 X_Shutdown() {
6
f0cbbe964629 XShmDetach() both cases.
darius
parents: 5
diff changeset
484 XShmDetach(disp, &shminfo);
5
8b6b46a1261d - Move to 5.x+ includes
darius
parents: 3
diff changeset
485 #ifdef USE_XVIMAGES
8b6b46a1261d - Move to 5.x+ includes
darius
parents: 3
diff changeset
486 shmctl(shminfo.shmid, IPC_RMID, 0);
8b6b46a1261d - Move to 5.x+ includes
darius
parents: 3
diff changeset
487 shmdt(shminfo.shmaddr);
8b6b46a1261d - Move to 5.x+ includes
darius
parents: 3
diff changeset
488 XFree(yuv_image);
1
769b155a34f9 Initial revision
darius
parents:
diff changeset
489 #else
3
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
490 XDestroyImage(rgb_image);
1
769b155a34f9 Initial revision
darius
parents:
diff changeset
491 #endif
3
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
492 shmdt(shminfo.shmaddr);
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
493 shmctl(shminfo.shmid, IPC_RMID, 0);
1
769b155a34f9 Initial revision
darius
parents:
diff changeset
494 }
769b155a34f9 Initial revision
darius
parents:
diff changeset
495
769b155a34f9 Initial revision
darius
parents:
diff changeset
496
769b155a34f9 Initial revision
darius
parents:
diff changeset
497 /*--------------------------------------------------------------------------*/
769b155a34f9 Initial revision
darius
parents:
diff changeset
498
3
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
499 void
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
500 X_Display(void) {
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
501 int _w , _h, _d;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
502 Window _dw;
1
769b155a34f9 Initial revision
darius
parents:
diff changeset
503
769b155a34f9 Initial revision
darius
parents:
diff changeset
504 #ifdef USE_XVIMAGES
3
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
505 XGetGeometry(disp, win, &_dw, &_d, &_d, &_w, &_h, &_d, &_d);
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
506 XvShmPutImage(disp, xv_adaptors[xv_adaptor].base_id, win,
7
210d197c77f9 Tolerate LIRC going away.
darius
parents: 6
diff changeset
507 gc, yuv_image, 0, 0, yuv_image->width, yuv_image->height,
210d197c77f9 Tolerate LIRC going away.
darius
parents: 6
diff changeset
508 0, 0, _w, _h, True);
1
769b155a34f9 Initial revision
darius
parents:
diff changeset
509 #else
3
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
510 XShmPutImage(disp, win, gc, rgb_image, 0, 0, 0, 0,
7
210d197c77f9 Tolerate LIRC going away.
darius
parents: 6
diff changeset
511 rgb_image->width, rgb_image->height, False);
1
769b155a34f9 Initial revision
darius
parents:
diff changeset
512 #endif
3
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
513 XSync(disp, False);
1
769b155a34f9 Initial revision
darius
parents:
diff changeset
514 }
769b155a34f9 Initial revision
darius
parents:
diff changeset
515
769b155a34f9 Initial revision
darius
parents:
diff changeset
516 #define CMD_NONE 0
769b155a34f9 Initial revision
darius
parents:
diff changeset
517 #define CMD_CHNUP 1
769b155a34f9 Initial revision
darius
parents:
diff changeset
518 #define CMD_CHNDN 2
769b155a34f9 Initial revision
darius
parents:
diff changeset
519 #define CMD_MUTE 3
769b155a34f9 Initial revision
darius
parents:
diff changeset
520 #define CMD_QUIT 4
769b155a34f9 Initial revision
darius
parents:
diff changeset
521 #define CMD_RELOAD 5
769b155a34f9 Initial revision
darius
parents:
diff changeset
522 #define CMD_CURSOR 6
769b155a34f9 Initial revision
darius
parents:
diff changeset
523 #define CMD_VOLDN 7
769b155a34f9 Initial revision
darius
parents:
diff changeset
524 #define CMD_VOLUP 8
769b155a34f9 Initial revision
darius
parents:
diff changeset
525 #define CMD_FSTOGGLE 9
769b155a34f9 Initial revision
darius
parents:
diff changeset
526
769b155a34f9 Initial revision
darius
parents:
diff changeset
527 /*--------------------------------------------------------------------------*/
769b155a34f9 Initial revision
darius
parents:
diff changeset
528
3
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
529 int
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
530 main(int argc, char *argv[]) {
1
769b155a34f9 Initial revision
darius
parents:
diff changeset
531 #ifndef USE_XVIMAGES
3
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
532 HermesHandle conv;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
533 HermesFormat fmt_source, fmt_dest;
1
769b155a34f9 Initial revision
darius
parents:
diff changeset
534 #endif
3
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
535 XEvent e;
7
210d197c77f9 Tolerate LIRC going away.
darius
parents: 6
diff changeset
536 char *scratch_buf, *code, *c, *mixerdev;
210d197c77f9 Tolerate LIRC going away.
darius
parents: 6
diff changeset
537 int frames, channelidx, oldchan, mute, cursor, fd, ret, cmd;
210d197c77f9 Tolerate LIRC going away.
darius
parents: 6
diff changeset
538 int exitnow, mfd, uselirc, curvol;
3
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
539 struct timeval then, now, diff, lastmove;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
540 float rate;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
541 KeySym key;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
542 char text [255];
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
543 int channellist[] = {2, 7, 9, 10, 28};
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
544 struct lirc_config *config;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
545 struct pollfd fds[1];
7
210d197c77f9 Tolerate LIRC going away.
darius
parents: 6
diff changeset
546
3
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
547 #define NUMCHANS (sizeof(channellist) / sizeof(channellist[0]))
1
769b155a34f9 Initial revision
darius
parents:
diff changeset
548
3
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
549 channelidx = mute = cursor = 0;
1
769b155a34f9 Initial revision
darius
parents:
diff changeset
550
3
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
551 oldchan = channel = channellist[channelidx];
1
769b155a34f9 Initial revision
darius
parents:
diff changeset
552
769b155a34f9 Initial revision
darius
parents:
diff changeset
553 #ifndef USE_XVIMAGES
3
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
554 if (!Hermes_Init()) {
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
555 printf("Couldn't initialise Hermes!\n");
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
556 exit(1);
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
557 }
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
558 conv = Hermes_ConverterInstance(HERMES_CONVERT_NORMAL);
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
559 if (!conv) {
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
560 printf("Could not obtain converter instance from Hermes!\n");
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
561 exit(1);
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
562 }
1
769b155a34f9 Initial revision
darius
parents:
diff changeset
563 #endif
769b155a34f9 Initial revision
darius
parents:
diff changeset
564
3
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
565 X_Setup(width, height);
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
566 XSelectInput(disp, win, KeyReleaseMask | PointerMotionMask | ButtonPressMask | ButtonReleaseMask);
1
769b155a34f9 Initial revision
darius
parents:
diff changeset
567
3
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
568 X_HideCursor();
1
769b155a34f9 Initial revision
darius
parents:
diff changeset
569
3
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
570 /* Open Capture device */
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
571 Open();
1
769b155a34f9 Initial revision
darius
parents:
diff changeset
572
3
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
573 /* Open audio mixer */
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
574 mixerdev = "/dev/mixer";
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
575 if ((mfd = open(mixerdev, O_RDWR)) == -1)
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
576 fprintf(stderr, "Unable to open %s - %s\n", mixerdev, strerror(errno));
1
769b155a34f9 Initial revision
darius
parents:
diff changeset
577
3
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
578 /* Talk to LIRC */
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
579 if ((fd = lirc_init(basename(argv[0]), 1)) == -1) {
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
580 fprintf(stderr, "Unable to init lirc client library\n");
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
581 uselirc = 0;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
582 } else {
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
583 if (lirc_readconfig(NULL, &config, NULL) != 0) {
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
584 fprintf(stderr, "Unable to parse config file\n");
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
585 uselirc = 0;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
586 } else
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
587 uselirc = 1;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
588 fds[0].fd = fd;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
589 fds[0].events = POLLRDNORM;
1
769b155a34f9 Initial revision
darius
parents:
diff changeset
590 }
769b155a34f9 Initial revision
darius
parents:
diff changeset
591
3
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
592 #ifndef USE_XVIMAGES
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
593 /* Conversion from and to formats */
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
594 fmt_source.indexed = 0;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
595 fmt_source.bits = 32;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
596 fmt_source.r = 0xff0000;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
597 fmt_source.g = 0x00ff00;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
598 fmt_source.b = 0x0000ff;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
599 fmt_source.a = 0;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
600
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
601 fmt_dest.indexed = 0;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
602 fmt_dest.bits = bits_per_pixel;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
603 fmt_dest.r = vi->red_mask;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
604 fmt_dest.g = vi->green_mask;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
605 fmt_dest.b = vi->blue_mask;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
606 fmt_dest.a = 0;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
607 #else
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
608 scratch_buf = malloc(width * height);
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
609 #endif
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
610
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
611 frames = 0;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
612 gettimeofday(&then, NULL);
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
613 gettimeofday(&lastmove, NULL);
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
614
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
615 exitnow = 0;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
616
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
617 /* Capture loop */
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
618 while (1) {
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
619 if (frames == 50) {
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
620 gettimeofday(&now, NULL);
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
621 timersub(&now, &then, &diff);
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
622
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
623 rate = (float)frames / (float)(diff.tv_usec / 1000000.0 + diff.tv_sec);
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
624
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
625 printf("%d frames in %.2f seconds, rate %.2f\n", frames, (float)(diff.tv_usec / 1000000.0) + diff.tv_sec, rate);
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
626 gettimeofday(&then, NULL);
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
627 frames = 0;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
628 XResetScreenSaver(disp);
1
769b155a34f9 Initial revision
darius
parents:
diff changeset
629 }
3
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
630 frames++;
1
769b155a34f9 Initial revision
darius
parents:
diff changeset
631
3
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
632 timersub(&now, &lastmove, &diff);
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
633 if (((float)diff.tv_usec / 1000000.0 + (float)diff.tv_sec) > 2.0) {
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
634 if (cursor) {
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
635 X_HideCursor();
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
636 cursor = 0;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
637 }
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
638 } else {
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
639 if (!cursor) {
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
640 X_ShowCursor();
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
641 cursor = 1;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
642 }
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
643 }
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
644
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
645 if (XCheckMaskEvent(disp, PointerMotionMask, &e) && e.type == MotionNotify) {
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
646 gettimeofday(&lastmove, NULL);
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
647 }
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
648 cmd = CMD_NONE;
1
769b155a34f9 Initial revision
darius
parents:
diff changeset
649
3
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
650 if (XCheckMaskEvent(disp, ButtonReleaseMask, &e)) {
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
651 printf("e.type = %d\n", e.type);
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
652 cmd = CMD_MUTE;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
653 }
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
654 if (XCheckMaskEvent(disp, KeyReleaseMask, &e) && e.type == KeyRelease) {
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
655 gettimeofday(&lastmove, NULL);
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
656
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
657 XLookupString(&e.xkey, text, 255, &key, 0);
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
658 printf("Press - %c\n", text[0]);
1
769b155a34f9 Initial revision
darius
parents:
diff changeset
659
3
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
660 switch (text[0]) {
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
661 case 'q':
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
662 cmd = CMD_QUIT;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
663 break;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
664
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
665 case '=':
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
666 case '+':
1
769b155a34f9 Initial revision
darius
parents:
diff changeset
667 cmd = CMD_CHNUP;
3
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
668 break;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
669
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
670 case '-':
1
769b155a34f9 Initial revision
darius
parents:
diff changeset
671 cmd = CMD_CHNDN;
3
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
672 break;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
673
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
674 case 'h':
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
675 cmd = CMD_CURSOR;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
676 break;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
677
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
678 case 'm':
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
679 cmd = CMD_MUTE;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
680 break;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
681
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
682 case 'r':
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
683 cmd = CMD_RELOAD;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
684 break;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
685
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
686 case ',':
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
687 cmd = CMD_VOLDN;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
688 break;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
689
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
690 case '.':
1
769b155a34f9 Initial revision
darius
parents:
diff changeset
691 cmd = CMD_VOLUP;
3
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
692 break;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
693
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
694 case 'f':
1
769b155a34f9 Initial revision
darius
parents:
diff changeset
695 cmd = CMD_FSTOGGLE;
3
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
696 break;
1
769b155a34f9 Initial revision
darius
parents:
diff changeset
697 }
3
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
698 }
7
210d197c77f9 Tolerate LIRC going away.
darius
parents: 6
diff changeset
699
3
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
700 /* Poll for IR events */
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
701 if (uselirc) {
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
702 fds[0].revents = 0;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
703
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
704 while (1) {
7
210d197c77f9 Tolerate LIRC going away.
darius
parents: 6
diff changeset
705
3
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
706 if (poll(fds, 1, 0) == -1) {
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
707 fprintf(stderr, "Poll failed - %s\n", strerror(errno));
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
708 exit(EXIT_FAILURE);
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
709 }
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
710 if ((fds[0].revents & POLLRDNORM) != 0) {
7
210d197c77f9 Tolerate LIRC going away.
darius
parents: 6
diff changeset
711 fprintf(stderr, "Processing IR.. \n", lircfails);
3
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
712
7
210d197c77f9 Tolerate LIRC going away.
darius
parents: 6
diff changeset
713 /* Try and get an event */
3
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
714 if (lirc_nextcode(&code) == 0) {
7
210d197c77f9 Tolerate LIRC going away.
darius
parents: 6
diff changeset
715 if (code == NULL) {
3
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
716 continue;
7
210d197c77f9 Tolerate LIRC going away.
darius
parents: 6
diff changeset
717 }
210d197c77f9 Tolerate LIRC going away.
darius
parents: 6
diff changeset
718
210d197c77f9 Tolerate LIRC going away.
darius
parents: 6
diff changeset
719 /* Translate it (via the config file) */
3
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
720 while ((ret = lirc_code2char(config, code, &c)) == 0 &&
7
210d197c77f9 Tolerate LIRC going away.
darius
parents: 6
diff changeset
721 c != NULL) {
3
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
722 fprintf(stderr, "Got command \"%s\"\n", c);
1
769b155a34f9 Initial revision
darius
parents:
diff changeset
723
3
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
724 if (!strcmp(c, "Mute"))
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
725 cmd = CMD_MUTE;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
726 else if (!strcmp(c, "CH_UP"))
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
727 cmd = CMD_CHNUP;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
728 else if (!strcmp(c, "CH_DOWN"))
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
729 cmd = CMD_CHNDN;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
730 else if (!strcmp(c, "Power"))
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
731 cmd = CMD_QUIT;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
732 else if (!strcmp(c, "VOL_UP"))
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
733 cmd = CMD_VOLUP;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
734 else if (!strcmp(c, "VOL_DOWN"))
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
735 cmd = CMD_VOLDN;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
736 else if (!strcmp(c, "AV/TV"))
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
737 cmd = CMD_FSTOGGLE;
7
210d197c77f9 Tolerate LIRC going away.
darius
parents: 6
diff changeset
738
3
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
739 free(code);
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
740 }
7
210d197c77f9 Tolerate LIRC going away.
darius
parents: 6
diff changeset
741 } else {
210d197c77f9 Tolerate LIRC going away.
darius
parents: 6
diff changeset
742 /* lircd probably died */
210d197c77f9 Tolerate LIRC going away.
darius
parents: 6
diff changeset
743 uselirc = 0;
210d197c77f9 Tolerate LIRC going away.
darius
parents: 6
diff changeset
744 fprintf(stderr, "Failed to communicate with LIRC - daemon exited?");
3
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
745 }
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
746 } else
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
747 break;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
748 }
1
769b155a34f9 Initial revision
darius
parents:
diff changeset
749 }
3
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
750 switch (cmd) {
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
751 case CMD_QUIT:
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
752 exitnow = 1;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
753 break;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
754
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
755 case CMD_CHNUP:
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
756 case CMD_CHNDN:
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
757 if (cmd == CMD_CHNUP)
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
758 channelidx++;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
759 else
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
760 channelidx--;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
761
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
762 if (channelidx < 0)
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
763 channelidx = NUMCHANS - 1;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
764 if (channelidx > NUMCHANS - 1)
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
765 channelidx = 0;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
766
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
767 channel = channellist[channelidx];
1
769b155a34f9 Initial revision
darius
parents:
diff changeset
768
3
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
769 printf("Channel - %d\n", channel);
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
770 if (oldchan != channel) {
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
771 oldchan = channel;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
772
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
773 if (ioctl(tuner_fd, TVTUNER_SETCHNL, &channel) < 0) {
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
774 DO_IOCTL_SERR("TVTUNER_SETCHNL", channel);
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
775 exit(1);
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
776 }
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
777 }
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
778 break;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
779
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
780 case CMD_MUTE:
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
781 if (mute)
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
782 mute = 0;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
783 else
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
784 mute = 1;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
785
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
786 printf("Mute - %d\n", mute);
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
787 if (ioctl(tuner_fd, BT848_SAUDIO, &mute) < 0) {
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
788 DO_IOCTL_SERR("BT848_SAUDIO", mute);
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
789 exit(1);
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
790 }
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
791 break;
1
769b155a34f9 Initial revision
darius
parents:
diff changeset
792
3
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
793 case CMD_CURSOR:
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
794 if (cursor) {
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
795 printf("Cursor hidden\n");
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
796 X_HideCursor();
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
797 cursor = 0;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
798 } else {
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
799 printf("Cursor revealed\n");
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
800 X_ShowCursor();
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
801 cursor = 1;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
802 }
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
803 break;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
804
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
805 case CMD_RELOAD:
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
806 printf("Reloading\n");
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
807 Close();
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
808 Open();
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
809 break;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
810
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
811 case CMD_VOLUP:
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
812 case CMD_VOLDN:
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
813 if (ioctl(mfd, MIXER_READ(SOUND_MIXER_VOLUME), &curvol) == -1) {
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
814 fprintf(stderr, "Unable to read current volume - %s\n", strerror(errno));
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
815 break;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
816 }
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
817 curvol = curvol & 0x7f;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
818
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
819 if (cmd == CMD_VOLUP)
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
820 curvol += 5;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
821 else
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
822 curvol -= 5;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
823
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
824 if (curvol < 0)
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
825 curvol = 0;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
826 if (curvol > 100)
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
827 curvol = 100;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
828
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
829 printf("Setting volume to %d\n", curvol);
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
830 curvol |= curvol << 8;
1
769b155a34f9 Initial revision
darius
parents:
diff changeset
831
3
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
832 if (ioctl(mfd, MIXER_WRITE(SOUND_MIXER_VOLUME), &curvol) == -1) {
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
833 fprintf(stderr, "Unable to write volume - %s\n", strerror(errno));
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
834 break;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
835 }
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
836 break;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
837
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
838 case CMD_FSTOGGLE:
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
839 vo_x11_ewmh_fullscreen(_NET_WM_STATE_TOGGLE);
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
840 break;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
841
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
842 }
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
843
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
844 Capture();
1
769b155a34f9 Initial revision
darius
parents:
diff changeset
845
3
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
846 #ifdef USE_XVIMAGES
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
847 /* bktr's YUV_12 is planar W*H bytes Y, W/2*H/2 bytes U, */
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
848 /* W/2*H/2 bytes V. Xv's YV12 is the same with U and V */
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
849 /* planes reversed. */
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
850 {
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
851 int y_off , u_off, v_off;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
852 y_off = 0;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
853 u_off = width * height;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
854 v_off = u_off + width * height / 4;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
855
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
856 assert(yuv_image->data_size == width * height * 3 / 2);
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
857 memcpy(yuv_image->data, bktr_buffer, u_off - y_off);
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
858 memcpy(yuv_image->data + u_off, bktr_buffer + v_off, v_off - u_off);
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
859 memcpy(yuv_image->data + v_off, bktr_buffer + u_off, v_off - u_off);
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
860 }
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
861 #else
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
862 /* SaveImage(); */
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
863
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
864 Hermes_ConverterRequest(conv, &fmt_source, &fmt_dest);
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
865 Hermes_ConverterCopy(conv, bktr_buffer, 0, 0, width, height, width * 4,
7
210d197c77f9 Tolerate LIRC going away.
darius
parents: 6
diff changeset
866 rgb_image->data, 0, 0, width, height,
210d197c77f9 Tolerate LIRC going away.
darius
parents: 6
diff changeset
867 rgb_image->bytes_per_line);
3
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
868 #endif
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
869
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
870 X_Display();
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
871 if (exitnow) {
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
872 printf("quitting\n");
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
873 break;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
874 }
1
769b155a34f9 Initial revision
darius
parents:
diff changeset
875 }
769b155a34f9 Initial revision
darius
parents:
diff changeset
876
3
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
877 #ifndef USE_XVIMAGES
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
878 Hermes_ConverterReturn(conv);
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
879 Hermes_Done();
1
769b155a34f9 Initial revision
darius
parents:
diff changeset
880 #endif
769b155a34f9 Initial revision
darius
parents:
diff changeset
881
3
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
882 X_Shutdown();
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
883 lirc_freeconfig(config);
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
884 lirc_deinit();
1
769b155a34f9 Initial revision
darius
parents:
diff changeset
885
3
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
886 return 0;
1
769b155a34f9 Initial revision
darius
parents:
diff changeset
887 }