[Gridflow-cvs] [svn] commit: r5415 - in /trunk/src: formats.cxx videodev.cxx

svn-gridflow at artengine.ca svn-gridflow at artengine.ca
Fri Apr 9 00:49:36 EDT 2010


Author: matju
Date: Fri Apr  9 00:49:35 2010
New Revision: 5415

Log:
[#in videodev]: use open() instead of fopen()

Modified:
    trunk/src/formats.cxx
    trunk/src/videodev.cxx

Modified: trunk/src/formats.cxx
==============================================================================
--- trunk/src/formats.cxx (original)
+++ trunk/src/formats.cxx Fri Apr  9 00:49:35 2010
@@ -124,7 +124,8 @@
 }
 \def 0 close() {
 	//post("CLOSE! f=%p fd=%d",f,fd);
-	if (f) {fclose(f); f=0; fd=-1;} else if (fd>=0) close(fd);
+	if (f) {fclose(f); f=0;}
+	if (fd>=0) {close(fd); fd=-1;} // ???
 }
 \def 0 cast(NumberTypeE nt) {cast = nt;}
 

Modified: trunk/src/videodev.cxx
==============================================================================
--- trunk/src/videodev.cxx (original)
+++ trunk/src/videodev.cxx Fri Apr  9 00:49:35 2010
@@ -39,7 +39,7 @@
 #include "pwc-ioctl.h"
 #include <sstream>
 
-#ifdef HAVE_LIBV4L1 // never defined (yet)
+#ifndef HAVE_LIBV4L1 // never defined (yet)
 #include <libv4l1.h>
 #define open   v4l1_open
 #define close  v4l1_close
@@ -211,9 +211,11 @@
 		has_tuner=false;
 		has_norm=false;
 		image=0;
-		f = fopen(filename.data(),"r+");
-		if (!f) RAISE("can't open device '%s': %s",filename.data(),strerror(errno));
-		fd = fileno(f);
+		//f = fopen(filename.data(),"r+");
+		//if (!f) RAISE("can't open device '%s': %s",filename.data(),strerror(errno));
+		//fd = fileno(f);
+		fd = open(filename.data(),O_RDWR);
+		if (fd<0) RAISE("can't open device '%s': %s",filename.data(),strerror(errno));
 		initialize2();
 	}
 	void frame_finished (uint8 *buf);
@@ -222,7 +224,10 @@
 	void dealloc_image ();
 	void frame_ask ();
 	void initialize2 ();
-	~FormatVideoDev () {if (image) dealloc_image();}
+	~FormatVideoDev () {
+		if (image) dealloc_image();
+		close(fd); // wtf
+	}
 
 	\decl 0 bang ();
 	\grin 0 int



More information about the Gridflow-cvs mailing list