Update of /cvsroot/artoolkit/artoolkit/lib/SRC/VideoWin32DirectShow
In directory sc8-pr-cvs11.sourceforge.net:/tmp/cvs-serv21353/lib/SRC/VideoWin32DirectShow
Modified Files:
videoWin32DirectShow.cpp
Log Message:
Fix bug where mem buffers would be checked in before being checked out.
Index: videoWin32DirectShow.cpp
===================================================================
RCS file: /cvsroot/artoolkit/artoolkit/lib/SRC/VideoWin32DirectShow/videoWin32DirectShow.cpp,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -d -r1.7 -r1.8
*** videoWin32DirectShow.cpp 8 Jun 2006 21:35:58 -0000 1.7
--- videoWin32DirectShow.cpp 29 Aug 2006 04:19:16 -0000 1.8
***************
*** 51,54 ****
--- 51,55 ----
DSVL_VideoSource *graphManager;
MemoryBufferHandle g_Handle;
+ bool bufferCheckedOut;
__int64 g_Timestamp; // deprecated, use (g_Handle.t) instead.
//bool flip_horizontal = false; // deprecated.
***************
*** 155,167 ****
vid->graphManager = new DSVL_VideoSource();
if (!config) {
! if(FAILED(vid->graphManager->BuildGraphFromXMLString(config_default))) return(NULL);
} else {
if (strncmp(config, "<?xml", 5) == 0) {
! if(FAILED(vid->graphManager->BuildGraphFromXMLString(config))) return(NULL);
} else {
! if(FAILED(vid->graphManager->BuildGraphFromXMLFile(config))) return(NULL);
}
}
! if(FAILED(vid->graphManager->EnableMemoryBuffer())) return(NULL);
return (vid);
--- 156,168 ----
vid->graphManager = new DSVL_VideoSource();
if (!config) {
! if (FAILED(vid->graphManager->BuildGraphFromXMLString(config_default))) return(NULL);
} else {
if (strncmp(config, "<?xml", 5) == 0) {
! if (FAILED(vid->graphManager->BuildGraphFromXMLString(config))) return(NULL);
} else {
! if (FAILED(vid->graphManager->BuildGraphFromXMLFile(config))) return(NULL);
}
}
! if (FAILED(vid->graphManager->EnableMemoryBuffer())) return(NULL);
return (vid);
***************
*** 174,178 ****
if (vid->graphManager == NULL) return (-1);
! vid->graphManager->CheckinMemoryBuffer(vid->g_Handle, true);
vid->graphManager->Stop();
delete vid->graphManager;
--- 175,179 ----
if (vid->graphManager == NULL) return (-1);
! if (vid->bufferCheckedOut) vid->graphManager->CheckinMemoryBuffer(vid->g_Handle, true);
vid->graphManager->Stop();
delete vid->graphManager;
***************
*** 191,199 ****
if (vid->graphManager == NULL) return (NULL);
wait_result = vid->graphManager->WaitForNextSample(frame_timeout_ms);
! if(wait_result == WAIT_OBJECT_0) {
if (FAILED(vid->graphManager->CheckoutMemoryBuffer(&(vid->g_Handle), &pixelBuffer, NULL, NULL, NULL, &(vid->g_Timestamp)))) return(NULL);
return (pixelBuffer);
}
return(NULL);
}
--- 192,206 ----
if (vid->graphManager == NULL) return (NULL);
+ if (vid->bufferCheckedOut) {
+ if (FAILED(vid->graphManager->CheckinMemoryBuffer(vid->g_Handle))) return (NULL);
+ vid->bufferCheckedOut = false;
+ }
wait_result = vid->graphManager->WaitForNextSample(frame_timeout_ms);
! if (wait_result == WAIT_OBJECT_0) {
if (FAILED(vid->graphManager->CheckoutMemoryBuffer(&(vid->g_Handle), &pixelBuffer, NULL, NULL, NULL, &(vid->g_Timestamp)))) return(NULL);
+ vid->bufferCheckedOut = true;
return (pixelBuffer);
}
+
return(NULL);
}
***************
*** 204,208 ****
if (vid->graphManager == NULL) return (-1);
! if(FAILED(vid->graphManager->Run())) return (-1);
return (0);
}
--- 211,215 ----
if (vid->graphManager == NULL) return (-1);
! if (FAILED(vid->graphManager->Run())) return (-1);
return (0);
}
***************
*** 213,217 ****
if (vid->graphManager == NULL) return (-1);
! vid->graphManager->CheckinMemoryBuffer(vid->g_Handle, true);
// PRL 2005-09-21: Commented out due to issue where stopping the
--- 220,227 ----
if (vid->graphManager == NULL) return (-1);
! if (vid->bufferCheckedOut) {
! if (FAILED(vid->graphManager->CheckinMemoryBuffer(vid->g_Handle, true))) return (-1);
! vid->bufferCheckedOut = false;
! }
// PRL 2005-09-21: Commented out due to issue where stopping the
***************
*** 228,232 ****
if (vid->graphManager == NULL) return (-1);
! return (SUCCEEDED(vid->graphManager->CheckinMemoryBuffer(vid->g_Handle)) ? 0 : -1);
}
--- 238,246 ----
if (vid->graphManager == NULL) return (-1);
! if (vid->bufferCheckedOut) {
! if (FAILED(vid->graphManager->CheckinMemoryBuffer(vid->g_Handle, true))) return (-1);
! vid->bufferCheckedOut = false;
! }
! return (0);
}
***************
*** 285,288 ****
--- 299,303 ----
if (FAILED(vid->graphManager->CheckoutMemoryBuffer(pHandle, &pixelBuffer))) return (NULL);
+ vid->bufferCheckedOut = true;
return (pixelBuffer);
***************
*** 295,299 ****
if (FAILED(vid->graphManager->CheckinMemoryBuffer(Handle))) return(-1);
!
return (0);
}
--- 310,315 ----
if (FAILED(vid->graphManager->CheckinMemoryBuffer(Handle))) return(-1);
! vid->bufferCheckedOut = false;
!
return (0);
}
|