[Gridflow-cvs] [svn] commit: r5412 - in /trunk/src: formats.cxx v4l2.cxx

svn-gridflow at artengine.ca svn-gridflow at artengine.ca
Thu Apr 8 23:53:45 EDT 2010


Author: matju
Date: Thu Apr  8 23:53:44 2010
New Revision: 5412

Log:
close v4l2 correctly. i'm not sure i understand what's going on here.

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

Modified: trunk/src/formats.cxx
==============================================================================
--- trunk/src/formats.cxx (original)
+++ trunk/src/formats.cxx Thu Apr  8 23:53:44 2010
@@ -122,7 +122,10 @@
 //		def self.rewind() raw_open(*@raw_open_args); @frame = 0 end unless @rewind_redefined
 //		@rewind_redefined = true
 }
-\def 0 close() {if (f) {fclose(f); f=0; fd=-1;}}
+\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);
+}
 \def 0 cast(NumberTypeE nt) {cast = nt;}
 
 \def 0 seek(int frame) {
@@ -139,7 +142,7 @@
 	frame = 0;
 }
 
-Format::~Format () {if (f) fclose(f); /*if (fd>=0) close(fd);*/}
+Format::~Format () {_0_close(0,0);}
 \end class Format {}
 
 /* This is the Grid format I defined: */

Modified: trunk/src/v4l2.cxx
==============================================================================
--- trunk/src/v4l2.cxx (original)
+++ trunk/src/v4l2.cxx Thu Apr  8 23:53:44 2010
@@ -119,7 +119,7 @@
 		image=0;
 		fd = v4l2_open(filename.data(),0);
 		if (fd<0) RAISE("can't open device '%s': %s",filename.data(),strerror(errno));
-		f = fdopen(fd,"r+");
+		f=0;
 		initialize2();
 	}
 	void frame_finished (uint8 *buf);
@@ -128,7 +128,10 @@
 	void dealloc_image ();
 	void frame_ask ();
 	void initialize2 ();
-	~FormatV4L2 () {if (image) dealloc_image();}
+	~FormatV4L2 () {
+		if (image) dealloc_image();
+		close(fd); fd=-1; /* can be v4l2_close, not same as in formats.cxx */
+	}
 
 	\decl 0 bang ();
 	\grin 0 int



More information about the Gridflow-cvs mailing list