diff --git a/webrtc/modules/audio_coding/main/acm2/audio_coding_module_unittest.cc b/webrtc/modules/audio_coding/main/acm2/audio_coding_module_unittest.cc index 17be285d7b..a600129db3 100644 --- a/webrtc/modules/audio_coding/main/acm2/audio_coding_module_unittest.cc +++ b/webrtc/modules/audio_coding/main/acm2/audio_coding_module_unittest.cc @@ -285,18 +285,11 @@ class AudioCodingModuleMtTest : public AudioCodingModuleTest { AudioCodingModuleMtTest() : AudioCodingModuleTest(), - send_thread_(ThreadWrapper::CreateThread(CbSendThread, - this, - kRealtimePriority, - "send")), - insert_packet_thread_(ThreadWrapper::CreateThread(CbInsertPacketThread, - this, - kRealtimePriority, - "insert_packet")), - pull_audio_thread_(ThreadWrapper::CreateThread(CbPullAudioThread, - this, - kRealtimePriority, - "pull_audio")), + send_thread_(ThreadWrapper::CreateThread(CbSendThread, this, "send")), + insert_packet_thread_(ThreadWrapper::CreateThread( + CbInsertPacketThread, this, "insert_packet")), + pull_audio_thread_(ThreadWrapper::CreateThread( + CbPullAudioThread, this, "pull_audio")), test_complete_(EventWrapper::Create()), send_count_(0), insert_packet_count_(0), @@ -315,8 +308,11 @@ class AudioCodingModuleMtTest : public AudioCodingModuleTest { void StartThreads() { ASSERT_TRUE(send_thread_->Start()); + send_thread_->SetPriority(kRealtimePriority); ASSERT_TRUE(insert_packet_thread_->Start()); + insert_packet_thread_->SetPriority(kRealtimePriority); ASSERT_TRUE(pull_audio_thread_->Start()); + pull_audio_thread_->SetPriority(kRealtimePriority); } void TearDown() override { diff --git a/webrtc/modules/audio_coding/main/acm2/audio_coding_module_unittest_oldapi.cc b/webrtc/modules/audio_coding/main/acm2/audio_coding_module_unittest_oldapi.cc index 829db2d5e7..c083f28570 100644 --- a/webrtc/modules/audio_coding/main/acm2/audio_coding_module_unittest_oldapi.cc +++ b/webrtc/modules/audio_coding/main/acm2/audio_coding_module_unittest_oldapi.cc @@ -462,18 +462,11 @@ class AudioCodingModuleMtTestOldApi : public AudioCodingModuleTestOldApi { AudioCodingModuleMtTestOldApi() : AudioCodingModuleTestOldApi(), - send_thread_(ThreadWrapper::CreateThread(CbSendThread, - this, - kRealtimePriority, - "send")), - insert_packet_thread_(ThreadWrapper::CreateThread(CbInsertPacketThread, - this, - kRealtimePriority, - "insert_packet")), - pull_audio_thread_(ThreadWrapper::CreateThread(CbPullAudioThread, - this, - kRealtimePriority, - "pull_audio")), + send_thread_(ThreadWrapper::CreateThread(CbSendThread, this, "send")), + insert_packet_thread_(ThreadWrapper::CreateThread( + CbInsertPacketThread, this, "insert_packet")), + pull_audio_thread_(ThreadWrapper::CreateThread( + CbPullAudioThread, this, "pull_audio")), test_complete_(EventWrapper::Create()), send_count_(0), insert_packet_count_(0), @@ -492,8 +485,11 @@ class AudioCodingModuleMtTestOldApi : public AudioCodingModuleTestOldApi { void StartThreads() { ASSERT_TRUE(send_thread_->Start()); + send_thread_->SetPriority(kRealtimePriority); ASSERT_TRUE(insert_packet_thread_->Start()); + insert_packet_thread_->SetPriority(kRealtimePriority); ASSERT_TRUE(pull_audio_thread_->Start()); + pull_audio_thread_->SetPriority(kRealtimePriority); } void TearDown() { diff --git a/webrtc/modules/audio_coding/main/test/APITest.cc b/webrtc/modules/audio_coding/main/test/APITest.cc index 83b24a87d5..8cfe0e3486 100644 --- a/webrtc/modules/audio_coding/main/test/APITest.cc +++ b/webrtc/modules/audio_coding/main/test/APITest.cc @@ -532,40 +532,36 @@ void APITest::Perform() { // A // PUSH rtc::scoped_ptr myPushAudioThreadA = - ThreadWrapper::CreateThread(PushAudioThreadA, this, kNormalPriority, - "PushAudioThreadA"); + ThreadWrapper::CreateThread(PushAudioThreadA, this, "PushAudioThreadA"); CHECK_THREAD_NULLITY(myPushAudioThreadA, "Unable to start A::PUSH thread"); // PULL rtc::scoped_ptr myPullAudioThreadA = - ThreadWrapper::CreateThread(PullAudioThreadA, this, kNormalPriority, - "PullAudioThreadA"); + ThreadWrapper::CreateThread(PullAudioThreadA, this, "PullAudioThreadA"); CHECK_THREAD_NULLITY(myPullAudioThreadA, "Unable to start A::PULL thread"); // Process rtc::scoped_ptr myProcessThreadA = ThreadWrapper::CreateThread( - ProcessThreadA, this, kNormalPriority, "ProcessThreadA"); + ProcessThreadA, this, "ProcessThreadA"); CHECK_THREAD_NULLITY(myProcessThreadA, "Unable to start A::Process thread"); // API rtc::scoped_ptr myAPIThreadA = ThreadWrapper::CreateThread( - APIThreadA, this, kNormalPriority, "APIThreadA"); + APIThreadA, this, "APIThreadA"); CHECK_THREAD_NULLITY(myAPIThreadA, "Unable to start A::API thread"); // B // PUSH rtc::scoped_ptr myPushAudioThreadB = - ThreadWrapper::CreateThread(PushAudioThreadB, this, kNormalPriority, - "PushAudioThreadB"); + ThreadWrapper::CreateThread(PushAudioThreadB, this, "PushAudioThreadB"); CHECK_THREAD_NULLITY(myPushAudioThreadB, "Unable to start B::PUSH thread"); // PULL rtc::scoped_ptr myPullAudioThreadB = - ThreadWrapper::CreateThread(PullAudioThreadB, this, kNormalPriority, - "PullAudioThreadB"); + ThreadWrapper::CreateThread(PullAudioThreadB, this, "PullAudioThreadB"); CHECK_THREAD_NULLITY(myPullAudioThreadB, "Unable to start B::PULL thread"); // Process rtc::scoped_ptr myProcessThreadB = ThreadWrapper::CreateThread( - ProcessThreadB, this, kNormalPriority, "ProcessThreadB"); + ProcessThreadB, this, "ProcessThreadB"); CHECK_THREAD_NULLITY(myProcessThreadB, "Unable to start B::Process thread"); // API rtc::scoped_ptr myAPIThreadB = ThreadWrapper::CreateThread( - APIThreadB, this, kNormalPriority, "APIThreadB"); + APIThreadB, this, "APIThreadB"); CHECK_THREAD_NULLITY(myAPIThreadB, "Unable to start B::API thread"); //_apiEventA->StartTimer(true, 5000); 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 359625b016..2138f1f860 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 @@ static const int kEventMsg = 1; 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 @@ class LowLatencyEventTest : public testing::Test { 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 f0e5347590..12640e7fd9 100644 --- a/webrtc/modules/audio_device/android/opensles_input.cc +++ b/webrtc/modules/audio_device/android/opensles_input.cc @@ -470,13 +470,14 @@ void OpenSlesInput::RecorderSimpleBufferQueueCallbackHandler( } 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 350b5de25d..578297390a 100644 --- a/webrtc/modules/audio_device/android/opensles_output.cc +++ b/webrtc/modules/audio_device/android/opensles_output.cc @@ -510,7 +510,7 @@ void OpenSlesOutput::PlayerSimpleBufferQueueCallbackHandler( } 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 @@ bool OpenSlesOutput::StartCbThreads() { 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 cce4f5c3da..82569e8fcf 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 @@ int32_t FileAudioDevice::StartPlayout() { } // 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 @@ int32_t FileAudioDevice::StartPlayout() { 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 @@ int32_t FileAudioDevice::StartPlayout() { _playoutBuffer = NULL; return -1; } - + _ptrThreadPlay->SetPriority(kRealtimePriority); return 0; } @@ -281,10 +278,7 @@ int32_t FileAudioDevice::StartRecording() { } 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 @@ int32_t FileAudioDevice::StartRecording() { _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 6b973abb49..178ce3e0a9 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 @@ int32_t AudioDeviceIOS::Init() { // 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 e590663bc0..3516d77eea 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 @@ int32_t AudioDeviceLinuxALSA::StartRecording() } // 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 @@ int32_t AudioDeviceLinuxALSA::StartRecording() _recordingBuffer = NULL; return -1; } + _ptrThreadRec->SetPriority(kRealtimePriority); errVal = LATE(snd_pcm_prepare)(_handleRecord); if (errVal < 0) @@ -1520,9 +1519,7 @@ int32_t AudioDeviceLinuxALSA::StartPlayout() // 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 @@ int32_t AudioDeviceLinuxALSA::StartPlayout() _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 fd16e9e96d..9098211a31 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 @@ int32_t AudioDeviceLinuxPulse::Init() // 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 @@ int32_t AudioDeviceLinuxPulse::Init() 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 @@ int32_t AudioDeviceLinuxPulse::Init() _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 a717848d7b..8c6f4c5d67 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 @@ int32_t AudioDeviceMac::StartRecording() 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 @@ int32_t AudioDeviceMac::StartPlayout() 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 c5f0a1a82a..bcea3176e9 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 @@ int32_t AudioDeviceWindowsWave::Init() } 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 @@ int32_t AudioDeviceWindowsWave::Init() _ptrThread.reset(); return -1; } + _ptrThread->SetPriority(kRealtimePriority); const bool periodic(true); if (!_timeEvent.StartTimer(periodic, TIMER_PERIOD_MS)) diff --git a/webrtc/modules/rtp_rtcp/test/BWEStandAlone/TestLoadGenerator.cc b/webrtc/modules/rtp_rtcp/test/BWEStandAlone/TestLoadGenerator.cc index a3f52f9d77..0ed35728e4 100644 --- a/webrtc/modules/rtp_rtcp/test/BWEStandAlone/TestLoadGenerator.cc +++ b/webrtc/modules/rtp_rtcp/test/BWEStandAlone/TestLoadGenerator.cc @@ -77,10 +77,11 @@ int32_t TestLoadGenerator::Start (const char *threadName) _eventPtr = EventWrapper::Create(); _genThread = ThreadWrapper::CreateThread(SenderThreadFunction, this, - kRealtimePriority, threadName); + threadName); _running = true; _genThread->Start(); + _genThread->SetPriority(kRealtimePriority); return 0; } diff --git a/webrtc/modules/rtp_rtcp/test/BWEStandAlone/TestSenderReceiver.cc b/webrtc/modules/rtp_rtcp/test/BWEStandAlone/TestSenderReceiver.cc index 839f5792a7..e55d363467 100644 --- a/webrtc/modules/rtp_rtcp/test/BWEStandAlone/TestSenderReceiver.cc +++ b/webrtc/modules/rtp_rtcp/test/BWEStandAlone/TestSenderReceiver.cc @@ -164,7 +164,7 @@ int32_t TestSenderReceiver::Start() } _procThread = ThreadWrapper::CreateThread(ProcThreadFunction, this, - kRealtimePriority, "TestSenderReceiver"); + "TestSenderReceiver"); _running = true; @@ -178,6 +178,7 @@ int32_t TestSenderReceiver::Start() } _procThread->Start(); + _procThread->SetPriority(kRealtimePriority); return 0; diff --git a/webrtc/modules/utility/source/process_thread_impl.cc b/webrtc/modules/utility/source/process_thread_impl.cc index 33a1c4f2d2..5b505390da 100644 --- a/webrtc/modules/utility/source/process_thread_impl.cc +++ b/webrtc/modules/utility/source/process_thread_impl.cc @@ -70,7 +70,7 @@ void ProcessThreadImpl::Start() { m.module->ProcessThreadAttached(this); thread_ = ThreadWrapper::CreateThread( - &ProcessThreadImpl::Run, this, kNormalPriority, "ProcessThread"); + &ProcessThreadImpl::Run, this, "ProcessThread"); CHECK(thread_->Start()); } diff --git a/webrtc/modules/video_capture/linux/video_capture_linux.cc b/webrtc/modules/video_capture/linux/video_capture_linux.cc index 41e0e84d28..23703aa53d 100644 --- a/webrtc/modules/video_capture/linux/video_capture_linux.cc +++ b/webrtc/modules/video_capture/linux/video_capture_linux.cc @@ -281,8 +281,9 @@ int32_t VideoCaptureModuleV4L2::StartCapture( if (!_captureThread) { _captureThread = ThreadWrapper::CreateThread( - VideoCaptureModuleV4L2::CaptureThread, this, kHighPriority); + VideoCaptureModuleV4L2::CaptureThread, this, "CaptureThread"); _captureThread->Start(); + _captureThread->SetPriority(kHighPriority); } // Needed to start UVC camera - from the uvcview application diff --git a/webrtc/modules/video_render/android/video_render_android_impl.cc b/webrtc/modules/video_render/android/video_render_android_impl.cc index 288d1fabcc..15b52d7739 100644 --- a/webrtc/modules/video_render/android/video_render_android_impl.cc +++ b/webrtc/modules/video_render/android/video_render_android_impl.cc @@ -142,7 +142,6 @@ int32_t VideoRenderAndroid::StartRender() { } _javaRenderThread = ThreadWrapper::CreateThread(JavaRenderThreadFun, this, - kRealtimePriority, "AndroidRenderThread"); if (_javaRenderThread->Start()) @@ -153,6 +152,7 @@ int32_t VideoRenderAndroid::StartRender() { "%s: Could not start send thread", __FUNCTION__); return -1; } + _javaRenderThread->SetPriority(kRealtimePriority); return 0; } diff --git a/webrtc/modules/video_render/incoming_video_stream.cc b/webrtc/modules/video_render/incoming_video_stream.cc index 40966bd406..6e9e8a4d96 100644 --- a/webrtc/modules/video_render/incoming_video_stream.cc +++ b/webrtc/modules/video_render/incoming_video_stream.cc @@ -179,8 +179,7 @@ int32_t IncomingVideoStream::Start() { assert(incoming_render_thread_ == NULL); incoming_render_thread_ = ThreadWrapper::CreateThread( - IncomingVideoStreamThreadFun, this, kRealtimePriority, - "IncomingVideoStreamThread"); + IncomingVideoStreamThreadFun, this, "IncomingVideoStreamThread"); if (!incoming_render_thread_) { WEBRTC_TRACE(kTraceError, kTraceVideoRenderer, module_id_, "%s: No thread", __FUNCTION__); @@ -195,6 +194,7 @@ int32_t IncomingVideoStream::Start() { "%s: Could not start send thread", __FUNCTION__); return -1; } + incoming_render_thread_->SetPriority(kRealtimePriority); deliver_buffer_event_.StartTimer(false, KEventStartupTimeMS); running_ = true; diff --git a/webrtc/modules/video_render/ios/video_render_ios_gles20.mm b/webrtc/modules/video_render/ios/video_render_ios_gles20.mm index 1d61a095b2..35382ea814 100644 --- a/webrtc/modules/video_render/ios/video_render_ios_gles20.mm +++ b/webrtc/modules/video_render/ios/video_render_ios_gles20.mm @@ -33,7 +33,7 @@ VideoRenderIosGles20::VideoRenderIosGles20(VideoRenderIosView* view, gles_context_([view context]), is_rendering_(true) { screen_update_thread_ = ThreadWrapper::CreateThread( - ScreenUpdateThreadProc, this, kRealtimePriority); + ScreenUpdateThreadProc, this, "ScreenUpdateGles20"); screen_update_event_ = EventWrapper::Create(); GetWindowRect(window_rect_); } @@ -83,6 +83,7 @@ int VideoRenderIosGles20::Init() { } screen_update_thread_->Start(); + screen_update_thread_->SetPriority(kRealtimePriority); // Start the event triggering the render process unsigned int monitor_freq = 60; diff --git a/webrtc/modules/video_render/mac/video_render_agl.cc b/webrtc/modules/video_render/mac/video_render_agl.cc index ae8b7c3ffe..6cd4173d8a 100644 --- a/webrtc/modules/video_render/mac/video_render_agl.cc +++ b/webrtc/modules/video_render/mac/video_render_agl.cc @@ -395,7 +395,8 @@ _renderingIsPaused( false), { //WEBRTC_TRACE(kTraceInfo, kTraceVideoRenderer, _id, "%s"); - _screenUpdateThread = ThreadWrapper::CreateThread(ScreenUpdateThreadProc, this, kRealtimePriority); + _screenUpdateThread = ThreadWrapper::CreateThread( + ScreenUpdateThreadProc, this, "ScreenUpdate"); _screenUpdateEvent = EventWrapper::Create(); if(!IsValidWindowPtr(_windowRef)) @@ -511,7 +512,8 @@ _renderingIsPaused( false), //WEBRTC_TRACE(kTraceDebug, "%s:%d Constructor", __FUNCTION__, __LINE__); // _renderCritSec = CriticalSectionWrapper::CreateCriticalSection(); - _screenUpdateThread = ThreadWrapper::CreateThread(ScreenUpdateThreadProc, this, kRealtimePriority); + _screenUpdateThread = ThreadWrapper::CreateThread( + ScreenUpdateThreadProc, this, "ScreenUpdateThread"); _screenUpdateEvent = EventWrapper::Create(); GetWindowRect(_windowRect); @@ -737,6 +739,7 @@ int VideoRenderAGL::Init() return -1; } _screenUpdateThread->Start(); + _screenUpdateThread->SetPriority(kRealtimePriority); // Start the event triggering the render process unsigned int monitorFreq = 60; @@ -1877,6 +1880,7 @@ int32_t VideoRenderAGL::StartRender() UnlockAGLCntx(); return -1; } + _screenUpdateThread->SetPriority(kRealtimePriority); if(FALSE == _screenUpdateEvent->StartTimer(true, 1000/MONITOR_FREQ)) { //WEBRTC_TRACE(kTraceError, kTraceVideoRenderer, _id, "%s:%d Failed to start screenUpdateEvent", __FUNCTION__, __LINE__); @@ -1887,7 +1891,8 @@ int32_t VideoRenderAGL::StartRender() return 0; } - _screenUpdateThread = ThreadWrapper::CreateThread(ScreenUpdateThreadProc, this, kRealtimePriority); + _screenUpdateThread = ThreadWrapper::CreateThread(ScreenUpdateThreadProc, + this, "ScreenUpdate"); _screenUpdateEvent = EventWrapper::Create(); if (!_screenUpdateThread) @@ -1898,6 +1903,7 @@ int32_t VideoRenderAGL::StartRender() } _screenUpdateThread->Start(); + _screenUpdateThread->SetPriority(kRealtimePriority); _screenUpdateEvent->StartTimer(true, 1000/MONITOR_FREQ); //WEBRTC_TRACE(kTraceInfo, kTraceVideoRenderer, _id, "%s:%d Started screenUpdateThread", __FUNCTION__, __LINE__); diff --git a/webrtc/modules/video_render/mac/video_render_nsopengl.mm b/webrtc/modules/video_render/mac/video_render_nsopengl.mm index 569dd26cdd..556eee0f99 100644 --- a/webrtc/modules/video_render/mac/video_render_nsopengl.mm +++ b/webrtc/modules/video_render/mac/video_render_nsopengl.mm @@ -380,7 +380,8 @@ _renderingIsPaused (FALSE), _windowRefSuperView(NULL), _windowRefSuperViewFrame(NSMakeRect(0,0,0,0)) { - _screenUpdateThread = ThreadWrapper::CreateThread(ScreenUpdateThreadProc, this, kRealtimePriority); + _screenUpdateThread = ThreadWrapper::CreateThread(ScreenUpdateThreadProc, + this, "ScreenUpdateNSOpenGL"); _screenUpdateEvent = EventWrapper::Create(); } @@ -437,6 +438,8 @@ int32_t VideoRenderNSOpenGL::StartRender() return -1; } + _screenUpdateThread->SetPriority(kRealtimePriority); + UnlockAGLCntx(); return 0; } @@ -716,6 +719,7 @@ int VideoRenderNSOpenGL::Init() } _screenUpdateThread->Start(); + _screenUpdateThread->SetPriority(kRealtimePriority); // Start the event triggering the render process unsigned int monitorFreq = 60; diff --git a/webrtc/modules/video_render/windows/video_render_direct3d9.cc b/webrtc/modules/video_render/windows/video_render_direct3d9.cc index 99dd4948ee..e9c08df69b 100644 --- a/webrtc/modules/video_render/windows/video_render_direct3d9.cc +++ b/webrtc/modules/video_render/windows/video_render_direct3d9.cc @@ -295,8 +295,8 @@ VideoRenderDirect3D9::VideoRenderDirect3D9(Trace* trace, _totalMemory(0), _availableMemory(0) { - _screenUpdateThread = ThreadWrapper::CreateThread(ScreenUpdateThreadProc, - this, kRealtimePriority); + _screenUpdateThread = ThreadWrapper::CreateThread( + ScreenUpdateThreadProc, this, "ScreenUpdateThread"); _screenUpdateEvent = EventWrapper::Create(); SetRect(&_originalHwndRect, 0, 0, 0, 0); } @@ -547,6 +547,7 @@ int32_t VideoRenderDirect3D9::Init() return -1; } _screenUpdateThread->Start(); + _screenUpdateThread->SetPriority(kRealtimePriority); // Start the event triggering the render process unsigned int monitorFreq = 60; diff --git a/webrtc/system_wrappers/interface/thread_wrapper.h b/webrtc/system_wrappers/interface/thread_wrapper.h index 67ce866d18..742056198a 100644 --- a/webrtc/system_wrappers/interface/thread_wrapper.h +++ b/webrtc/system_wrappers/interface/thread_wrapper.h @@ -16,6 +16,10 @@ #ifndef WEBRTC_SYSTEM_WRAPPERS_INTERFACE_THREAD_WRAPPER_H_ #define WEBRTC_SYSTEM_WRAPPERS_INTERFACE_THREAD_WRAPPER_H_ +#if defined(WEBRTC_WIN) +#include +#endif + #include "webrtc/base/scoped_ptr.h" #include "webrtc/common_types.h" #include "webrtc/typedefs.h" @@ -28,11 +32,19 @@ namespace webrtc { typedef bool(*ThreadRunFunction)(void*); enum ThreadPriority { +#ifdef WEBRTC_WIN + kLowPriority = THREAD_PRIORITY_BELOW_NORMAL, + kNormalPriority = THREAD_PRIORITY_NORMAL, + kHighPriority = THREAD_PRIORITY_ABOVE_NORMAL, + kHighestPriority = THREAD_PRIORITY_HIGHEST, + kRealtimePriority = THREAD_PRIORITY_TIME_CRITICAL +#else kLowPriority = 1, kNormalPriority = 2, kHighPriority = 3, kHighestPriority = 4, kRealtimePriority = 5 +#endif }; // Represents a simple worker thread. The implementation must be assumed @@ -52,11 +64,8 @@ class ThreadWrapper { // prio Thread priority. May require root/admin rights. // thread_name NULL terminated thread name, will be visable in the Windows // debugger. - // TODO(tommi): Remove the priority argument and provide a setter instead. - // TODO(tommi): Make thread_name non-optional (i.e. no default value). static rtc::scoped_ptr CreateThread(ThreadRunFunction func, - void* obj, ThreadPriority prio = kNormalPriority, - const char* thread_name = 0); + void* obj, const char* thread_name); // Get the current thread's thread ID. // NOTE: This is a static method. It returns the id of the calling thread, @@ -75,6 +84,10 @@ class ThreadWrapper { // Multiple tries to Stop are allowed (e.g. to wait longer than 2 seconds). // It's ok to call Stop() even if the spawned thread has been reclaimed. virtual bool Stop() = 0; + + // Set the priority of the worker thread. Must be called when thread + // is running. + virtual bool SetPriority(ThreadPriority priority) = 0; }; } // namespace webrtc diff --git a/webrtc/system_wrappers/source/condition_variable_unittest.cc b/webrtc/system_wrappers/source/condition_variable_unittest.cc index d6907f6475..c34c4ea0d8 100644 --- a/webrtc/system_wrappers/source/condition_variable_unittest.cc +++ b/webrtc/system_wrappers/source/condition_variable_unittest.cc @@ -145,7 +145,7 @@ class CondVarTest : public ::testing::Test { virtual void SetUp() { thread_ = ThreadWrapper::CreateThread(&WaitingRunFunction, - &baton_); + &baton_, "CondVarTest"); ASSERT_TRUE(thread_->Start()); } diff --git a/webrtc/system_wrappers/source/critical_section_unittest.cc b/webrtc/system_wrappers/source/critical_section_unittest.cc index 9b497b426a..ec639eb673 100644 --- a/webrtc/system_wrappers/source/critical_section_unittest.cc +++ b/webrtc/system_wrappers/source/critical_section_unittest.cc @@ -79,7 +79,7 @@ TEST_F(CritSectTest, ThreadWakesOnce) NO_THREAD_SAFETY_ANALYSIS { CriticalSectionWrapper::CreateCriticalSection(); ProtectedCount count(crit_sect); rtc::scoped_ptr thread = ThreadWrapper::CreateThread( - &LockUnlockThenStopRunFunction, &count); + &LockUnlockThenStopRunFunction, &count, "ThreadWakesOnce"); crit_sect->Enter(); ASSERT_TRUE(thread->Start()); SwitchProcess(); @@ -106,7 +106,7 @@ TEST_F(CritSectTest, ThreadWakesTwice) NO_THREAD_SAFETY_ANALYSIS { CriticalSectionWrapper::CreateCriticalSection(); ProtectedCount count(crit_sect); rtc::scoped_ptr thread = ThreadWrapper::CreateThread( - &LockUnlockRunFunction, &count); + &LockUnlockRunFunction, &count, "ThreadWakesTwice"); crit_sect->Enter(); // Make sure counter stays 0 until we wait for it. ASSERT_TRUE(thread->Start()); crit_sect->Leave(); diff --git a/webrtc/system_wrappers/source/data_log.cc b/webrtc/system_wrappers/source/data_log.cc index 7c2a91b558..653af657dd 100644 --- a/webrtc/system_wrappers/source/data_log.cc +++ b/webrtc/system_wrappers/source/data_log.cc @@ -349,13 +349,11 @@ int DataLogImpl::CreateLog() { int DataLogImpl::Init() { file_writer_thread_ = ThreadWrapper::CreateThread( - DataLogImpl::Run, - instance_, - kHighestPriority, - "DataLog"); + DataLogImpl::Run, instance_, "DataLog"); bool success = file_writer_thread_->Start(); if (!success) return -1; + file_writer_thread_->SetPriority(kHighestPriority); return 0; } diff --git a/webrtc/system_wrappers/source/event_posix.cc b/webrtc/system_wrappers/source/event_posix.cc index bbfb0b03b1..6833e0e8af 100644 --- a/webrtc/system_wrappers/source/event_posix.cc +++ b/webrtc/system_wrappers/source/event_posix.cc @@ -154,11 +154,11 @@ bool EventPosix::StartTimer(bool periodic, unsigned long time) { // Start the timer thread timer_event_ = static_cast(EventWrapper::Create()); const char* thread_name = "WebRtc_event_timer_thread"; - timer_thread_ = ThreadWrapper::CreateThread(Run, this, kRealtimePriority, - thread_name); + timer_thread_ = ThreadWrapper::CreateThread(Run, this, thread_name); periodic_ = periodic; time_ = time; bool started = timer_thread_->Start(); + timer_thread_->SetPriority(kRealtimePriority); pthread_mutex_unlock(&mutex_); return started; diff --git a/webrtc/system_wrappers/source/thread.cc b/webrtc/system_wrappers/source/thread.cc index 957388b885..b469344bd1 100644 --- a/webrtc/system_wrappers/source/thread.cc +++ b/webrtc/system_wrappers/source/thread.cc @@ -25,10 +25,9 @@ typedef ThreadPosix ThreadType; #endif rtc::scoped_ptr ThreadWrapper::CreateThread( - ThreadRunFunction func, void* obj, ThreadPriority prio, - const char* thread_name) { + ThreadRunFunction func, void* obj, const char* thread_name) { return rtc::scoped_ptr( - new ThreadType(func, obj, prio, thread_name)).Pass(); + new ThreadType(func, obj, thread_name)).Pass(); } } // namespace webrtc diff --git a/webrtc/system_wrappers/source/thread_posix.cc b/webrtc/system_wrappers/source/thread_posix.cc index c60541175f..dc95cbcd73 100644 --- a/webrtc/system_wrappers/source/thread_posix.cc +++ b/webrtc/system_wrappers/source/thread_posix.cc @@ -69,10 +69,9 @@ void* ThreadPosix::StartThread(void* param) { } ThreadPosix::ThreadPosix(ThreadRunFunction func, void* obj, - ThreadPriority prio, const char* thread_name) + const char* thread_name) : run_function_(func), obj_(obj), - prio_(prio), stop_event_(false, false), name_(thread_name ? thread_name : "webrtc"), thread_(0) { @@ -112,6 +111,38 @@ bool ThreadPosix::Stop() { return true; } +bool ThreadPosix::SetPriority(ThreadPriority priority) { + DCHECK(thread_checker_.CalledOnValidThread()); + if (!thread_) + return false; + +#ifdef WEBRTC_THREAD_RR + const int policy = SCHED_RR; +#else + const int policy = SCHED_FIFO; +#endif + const int min_prio = sched_get_priority_min(policy); + const int max_prio = sched_get_priority_max(policy); + if (min_prio == -1 || max_prio == -1) { + WEBRTC_TRACE(kTraceError, kTraceUtility, -1, + "unable to retreive min or max priority for threads"); + return false; + } + + if (max_prio - min_prio <= 2) + return false; + + sched_param param; + param.sched_priority = ConvertToSystemPriority(priority, min_prio, max_prio); + if (pthread_setschedparam(thread_, policy, ¶m) != 0) { + WEBRTC_TRACE( + kTraceError, kTraceUtility, -1, "unable to set thread priority"); + return false; + } + + return true; +} + void ThreadPosix::Run() { if (!name_.empty()) { // Setting the thread name may fail (harmlessly) if running inside a @@ -123,27 +154,6 @@ void ThreadPosix::Run() { #endif } -#ifdef WEBRTC_THREAD_RR - const int policy = SCHED_RR; -#else - const int policy = SCHED_FIFO; -#endif - const int min_prio = sched_get_priority_min(policy); - const int max_prio = sched_get_priority_max(policy); - if ((min_prio == -1) || (max_prio == -1)) { - WEBRTC_TRACE(kTraceError, kTraceUtility, -1, - "unable to retreive min or max priority for threads"); - } - - if (max_prio - min_prio > 2) { - sched_param param; - param.sched_priority = ConvertToSystemPriority(prio_, min_prio, max_prio); - if (pthread_setschedparam(pthread_self(), policy, ¶m) != 0) { - WEBRTC_TRACE( - kTraceError, kTraceUtility, -1, "unable to set thread priority"); - } - } - // It's a requirement that for successful thread creation that the run // function be called at least once (see RunFunctionIsCalled unit test), // so to fullfill that requirement, we use a |do| loop and not |while|. diff --git a/webrtc/system_wrappers/source/thread_posix.h b/webrtc/system_wrappers/source/thread_posix.h index ccc52b642a..c726e480cf 100644 --- a/webrtc/system_wrappers/source/thread_posix.h +++ b/webrtc/system_wrappers/source/thread_posix.h @@ -25,14 +25,15 @@ int ConvertToSystemPriority(ThreadPriority priority, int min_prio, class ThreadPosix : public ThreadWrapper { public: - ThreadPosix(ThreadRunFunction func, void* obj, ThreadPriority prio, - const char* thread_name); + ThreadPosix(ThreadRunFunction func, void* obj, const char* thread_name); ~ThreadPosix() override; // From ThreadWrapper. bool Start() override; bool Stop() override; + bool SetPriority(ThreadPriority priority) override; + private: static void* StartThread(void* param); @@ -41,7 +42,6 @@ class ThreadPosix : public ThreadWrapper { rtc::ThreadChecker thread_checker_; ThreadRunFunction const run_function_; void* const obj_; - ThreadPriority prio_; rtc::Event stop_event_; const std::string name_; diff --git a/webrtc/system_wrappers/source/thread_unittest.cc b/webrtc/system_wrappers/source/thread_unittest.cc index f5de7d2099..854f98bbd9 100644 --- a/webrtc/system_wrappers/source/thread_unittest.cc +++ b/webrtc/system_wrappers/source/thread_unittest.cc @@ -24,7 +24,7 @@ bool NullRunFunction(void* obj) { TEST(ThreadTest, StartStop) { rtc::scoped_ptr thread = ThreadWrapper::CreateThread( - &NullRunFunction, NULL); + &NullRunFunction, nullptr, "ThreadTest"); ASSERT_TRUE(thread->Start()); EXPECT_TRUE(thread->Stop()); } @@ -40,7 +40,7 @@ bool SetFlagRunFunction(void* obj) { TEST(ThreadTest, RunFunctionIsCalled) { bool flag = false; rtc::scoped_ptr thread = ThreadWrapper::CreateThread( - &SetFlagRunFunction, &flag); + &SetFlagRunFunction, &flag, "RunFunctionIsCalled"); ASSERT_TRUE(thread->Start()); // At this point, the flag may be either true or false. diff --git a/webrtc/system_wrappers/source/thread_win.cc b/webrtc/system_wrappers/source/thread_win.cc index 0c1a8f209e..aa03b91809 100644 --- a/webrtc/system_wrappers/source/thread_win.cc +++ b/webrtc/system_wrappers/source/thread_win.cc @@ -55,10 +55,9 @@ void SetThreadName(DWORD dwThreadID, LPCSTR szThreadName) { } ThreadWindows::ThreadWindows(ThreadRunFunction func, void* obj, - ThreadPriority prio, const char* thread_name) + const char* thread_name) : run_function_(func), obj_(obj), - prio_(prio), stop_(false), thread_(NULL), name_(thread_name ? thread_name : "webrtc") { @@ -98,28 +97,6 @@ bool ThreadWindows::Start() { return false; } - if (prio_ != kNormalPriority) { - int priority = THREAD_PRIORITY_NORMAL; - switch (prio_) { - case kLowPriority: - priority = THREAD_PRIORITY_BELOW_NORMAL; - break; - case kHighPriority: - priority = THREAD_PRIORITY_ABOVE_NORMAL; - break; - case kHighestPriority: - priority = THREAD_PRIORITY_HIGHEST; - break; - case kRealtimePriority: - priority = THREAD_PRIORITY_TIME_CRITICAL; - break; - default: - break; - } - - SetThreadPriority(thread_, priority); - } - return true; } @@ -136,6 +113,11 @@ bool ThreadWindows::Stop() { return true; } +bool ThreadWindows::SetPriority(ThreadPriority priority) { + DCHECK(main_thread_.CalledOnValidThread()); + return thread_ && SetThreadPriority(thread_, priority); +} + void ThreadWindows::Run() { if (!name_.empty()) SetThreadName(static_cast(-1), name_.c_str()); diff --git a/webrtc/system_wrappers/source/thread_win.h b/webrtc/system_wrappers/source/thread_win.h index 1652551a7b..741ae1ed05 100644 --- a/webrtc/system_wrappers/source/thread_win.h +++ b/webrtc/system_wrappers/source/thread_win.h @@ -21,13 +21,14 @@ namespace webrtc { class ThreadWindows : public ThreadWrapper { public: - ThreadWindows(ThreadRunFunction func, void* obj, ThreadPriority prio, - const char* thread_name); + ThreadWindows(ThreadRunFunction func, void* obj, const char* thread_name); ~ThreadWindows() override; bool Start() override; bool Stop() override; + bool SetPriority(ThreadPriority priority) override; + protected: void Run(); @@ -37,8 +38,6 @@ class ThreadWindows : public ThreadWrapper { ThreadRunFunction const run_function_; void* const obj_; bool stop_; - // TODO(tommi): Consider having a SetPriority method instead of this variable. - ThreadPriority prio_; HANDLE thread_; const std::string name_; rtc::ThreadChecker main_thread_; diff --git a/webrtc/test/channel_transport/udp_socket2_manager_win.cc b/webrtc/test/channel_transport/udp_socket2_manager_win.cc index f5062b1351..55ddaee068 100644 --- a/webrtc/test/channel_transport/udp_socket2_manager_win.cc +++ b/webrtc/test/channel_transport/udp_socket2_manager_win.cc @@ -537,7 +537,11 @@ bool UdpSocket2WorkerWindows::Start() { WEBRTC_TRACE(kTraceStateInfo, kTraceTransport, -1, "Start UdpSocket2WorkerWindows"); - return _pThread->Start(); + if (!_pThread->Start()) + return false; + + _pThread->SetPriority(kRealtimePriority); + return true; } bool UdpSocket2WorkerWindows::Stop() @@ -552,8 +556,7 @@ int32_t UdpSocket2WorkerWindows::Init() if(!_init) { const char* threadName = "UdpSocket2ManagerWindows_thread"; - _pThread = ThreadWrapper::CreateThread(Run, this, kRealtimePriority, - threadName); + _pThread = ThreadWrapper::CreateThread(Run, this, threadName); _init = true; } return 0; diff --git a/webrtc/test/channel_transport/udp_socket_manager_posix.cc b/webrtc/test/channel_transport/udp_socket_manager_posix.cc index 5d7686ef43..9748400f11 100644 --- a/webrtc/test/channel_transport/udp_socket_manager_posix.cc +++ b/webrtc/test/channel_transport/udp_socket_manager_posix.cc @@ -189,7 +189,6 @@ UdpSocketManagerPosixImpl::UdpSocketManagerPosixImpl() { _critSectList = CriticalSectionWrapper::CreateCriticalSection(); _thread = ThreadWrapper::CreateThread(UdpSocketManagerPosixImpl::Run, this, - kRealtimePriority, "UdpSocketManagerPosixImplThread"); FD_ZERO(&_readFds); WEBRTC_TRACE(kTraceMemory, kTraceTransport, -1, @@ -228,7 +227,10 @@ bool UdpSocketManagerPosixImpl::Start() WEBRTC_TRACE(kTraceStateInfo, kTraceTransport, -1, "Start UdpSocketManagerPosix"); - return _thread->Start(); + if (!_thread->Start()) + return false; + _thread->SetPriority(kRealtimePriority); + return true; } bool UdpSocketManagerPosixImpl::Stop() diff --git a/webrtc/test/direct_transport.cc b/webrtc/test/direct_transport.cc index 4e7b9d01ec..871bcb06c3 100644 --- a/webrtc/test/direct_transport.cc +++ b/webrtc/test/direct_transport.cc @@ -20,7 +20,8 @@ namespace test { DirectTransport::DirectTransport() : lock_(CriticalSectionWrapper::CreateCriticalSection()), packet_event_(EventWrapper::Create()), - thread_(ThreadWrapper::CreateThread(NetworkProcess, this)), + thread_(ThreadWrapper::CreateThread( + NetworkProcess, this, "NetworkProcess")), clock_(Clock::GetRealTimeClock()), shutting_down_(false), fake_network_(FakeNetworkPipe::Config()) { @@ -31,7 +32,8 @@ DirectTransport::DirectTransport( const FakeNetworkPipe::Config& config) : lock_(CriticalSectionWrapper::CreateCriticalSection()), packet_event_(EventWrapper::Create()), - thread_(ThreadWrapper::CreateThread(NetworkProcess, this)), + thread_(ThreadWrapper::CreateThread( + NetworkProcess, this, "NetworkProcess")), clock_(Clock::GetRealTimeClock()), shutting_down_(false), fake_network_(config) { diff --git a/webrtc/test/fake_audio_device.cc b/webrtc/test/fake_audio_device.cc index 5f78eb46ca..a55be4a2fc 100644 --- a/webrtc/test/fake_audio_device.cc +++ b/webrtc/test/fake_audio_device.cc @@ -55,14 +55,15 @@ int32_t FakeAudioDevice::Init() { if (!tick_->StartTimer(true, 10)) return -1; - thread_ = ThreadWrapper::CreateThread( - FakeAudioDevice::Run, this, webrtc::kHighPriority, "FakeAudioDevice"); + thread_ = ThreadWrapper::CreateThread(FakeAudioDevice::Run, this, + "FakeAudioDevice"); if (thread_.get() == NULL) return -1; if (!thread_->Start()) { thread_.reset(); return -1; } + thread_->SetPriority(webrtc::kHighPriority); return 0; } diff --git a/webrtc/test/frame_generator_capturer.cc b/webrtc/test/frame_generator_capturer.cc index e956fd21dc..664ed6b19a 100644 --- a/webrtc/test/frame_generator_capturer.cc +++ b/webrtc/test/frame_generator_capturer.cc @@ -90,9 +90,7 @@ bool FrameGeneratorCapturer::Init() { if (!tick_->StartTimer(true, 1000 / target_fps_)) return false; - thread_ = ThreadWrapper::CreateThread(FrameGeneratorCapturer::Run, - this, - webrtc::kHighPriority, + thread_ = ThreadWrapper::CreateThread(FrameGeneratorCapturer::Run, this, "FrameGeneratorCapturer"); if (thread_.get() == NULL) return false; @@ -100,6 +98,7 @@ bool FrameGeneratorCapturer::Init() { thread_.reset(); return false; } + thread_->SetPriority(webrtc::kHighPriority); return true; } diff --git a/webrtc/video/full_stack.cc b/webrtc/video/full_stack.cc index 9913f3dcbd..93e682a7bb 100644 --- a/webrtc/video/full_stack.cc +++ b/webrtc/video/full_stack.cc @@ -108,7 +108,7 @@ class VideoAnalyzer : public PacketReceiver, for (uint32_t i = 0; i < num_cores; ++i) { rtc::scoped_ptr thread = - ThreadWrapper::CreateThread(&FrameComparisonThread, this); + ThreadWrapper::CreateThread(&FrameComparisonThread, this, "Analyzer"); EXPECT_TRUE(thread->Start()); comparison_thread_pool_.push_back(thread.release()); } diff --git a/webrtc/video_engine/test/auto_test/source/vie_autotest_win.cc b/webrtc/video_engine/test/auto_test/source/vie_autotest_win.cc index a5ef89cdf0..6e2bac3f9f 100755 --- a/webrtc/video_engine/test/auto_test/source/vie_autotest_win.cc +++ b/webrtc/video_engine/test/auto_test/source/vie_autotest_win.cc @@ -47,8 +47,7 @@ ViEAutoTestWindowManager::ViEAutoTestWindowManager() _window2(NULL), _terminate(false), _eventThread(webrtc::ThreadWrapper::CreateThread( - EventProcess, this, webrtc::kNormalPriority, - "ViEAutotestEventThread")), + EventProcess, this, "ViEAutotestEventThread")), _crit(*webrtc::CriticalSectionWrapper::CreateCriticalSection()), _hwnd1(NULL), _hwnd2(NULL), diff --git a/webrtc/video_engine/test/libvietest/helpers/vie_fake_camera.cc b/webrtc/video_engine/test/libvietest/helpers/vie_fake_camera.cc index 5de0f9ce59..1c18d498e0 100644 --- a/webrtc/video_engine/test/libvietest/helpers/vie_fake_camera.cc +++ b/webrtc/video_engine/test/libvietest/helpers/vie_fake_camera.cc @@ -61,7 +61,8 @@ bool ViEFakeCamera::StartCameraInNewThread( // Set up a thread which runs the fake camera. The capturer object is // thread-safe. camera_thread_ = webrtc::ThreadWrapper::CreateThread( - StreamVideoFileRepeatedlyIntoCaptureDevice, file_capture_device_); + StreamVideoFileRepeatedlyIntoCaptureDevice, file_capture_device_, + "StreamVideoFileRepeatedlyIntoCaptureDevice"); camera_thread_->Start(); return true; diff --git a/webrtc/video_engine/test/libvietest/helpers/vie_to_file_renderer.cc b/webrtc/video_engine/test/libvietest/helpers/vie_to_file_renderer.cc index 640d9c6938..d0aee84bd6 100644 --- a/webrtc/video_engine/test/libvietest/helpers/vie_to_file_renderer.cc +++ b/webrtc/video_engine/test/libvietest/helpers/vie_to_file_renderer.cc @@ -37,8 +37,7 @@ ViEToFileRenderer::ViEToFileRenderer() output_path_(), output_filename_(), thread_(webrtc::ThreadWrapper::CreateThread( - ViEToFileRenderer::RunRenderThread, - this, webrtc::kNormalPriority, "ViEToFileRendererThread")), + ViEToFileRenderer::RunRenderThread, this, "ViEToFileRendererThread")), frame_queue_cs_(webrtc::CriticalSectionWrapper::CreateCriticalSection()), frame_render_event_(webrtc::EventWrapper::Create()), render_queue_(), diff --git a/webrtc/video_engine/test/libvietest/testbed/tb_external_transport.cc b/webrtc/video_engine/test/libvietest/testbed/tb_external_transport.cc index f62c66079b..d406985ef4 100644 --- a/webrtc/video_engine/test/libvietest/testbed/tb_external_transport.cc +++ b/webrtc/video_engine/test/libvietest/testbed/tb_external_transport.cc @@ -41,8 +41,7 @@ TbExternalTransport::TbExternalTransport( receive_channels_(receive_channels), _vieNetwork(vieNetwork), _thread(webrtc::ThreadWrapper::CreateThread( - ViEExternalTransportRun, this, webrtc::kHighPriority, - "AutotestTransport")), + ViEExternalTransportRun, this, "AutotestTransport")), _event(*webrtc::EventWrapper::Create()), _crit(*webrtc::CriticalSectionWrapper::CreateCriticalSection()), _statCrit(*webrtc::CriticalSectionWrapper::CreateCriticalSection()), @@ -77,6 +76,7 @@ TbExternalTransport::TbExternalTransport( srand((int) webrtc::TickTime::MicrosecondTimestamp()); memset(&network_parameters_, 0, sizeof(NetworkParameters)); _thread->Start(); + _thread->SetPriority(webrtc::kHighPriority); } TbExternalTransport::~TbExternalTransport() diff --git a/webrtc/video_engine/vie_capturer.cc b/webrtc/video_engine/vie_capturer.cc index 456d15de0d..8a4880435d 100644 --- a/webrtc/video_engine/vie_capturer.cc +++ b/webrtc/video_engine/vie_capturer.cc @@ -68,10 +68,8 @@ ViECapturer::ViECapturer(int capture_id, module_process_thread_(module_process_thread), capture_id_(capture_id), incoming_frame_cs_(CriticalSectionWrapper::CreateCriticalSection()), - capture_thread_(ThreadWrapper::CreateThread(ViECaptureThreadFunction, - this, - kHighPriority, - "ViECaptureThread")), + capture_thread_(ThreadWrapper::CreateThread( + ViECaptureThreadFunction, this, "ViECaptureThread")), capture_event_(*EventWrapper::Create()), deliver_event_(*EventWrapper::Create()), stop_(0), @@ -93,6 +91,7 @@ ViECapturer::ViECapturer(int capture_id, new OveruseFrameDetector(Clock::GetRealTimeClock(), cpu_overuse_metrics_observer_.get())) { capture_thread_->Start(); + capture_thread_->SetPriority(kHighPriority); module_process_thread_.RegisterModule(overuse_detector_.get()); } diff --git a/webrtc/video_engine/vie_channel.cc b/webrtc/video_engine/vie_channel.cc index ee23dcc693..a6d075fa40 100644 --- a/webrtc/video_engine/vie_channel.cc +++ b/webrtc/video_engine/vie_channel.cc @@ -1839,9 +1839,9 @@ int32_t ViEChannel::StartDecodeThread() { return 0; } decode_thread_ = ThreadWrapper::CreateThread(ChannelDecodeThreadFunction, - this, kHighestPriority, - "DecodingThread"); + this, "DecodingThread"); decode_thread_->Start(); + decode_thread_->SetPriority(kHighestPriority); return 0; } diff --git a/webrtc/voice_engine/test/android/android_test/jni/android_test.cc b/webrtc/voice_engine/test/android/android_test/jni/android_test.cc index 1efe0759a1..b0a26e06a0 100644 --- a/webrtc/voice_engine/test/android/android_test/jni/android_test.cc +++ b/webrtc/voice_engine/test/android/android_test/jni/android_test.cc @@ -188,8 +188,7 @@ ThreadTest::~ThreadTest() ThreadTest::ThreadTest() { - _thread = ThreadWrapper::CreateThread(Run, this, kNormalPriority, - "ThreadTest thread"); + _thread = ThreadWrapper::CreateThread(Run, this, "ThreadTest thread"); } bool ThreadTest::Run(void* ptr) diff --git a/webrtc/voice_engine/test/auto_test/fakes/fake_external_transport.cc b/webrtc/voice_engine/test/auto_test/fakes/fake_external_transport.cc index 29156cd577..c825ea5861 100644 --- a/webrtc/voice_engine/test/auto_test/fakes/fake_external_transport.cc +++ b/webrtc/voice_engine/test/auto_test/fakes/fake_external_transport.cc @@ -27,10 +27,10 @@ FakeExternalTransport::FakeExternalTransport(webrtc::VoENetwork* ptr) const char* thread_name = "external_thread"; lock_ = webrtc::CriticalSectionWrapper::CreateCriticalSection(); event_ = webrtc::EventWrapper::Create(); - thread_ = webrtc::ThreadWrapper::CreateThread( - Run, this, webrtc::kHighPriority, thread_name); + thread_ = webrtc::ThreadWrapper::CreateThread(Run, this, thread_name); if (thread_) { thread_->Start(); + thread_->SetPriority(webrtc::kHighPriority); } } diff --git a/webrtc/voice_engine/test/auto_test/fixtures/after_initialization_fixture.h b/webrtc/voice_engine/test/auto_test/fixtures/after_initialization_fixture.h index 3383a53bd2..cee5a58f8e 100644 --- a/webrtc/voice_engine/test/auto_test/fixtures/after_initialization_fixture.h +++ b/webrtc/voice_engine/test/auto_test/fixtures/after_initialization_fixture.h @@ -29,7 +29,8 @@ class LoopBackTransport : public webrtc::Transport { LoopBackTransport(webrtc::VoENetwork* voe_network) : crit_(webrtc::CriticalSectionWrapper::CreateCriticalSection()), packet_event_(webrtc::EventWrapper::Create()), - thread_(webrtc::ThreadWrapper::CreateThread(NetworkProcess, this)), + thread_(webrtc::ThreadWrapper::CreateThread( + NetworkProcess, this, "LoopBackTransport")), voe_network_(voe_network), transmitted_packets_(0) { thread_->Start(); } diff --git a/webrtc/voice_engine/test/auto_test/voe_stress_test.cc b/webrtc/voice_engine/test/auto_test/voe_stress_test.cc index 38329eb74f..ab8fffe832 100644 --- a/webrtc/voice_engine/test/auto_test/voe_stress_test.cc +++ b/webrtc/voice_engine/test/auto_test/voe_stress_test.cc @@ -334,9 +334,8 @@ int VoEStressTest::MultipleThreadsTest() { int rnd(0); // Start extra thread - const char* threadName = "StressTest Extra API Thread"; _ptrExtraApiThread = ThreadWrapper::CreateThread(RunExtraApi, this, - kNormalPriority, threadName); + "StressTestExtraApiThread"); VALIDATE_STRESS(!_ptrExtraApiThread->Start()); // Some possible extensions include: