[Gridflow-cvs] [svn] commit: r5554 - /trunk/src/quicktimecamera.cxx

svn-gridflow at artengine.ca svn-gridflow at artengine.ca
Tue Apr 27 00:13:11 EDT 2010


Author: pboivin
Date: Tue Apr 27 00:13:11 2010
New Revision: 5554

Log:
prevent crash when opening the same camera twice

Modified:
    trunk/src/quicktimecamera.cxx

Modified: trunk/src/quicktimecamera.cxx
==============================================================================
--- trunk/src/quicktimecamera.cxx (original)
+++ trunk/src/quicktimecamera.cxx Tue Apr 27 00:13:11 2010
@@ -32,6 +32,8 @@
 #include <CoreServices/CoreServices.h>
 #include <map>
 extern std::map<long,const char *> oserr_table;
+
+#define DEBUG false
 
 typedef ComponentInstance VideoDigitizerComponent, VDC;
 typedef ComponentResult   VideoDigitizerError,     VDE;
@@ -223,7 +225,6 @@
 		//post("  info=%08x, *info='%*s'",info, *name, info+1);
 		n++;
 	}
-	//post("  number of components: %d",n);
 	m_sg = OpenDefaultComponent(SeqGrabComponentType, 0);
 	if(!m_sg) RAISE("could not open default component");
 	e=SGInitialize(m_sg);
@@ -231,19 +232,18 @@
 	e=SGSetDataRef(m_sg, 0, 0, seqGrabDontMakeMovie);
 	if (e!=noErr) RAISE("dataref failed");
 	e=SGNewChannel(m_sg, VideoMediaType, &m_vc);
-	if(e!=noErr) post("could not make new SG channel");
+	if(e!=noErr) RAISE("could not make new SG channel");
 	e=SGSetChannelBounds(m_vc, &rect);
-	if(e!=noErr) post("could not set SG ChannelBounds");
-	
+	if(e!=noErr) RAISE("could not set SG ChannelBounds");
 	e=SGGetChannelDeviceList(m_vc, sgDeviceListIncludeInputs, &deviceList);
-	if (e!=noErr) post("could not get device list");
+	if (e!=noErr) RAISE("could not get device list");
 	else {
 		nDevices = (*deviceList)->count;
-		//post("  number of available devices: %d", nDevices); 
-		//post("  current device: %d", (*deviceList)->selectedIndex);
-		//for (int i=0; i<nDevices; i++) post("  Device %d: %s", i, (*deviceList)->entry[i].name);
-	}
-    
+		//fprintf(stderr,"  number of available devices: %d\n", nDevices); 
+		//fprintf(stderr,"  current device: %d\n", (*deviceList)->selectedIndex);
+		//for (int i=0; i<nDevices; i++) fprintf(stderr,"  Device %d: '%.*s'\n", i, *(*deviceList)->entry[i].name,1+(*deviceList)->entry[i].name);
+	}
+
 	// treat the device list in reverse order
 	device = nDevices-1-device;
 	e=SGSetChannelDevice(m_vc, (*deviceList)->entry[device].name);
@@ -312,11 +312,11 @@
 \def 0 size (int height, int width) {
 	OSErr e = VDGetDigitizerRect(vdc,&rect);
 	if (e!=noErr) RAISE("VDGetDigitizerRect error");
-	post("rect1: top=%d left=%d bottom=%d right=%d",rect.top,rect.left,rect.bottom,rect.right);
+	if (DEBUG) post("rect1: top=%d left=%d bottom=%d right=%d",rect.top,rect.left,rect.bottom,rect.right);
 	dim = new Dim(height,width,dim->v[2]);
 	rect.bottom = height;
 	rect.right = width;
-	post("rect2: top=%d left=%d bottom=%d right=%d",rect.top,rect.left,rect.bottom,rect.right);
+	if (DEBUG) post("rect2: top=%d left=%d bottom=%d right=%d",rect.top,rect.left,rect.bottom,rect.right);
 	e = VDSetDigitizerRect(vdc,&rect);
 	if (e!=noErr) post("VDSetDigitizerRect error");
 	e = SGSetChannelBounds(m_vc,&rect);
@@ -329,12 +329,14 @@
 		DigitizerInfo di;
 		OSErr e = VDGetDigitizerInfo(vdc,&di);
 		if (e!=noErr) RAISE("VDGetDigitizerInfo error");
-		post("vdigType=%d inputCapabilityFlags=0x%08x outputCapabilityFlags=0x%08x inputCurrentFlags=0x%08x outputCurrentFlags=0x%08x",
-			di.vdigType, di.inputCapabilityFlags, di.outputCapabilityFlags, di.inputCurrentFlags, di.outputCurrentFlags);
-		post("slot=%d gdh=%p maskgdh=%p",di.slot,di.gdh,di.maskgdh);
-		post("minDestHeight=%d minDestWidth=%d maxDestHeight=%d maxDestWidth=%d",
-			di.minDestHeight, di.minDestWidth, di.maxDestHeight, di.maxDestWidth);
-		post("blendLevels=%d reserved=%d",di.blendLevels,di.reserved);
+		if (DEBUG) {
+			post("vdigType=%d inputCapabilityFlags=0x%08x outputCapabilityFlags=0x%08x inputCurrentFlags=0x%08x outputCurrentFlags=0x%08x",
+				di.vdigType, di.inputCapabilityFlags, di.outputCapabilityFlags, di.inputCurrentFlags, di.outputCurrentFlags);
+			post("slot=%d gdh=%p maskgdh=%p",di.slot,di.gdh,di.maskgdh);
+			post("minDestHeight=%d minDestWidth=%d maxDestHeight=%d maxDestWidth=%d",
+				di.minDestHeight, di.minDestWidth, di.maxDestHeight, di.maxDestWidth);
+			post("blendLevels=%d reserved=%d",di.blendLevels,di.reserved);
+		}
 		//Rect r;
 		//OSErr e = SGGetChannelBounds (m_vc,&r);
 		//if (e!=noErr) RAISE("SGGetChannelBounds error");



More information about the Gridflow-cvs mailing list