[Jderobot-admin] jderobot-r1235 - trunk/src/stable/components/recorder

rocapal en jderobot.org rocapal en jderobot.org
Jue Mayo 29 13:18:57 CEST 2014


Author: rocapal
Date: 2014-05-29 13:18:57 +0200 (Thu, 29 May 2014)
New Revision: 1235

Modified:
   trunk/src/stable/components/recorder/RingBuffer.cpp
   trunk/src/stable/components/recorder/RingBuffer.h
Log:
#249 fixed bug about sync buffers


Modified: trunk/src/stable/components/recorder/RingBuffer.cpp
===================================================================
--- trunk/src/stable/components/recorder/RingBuffer.cpp	2014-05-29 10:40:01 UTC (rev 1234)
+++ trunk/src/stable/components/recorder/RingBuffer.cpp	2014-05-29 11:18:57 UTC (rev 1235)
@@ -43,8 +43,6 @@
 {
 
 	mBuffer.push_back(node);
-	//jderobot::Logger::getInstance()->info("Buffer Size: " + boost::lexical_cast<std::string>(mBuffer.size()));
-
 	return checkBuffer();
 }
 
@@ -59,7 +57,7 @@
 void RingBuffer::write_th()
 {
 	boost::posix_time::ptime init = boost::posix_time::microsec_clock::local_time();
-	for (std::vector<RingNode>::iterator it = mBuffer.begin(); it < mBuffer.end(); it++ )
+	for (std::vector<RingNode>::iterator it = mWriteBuffer.begin(); it < mWriteBuffer.end(); it++ )
 	{
 		std::stringstream path;
 		path << "data-" << mNameLog << "/images/camera" << it->cameraId << "/" << it->relativeTime << ".png";
@@ -68,9 +66,14 @@
 	boost::posix_time::ptime end = boost::posix_time::microsec_clock::local_time();
 
 	boost::posix_time::time_duration total = end - init;
-	std::cout << "Total milliseconds spent: " << total.total_milliseconds() << std::endl;
-	std::cout << "Total Size: " << mBuffer.size() << std::endl;
+	std::cout << "Total milliseconds spent: " << total.total_milliseconds() << " - " << "Total Size: " << mBuffer.size() << std::endl;
 
+	for (std::vector<RingNode>::iterator it = mWriteBuffer.begin(); it < mWriteBuffer.end(); it++ )
+		it->frame.release();
+
+
+	mWriteBuffer.clear();
+
 }
 
 void RingBuffer::write(std::string nameLog, std::vector<int> compression)
@@ -78,6 +81,12 @@
 	mCompression = compression;
 	mNameLog = nameLog;
 
+	mWriteBuffer.resize(mBuffer.size());
+	std::copy( mBuffer.begin(), mBuffer.end(), mWriteBuffer.begin() );
+
+	//std::cout << &(mBuffer[0].frame) << std::endl;
+	//std::cout << &(mWriteBuffer[0].frame) << std::endl;
+
 	pthread_attr_init(&mAttr);
 	pthread_attr_setdetachstate(&mAttr, PTHREAD_CREATE_JOINABLE);
 	pthread_create(&mThread, &mAttr, write_thread, this);

Modified: trunk/src/stable/components/recorder/RingBuffer.h
===================================================================
--- trunk/src/stable/components/recorder/RingBuffer.h	2014-05-29 10:40:01 UTC (rev 1234)
+++ trunk/src/stable/components/recorder/RingBuffer.h	2014-05-29 11:18:57 UTC (rev 1235)
@@ -56,6 +56,7 @@
 
 		long int mMaxBufferTime;
 		std::vector<RingNode> mBuffer;
+		std::vector<RingNode> mWriteBuffer;
 		std::vector<int> mCompression;
 
 		pthread_t mThread;



More information about the Jderobot-admin mailing list