- Add a SetPriority method to ThreadWrapper
- Remove 'priority' from CreateThread and related member variables from implementations
- Make supplying a name for threads, non-optional
BUG=
R=magjed@webrtc.org
Review URL: https://webrtc-codereview.appspot.com/44729004
Cr-Commit-Position: refs/heads/master@{#8810}
git-svn-id: http://webrtc.googlecode.com/svn/trunk@8810 4adac7df-926f-26a2-2b94-8c16560cd09d
diff --git a/webrtc/modules/audio_device/android/low_latency_event_unittest.cc b/webrtc/modules/audio_device/android/low_latency_event_unittest.cc
index 359625b..2138f1f 100644
--- a/webrtc/modules/audio_device/android/low_latency_event_unittest.cc
+++ b/webrtc/modules/audio_device/android/low_latency_event_unittest.cc
@@ -22,10 +22,8 @@
class LowLatencyEventTest : public testing::Test {
public:
LowLatencyEventTest()
- : process_thread_(ThreadWrapper::CreateThread(CbThread,
- this,
- kRealtimePriority,
- "test_thread")),
+ : process_thread_(ThreadWrapper::CreateThread(
+ CbThread, this, "test_thread")),
terminated_(false),
iteration_count_(0),
allowed_iterations_(0) {
@@ -46,6 +44,7 @@
private:
void Start() {
EXPECT_TRUE(process_thread_->Start());
+ process_thread_->SetPriority(kRealtimePriority);
}
void Stop() {
terminated_ = true;
diff --git a/webrtc/modules/audio_device/android/opensles_input.cc b/webrtc/modules/audio_device/android/opensles_input.cc
index f0e5347..12640e7 100644
--- a/webrtc/modules/audio_device/android/opensles_input.cc
+++ b/webrtc/modules/audio_device/android/opensles_input.cc
@@ -470,13 +470,14 @@
}
bool OpenSlesInput::StartCbThreads() {
- rec_thread_ = ThreadWrapper::CreateThread(CbThread, this, kRealtimePriority,
+ rec_thread_ = ThreadWrapper::CreateThread(CbThread, this,
"opensl_rec_thread");
assert(rec_thread_.get());
if (!rec_thread_->Start()) {
assert(false);
return false;
}
+ rec_thread_->SetPriority(kRealtimePriority);
OPENSL_RETURN_ON_FAILURE(
(*sles_recorder_itf_)->SetRecordState(sles_recorder_itf_,
SL_RECORDSTATE_RECORDING),
diff --git a/webrtc/modules/audio_device/android/opensles_output.cc b/webrtc/modules/audio_device/android/opensles_output.cc
index 350b5de..5782973 100644
--- a/webrtc/modules/audio_device/android/opensles_output.cc
+++ b/webrtc/modules/audio_device/android/opensles_output.cc
@@ -510,7 +510,7 @@
}
bool OpenSlesOutput::StartCbThreads() {
- play_thread_ = ThreadWrapper::CreateThread(CbThread, this, kRealtimePriority,
+ play_thread_ = ThreadWrapper::CreateThread(CbThread, this,
"opensl_play_thread");
assert(play_thread_.get());
OPENSL_RETURN_ON_FAILURE(
@@ -522,6 +522,7 @@
assert(false);
return false;
}
+ play_thread_->SetPriority(kRealtimePriority);
return true;
}
diff --git a/webrtc/modules/audio_device/dummy/file_audio_device.cc b/webrtc/modules/audio_device/dummy/file_audio_device.cc
index cce4f5c..82569e8 100644
--- a/webrtc/modules/audio_device/dummy/file_audio_device.cc
+++ b/webrtc/modules/audio_device/dummy/file_audio_device.cc
@@ -205,12 +205,6 @@
}
// PLAYOUT
- const char* threadName = "webrtc_audio_module_play_thread";
- _ptrThreadPlay = ThreadWrapper::CreateThread(PlayThreadFunc,
- this,
- kRealtimePriority,
- threadName);
-
if (!_outputFilename.empty() && _outputFile.OpenFile(
_outputFilename.c_str(), false, false, false) == -1) {
printf("Failed to open playout file %s!\n", _outputFilename.c_str());
@@ -220,6 +214,9 @@
return -1;
}
+ const char* threadName = "webrtc_audio_module_play_thread";
+ _ptrThreadPlay = ThreadWrapper::CreateThread(PlayThreadFunc, this,
+ threadName);
if (!_ptrThreadPlay->Start()) {
_ptrThreadPlay.reset();
_playing = false;
@@ -227,7 +224,7 @@
_playoutBuffer = NULL;
return -1;
}
-
+ _ptrThreadPlay->SetPriority(kRealtimePriority);
return 0;
}
@@ -281,10 +278,7 @@
}
const char* threadName = "webrtc_audio_module_capture_thread";
- _ptrThreadRec = ThreadWrapper::CreateThread(RecThreadFunc,
- this,
- kRealtimePriority,
- threadName);
+ _ptrThreadRec = ThreadWrapper::CreateThread(RecThreadFunc, this, threadName);
if (!_ptrThreadRec->Start()) {
_ptrThreadRec.reset();
@@ -293,6 +287,7 @@
_recordingBuffer = NULL;
return -1;
}
+ _ptrThreadRec->SetPriority(kRealtimePriority);
return 0;
}
diff --git a/webrtc/modules/audio_device/ios/audio_device_ios.mm b/webrtc/modules/audio_device/ios/audio_device_ios.mm
index 6b973ab..178ce3e 100644
--- a/webrtc/modules/audio_device/ios/audio_device_ios.mm
+++ b/webrtc/modules/audio_device/ios/audio_device_ios.mm
@@ -107,12 +107,12 @@
// Create and start capture thread
if (!_captureWorkerThread) {
- _captureWorkerThread
- = ThreadWrapper::CreateThread(RunCapture, this, kRealtimePriority,
- "CaptureWorkerThread");
+ _captureWorkerThread = ThreadWrapper::CreateThread(
+ RunCapture, this, "CaptureWorkerThread");
bool res = _captureWorkerThread->Start();
WEBRTC_TRACE(kTraceDebug, kTraceAudioDevice,
_id, "CaptureWorkerThread started (res=%d)", res);
+ _captureWorkerThread->SetPriority(kRealtimePriority);
} else {
WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice,
_id, "Thread already created");
diff --git a/webrtc/modules/audio_device/linux/audio_device_alsa_linux.cc b/webrtc/modules/audio_device/linux/audio_device_alsa_linux.cc
index e590663..3516d77 100644
--- a/webrtc/modules/audio_device/linux/audio_device_alsa_linux.cc
+++ b/webrtc/modules/audio_device/linux/audio_device_alsa_linux.cc
@@ -1365,10 +1365,8 @@
}
// RECORDING
const char* threadName = "webrtc_audio_module_capture_thread";
- _ptrThreadRec = ThreadWrapper::CreateThread(RecThreadFunc,
- this,
- kRealtimePriority,
- threadName);
+ _ptrThreadRec = ThreadWrapper::CreateThread(
+ RecThreadFunc, this, threadName);
if (!_ptrThreadRec->Start())
{
@@ -1380,6 +1378,7 @@
_recordingBuffer = NULL;
return -1;
}
+ _ptrThreadRec->SetPriority(kRealtimePriority);
errVal = LATE(snd_pcm_prepare)(_handleRecord);
if (errVal < 0)
@@ -1520,9 +1519,7 @@
// PLAYOUT
const char* threadName = "webrtc_audio_module_play_thread";
- _ptrThreadPlay = ThreadWrapper::CreateThread(PlayThreadFunc,
- this,
- kRealtimePriority,
+ _ptrThreadPlay = ThreadWrapper::CreateThread(PlayThreadFunc, this,
threadName);
if (!_ptrThreadPlay->Start())
{
@@ -1534,6 +1531,7 @@
_playoutBuffer = NULL;
return -1;
}
+ _ptrThreadPlay->SetPriority(kRealtimePriority);
int errVal = LATE(snd_pcm_prepare)(_handlePlayout);
if (errVal < 0)
diff --git a/webrtc/modules/audio_device/linux/audio_device_pulse_linux.cc b/webrtc/modules/audio_device/linux/audio_device_pulse_linux.cc
index fd16e9e..9098211 100644
--- a/webrtc/modules/audio_device/linux/audio_device_pulse_linux.cc
+++ b/webrtc/modules/audio_device/linux/audio_device_pulse_linux.cc
@@ -208,7 +208,7 @@
// RECORDING
const char* threadName = "webrtc_audio_module_rec_thread";
_ptrThreadRec = ThreadWrapper::CreateThread(RecThreadFunc, this,
- kRealtimePriority, threadName);
+ threadName);
if (!_ptrThreadRec->Start())
{
WEBRTC_TRACE(kTraceCritical, kTraceAudioDevice, _id,
@@ -218,10 +218,12 @@
return -1;
}
+ _ptrThreadRec->SetPriority(kRealtimePriority);
+
// PLAYOUT
threadName = "webrtc_audio_module_play_thread";
_ptrThreadPlay = ThreadWrapper::CreateThread(PlayThreadFunc, this,
- kRealtimePriority, threadName);
+ threadName);
if (!_ptrThreadPlay->Start())
{
WEBRTC_TRACE(kTraceCritical, kTraceAudioDevice, _id,
@@ -230,6 +232,7 @@
_ptrThreadPlay.reset();
return -1;
}
+ _ptrThreadPlay->SetPriority(kRealtimePriority);
_initialized = true;
diff --git a/webrtc/modules/audio_device/mac/audio_device_mac.cc b/webrtc/modules/audio_device/mac/audio_device_mac.cc
index a717848..8c6f4c5 100644
--- a/webrtc/modules/audio_device/mac/audio_device_mac.cc
+++ b/webrtc/modules/audio_device/mac/audio_device_mac.cc
@@ -1755,10 +1755,10 @@
DCHECK(!capture_worker_thread_.get());
capture_worker_thread_ =
- ThreadWrapper::CreateThread(RunCapture, this, kRealtimePriority,
- "CaptureWorkerThread");
+ ThreadWrapper::CreateThread(RunCapture, this, "CaptureWorkerThread");
DCHECK(capture_worker_thread_.get());
capture_worker_thread_->Start();
+ capture_worker_thread_->SetPriority(kRealtimePriority);
OSStatus err = noErr;
if (_twoDevices)
@@ -1910,9 +1910,9 @@
DCHECK(!render_worker_thread_.get());
render_worker_thread_ =
- ThreadWrapper::CreateThread(RunRender, this, kRealtimePriority,
- "RenderWorkerThread");
+ ThreadWrapper::CreateThread(RunRender, this, "RenderWorkerThread");
render_worker_thread_->Start();
+ render_worker_thread_->SetPriority(kRealtimePriority);
if (_twoDevices || !_recording)
{
diff --git a/webrtc/modules/audio_device/win/audio_device_wave_win.cc b/webrtc/modules/audio_device/win/audio_device_wave_win.cc
index c5f0a1a..bcea317 100644
--- a/webrtc/modules/audio_device/win/audio_device_wave_win.cc
+++ b/webrtc/modules/audio_device/win/audio_device_wave_win.cc
@@ -228,10 +228,7 @@
}
const char* threadName = "webrtc_audio_module_thread";
- _ptrThread = ThreadWrapper::CreateThread(ThreadFunc,
- this,
- kRealtimePriority,
- threadName);
+ _ptrThread = ThreadWrapper::CreateThread(ThreadFunc, this, threadName);
if (!_ptrThread->Start())
{
WEBRTC_TRACE(kTraceCritical, kTraceAudioDevice, _id,
@@ -239,6 +236,7 @@
_ptrThread.reset();
return -1;
}
+ _ptrThread->SetPriority(kRealtimePriority);
const bool periodic(true);
if (!_timeEvent.StartTimer(periodic, TIMER_PERIOD_MS))