changeset 5:8b6b46a1261d

- Move to 5.x+ includes - XFree the Xv image - Ask the WM to keep the window aspect 4:3
author darius
date Tue, 28 Jun 2005 13:12:39 +0000
parents 8f7cda8e4af8
children f0cbbe964629
files simpletv.c
diffstat 1 files changed, 23 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/simpletv.c	Tue Jan 04 05:21:07 2005 +0000
+++ b/simpletv.c	Tue Jun 28 13:12:39 2005 +0000
@@ -46,8 +46,8 @@
 #include <sys/time.h>
 #include <libgen.h>
 #include <sys/soundcard.h>
-#include <machine/ioctl_bt848.h>
-#include <machine/ioctl_meteor.h>
+#include <dev/bktr/ioctl_bt848.h>
+#include <dev/bktr/ioctl_meteor.h>
 #include <machine/param.h>
 #include <sys/types.h>
 #include <sys/ipc.h>
@@ -147,10 +147,7 @@
 	geo.frames = 1;
 #ifdef USE_XVIMAGES
 	/* Should be YUV_12, but 422 actually gives a synced picture.  Though  */
-
-	/* geo.oformat = METEOR_GEO_YUV_12; */
 	geo.oformat = METEOR_GEO_YUV_422 | METEOR_GEO_YUV_12;
-	/* geo.oformat = METEOR_GEO_YUV_12; */
 #else
 	geo.oformat = METEOR_GEO_RGB24;
 #endif
@@ -359,7 +356,8 @@
 	int		num_vis;
 	XPixmapFormatValues *pf;
 	int		num_pf    , pfi, i, j;
-
+	XSizeHints	sz_hint;
+	
 	disp = XOpenDisplay(NULL);
 	if (!disp) {
 		fprintf(stderr, "X-Error: unable to connect to display\n");
@@ -385,6 +383,18 @@
 
 	XMapWindow(disp, win);
 	cmap = DefaultColormap(disp, scr);
+
+	sz_hint.flags = PAspect;
+	sz_hint.min_aspect.x = width;
+	sz_hint.min_aspect.y = height;
+	sz_hint.max_aspect.x = width;
+	sz_hint.max_aspect.y = height;
+
+	/* set min height/width to 4 to avoid off by one errors */
+	sz_hint.min_width = sz_hint.min_height = 4;
+	sz_hint.flags |= PMinSize;
+	XSetWMNormalHints(disp, win, &sz_hint);
+
 	XSync(disp, False);
 
 	/* Setup with Xv extension  */
@@ -416,8 +426,8 @@
 
 	/* Create an image to captured frames  */
 #ifdef USE_XVIMAGES
-	yuv_im		age = XvShmCreateImage(disp, xv_adaptors[xv_adaptor].base_id,
-	    xv_format_id, 0, w, h, &shminfo);
+	yuv_image = XvShmCreateImage(disp, xv_adaptors[xv_adaptor].base_id,
+					       xv_format_id, 0, w, h, &shminfo);
 	if (!yuv_image)
 		fprintf(stderr, "X-Error: unable to create XvShm XImage\n");
 
@@ -426,6 +436,7 @@
 		fprintf(stderr, "SharedMemory Error: unable to get identifier\n");
 
 	shminfo.shmaddr = yuv_image->data = shmat(shminfo.shmid, 0, 0);
+	yuv_image->data = shminfo.shmaddr;
 #else
 	rgb_image = XShmCreateImage(disp, vis, depth, ZPixmap, NULL, &shminfo, w, h);
 	if (!rgb_image)
@@ -469,9 +480,11 @@
 
 void
 X_Shutdown() {
+#ifdef USE_XVIMAGES
 	XShmDetach(disp, &shminfo);
-#ifdef USE_XVIMAGES
-#warning How do we destroy an XvImage?
+	shmctl(shminfo.shmid, IPC_RMID, 0);
+	shmdt(shminfo.shmaddr);
+	XFree(yuv_image);
 #else
 	XDestroyImage(rgb_image);
 #endif