summaryrefslogtreecommitdiff
path: root/orkbasecxx/ImmediateProcessing.cpp
diff options
context:
space:
mode:
authorHenri Herscher <henri@oreka.org>2007-07-30 14:32:19 +0000
committerHenri Herscher <henri@oreka.org>2007-07-30 14:32:19 +0000
commit72fda6ebe7d6245b57178441c6355eb9d2402747 (patch)
treed5683a93b1e4d0efee26995caeeccd55faae0d8c /orkbasecxx/ImmediateProcessing.cpp
parent483b0c94e1754d01c934dc3421527fc6eefa3ebd (diff)
Added non-lookback recording mode.
git-svn-id: https://oreka.svn.sourceforge.net/svnroot/oreka/trunk@458 09dcff7a-b715-0410-9601-b79a96267cd0
Diffstat (limited to 'orkbasecxx/ImmediateProcessing.cpp')
-rw-r--r--orkbasecxx/ImmediateProcessing.cpp101
1 files changed, 101 insertions, 0 deletions
diff --git a/orkbasecxx/ImmediateProcessing.cpp b/orkbasecxx/ImmediateProcessing.cpp
new file mode 100644
index 0000000..1ac414c
--- /dev/null
+++ b/orkbasecxx/ImmediateProcessing.cpp
@@ -0,0 +1,101 @@
+/*
+ * Oreka -- A media capture and retrieval platform
+ *
+ * Copyright (C) 2005, orecx LLC
+ *
+ * http://www.orecx.com
+ *
+ * This program is free software, distributed under the terms of
+ * the GNU General Public License.
+ * Please refer to http://www.gnu.org/copyleft/gpl.html
+ *
+ */
+#pragma warning( disable: 4786 )
+
+#define _WINSOCKAPI_ // prevents the inclusion of winsock.h
+
+#include "ImmediateProcessing.h"
+#include "LogManager.h"
+#include "ace/OS_NS_unistd.h"
+#include "BatchProcessing.h"
+#include "Daemon.h"
+#include "ConfigManager.h"
+#include "TapeProcessor.h"
+
+
+ImmediateProcessing ImmediateProcessing::m_immediateProcessingSingleton;
+
+ImmediateProcessing::ImmediateProcessing()
+{
+ m_lastQueueFullTime = time(NULL);
+}
+
+ImmediateProcessing* ImmediateProcessing::GetInstance()
+{
+ return &m_immediateProcessingSingleton;
+}
+
+void ImmediateProcessing::AddAudioTape(AudioTapeRef audioTapeRef)
+{
+ if (!m_audioTapeQueue.push(audioTapeRef))
+ {
+ if( (time(NULL) - m_lastQueueFullTime) > 10 )
+ {
+ m_lastQueueFullTime = time(NULL);
+ LOG4CXX_ERROR(LOG.immediateProcessingLog, CStdString("ImmediateProcessing: queue full"));
+ }
+ }
+}
+
+void ImmediateProcessing::SetQueueSize(int size)
+{
+ m_audioTapeQueue.setSize(size);
+}
+
+
+void ImmediateProcessing::ThreadHandler(void *args)
+{
+ CStdString logMsg;
+
+ ImmediateProcessing* pImmediateProcessing = ImmediateProcessing::GetInstance();
+ pImmediateProcessing->SetQueueSize(CONFIG.m_immediateProcessingQueueSize);
+
+ logMsg.Format("thread starting - queue size:%d", CONFIG.m_immediateProcessingQueueSize);
+ LOG4CXX_INFO(LOG.immediateProcessingLog, logMsg);
+
+ bool stop = false;
+
+ for(;stop == false;)
+ {
+ try
+ {
+ AudioTapeRef audioTapeRef = pImmediateProcessing->m_audioTapeQueue.pop();
+
+ if(audioTapeRef.get() == NULL)
+ {
+ if(Daemon::Singleton()->IsStopping())
+ {
+ stop = true;
+ }
+ }
+ else
+ {
+ //LOG4CXX_DEBUG(LOG.immediateProcessingLog, CStdString("Got chunk"));
+
+ audioTapeRef->Write();
+
+ if (audioTapeRef->IsReadyForBatchProcessing())
+ {
+ // Pass the tape to the tape processor chain
+ TapeProcessorRegistry::instance()->RunProcessingChain(audioTapeRef);
+ }
+ }
+ }
+ catch (CStdString& e)
+ {
+ LOG4CXX_ERROR(LOG.immediateProcessingLog, CStdString("ImmediateProcessing: ") + e);
+ }
+ }
+ LOG4CXX_INFO(LOG.immediateProcessingLog, CStdString("Exiting thread"));
+}
+