summaryrefslogtreecommitdiff
path: root/orkbasecxx
diff options
context:
space:
mode:
authorGerald Begumisa <ben_g@users.sourceforge.net>2008-03-07 08:54:25 +0000
committerGerald Begumisa <ben_g@users.sourceforge.net>2008-03-07 08:54:25 +0000
commita6d2e0b990df35b552ef5fa25d695f043b120d70 (patch)
tree9d836d3c505f1786038603f392e9093e406b9051 /orkbasecxx
parentc8218d259f148e5eb267369a2e508d43570291c0 (diff)
Added feature that allows control over the CPU time which is given for transcoding purposes. Two configuration parameters, TranscodingSleepEveryNumFrames and TranscodingSleepUs have been added to config.xml. If both parameters have non-zero values then the transcoding thread will sleep for TranscodingSleepUs microseconds every TranscodingSleepEveryNumFrames which are transcoded.
git-svn-id: https://oreka.svn.sourceforge.net/svnroot/oreka/trunk@528 09dcff7a-b715-0410-9601-b79a96267cd0
Diffstat (limited to 'orkbasecxx')
-rw-r--r--orkbasecxx/BatchProcessing.cpp19
-rw-r--r--orkbasecxx/Config.cpp17
-rw-r--r--orkbasecxx/Config.h6
3 files changed, 42 insertions, 0 deletions
diff --git a/orkbasecxx/BatchProcessing.cpp b/orkbasecxx/BatchProcessing.cpp
index 95b8b8a..a2361a1 100644
--- a/orkbasecxx/BatchProcessing.cpp
+++ b/orkbasecxx/BatchProcessing.cpp
@@ -138,6 +138,9 @@ void BatchProcessing::ThreadHandler(void *args)
AudioChunkRef chunkRef;
AudioChunkRef tmpChunkRef;
+ unsigned int frameSleepCounter;
+
+ frameSleepCounter = 0;
switch(CONFIG.m_storageAudioFormat)
{
@@ -296,6 +299,22 @@ void BatchProcessing::ThreadHandler(void *args)
ts.tv_nsec = 1;
ACE_OS::nanosleep (&ts, NULL);
}
+
+ if(CONFIG.m_transcodingSleepEveryNumFrames > 0 && CONFIG.m_transcodingSleepUs > 0)
+ {
+ if(frameSleepCounter >= CONFIG.m_transcodingSleepEveryNumFrames)
+ {
+ frameSleepCounter = 0;
+ struct timespec ts;
+ ts.tv_sec = 0;
+ ts.tv_nsec = CONFIG.m_transcodingSleepUs*1000;
+ ACE_OS::nanosleep (&ts, NULL);
+ }
+ else
+ {
+ frameSleepCounter += 1;
+ }
+ }
}
if(voIpSession && !firstChunk)
diff --git a/orkbasecxx/Config.cpp b/orkbasecxx/Config.cpp
index 2da7141..08038f7 100644
--- a/orkbasecxx/Config.cpp
+++ b/orkbasecxx/Config.cpp
@@ -71,6 +71,8 @@ Config::Config()
m_stereoRecording = STEREO_RECORDING_DEFAULT;
m_tapeNumChannels = TAPE_NUM_CHANNELS_DEFAULT;
m_tapeDurationMinimumSec = TAPE_DURATION_MINIMUM_SEC_DEFAULT;
+ m_transcodingSleepEveryNumFrames = TRANSCODING_SLEEP_EVERY_NUM_FRAMES_DEFAULT;
+ m_transcodingSleepUs = TRANSCODING_SLEEP_US_DEFAULT;
}
void Config::Define(Serializer* s)
@@ -146,6 +148,8 @@ void Config::Define(Serializer* s)
s->BoolValue(STEREO_RECORDING_PARAM, m_stereoRecording);
s->IntValue(TAPE_NUM_CHANNELS_PARAM, m_tapeNumChannels);
s->IntValue(TAPE_DURATION_MINIMUM_SEC_PARAM, m_tapeDurationMinimumSec);
+ s->IntValue(TRANSCODING_SLEEP_EVERY_NUM_FRAMES_PARAM, m_transcodingSleepEveryNumFrames);
+ s->IntValue(TRANSCODING_SLEEP_US_PARAM, m_transcodingSleepUs);
}
void Config::Validate()
@@ -195,6 +199,19 @@ void Config::Validate()
exception.Format("Config::Validate: please set a valid number for TapeNumChannels - currently:%d", m_tapeNumChannels);
throw(exception);
}
+
+ if(m_transcodingSleepEveryNumFrames < 0)
+ {
+ CStdString exception;
+ exception.Format("Config::Validate: please set a valid value for TranscodingSleepEveryNumFrames - currently:%d", m_transcodingSleepEveryNumFrames);
+ throw(exception);
+ }
+ if(m_transcodingSleepUs < 0)
+ {
+ CStdString exception;
+ exception.Format("Config::Validate: please set a valid value for TranscodingSleepUs - currently:%d", m_transcodingSleepUs);
+ throw(exception);
+ }
}
CStdString Config::GetClassName()
diff --git a/orkbasecxx/Config.h b/orkbasecxx/Config.h
index 561e238..02fe025 100644
--- a/orkbasecxx/Config.h
+++ b/orkbasecxx/Config.h
@@ -110,6 +110,10 @@
#define TAPE_NUM_CHANNELS_DEFAULT 2
#define TAPE_DURATION_MINIMUM_SEC_PARAM "TapeDurationMinimumSec"
#define TAPE_DURATION_MINIMUM_SEC_DEFAULT 0
+#define TRANSCODING_SLEEP_EVERY_NUM_FRAMES_PARAM "TranscodingSleepEveryNumFrames"
+#define TRANSCODING_SLEEP_EVERY_NUM_FRAMES_DEFAULT 0
+#define TRANSCODING_SLEEP_US_PARAM "TranscodingSleepUs"
+#define TRANSCODING_SLEEP_US_DEFAULT 0
class DLL_IMPORT_EXPORT_ORKBASE Config : public Object
@@ -173,6 +177,8 @@ public:
bool m_stereoRecording;
int m_tapeNumChannels;
int m_tapeDurationMinimumSec;
+ int m_transcodingSleepEveryNumFrames;
+ int m_transcodingSleepUs;
private:
log4cxx::LoggerPtr m_log;