Revert 8810 "- Add a SetPriority method to ThreadWrapper"
Seeing if this is causing roll issues. > - 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 TBR=tommi@webrtc.org Review URL: https://webrtc-codereview.appspot.com/48609004 Cr-Commit-Position: refs/heads/master@{#8818} git-svn-id: http://webrtc.googlecode.com/svn/trunk@8818 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
parent
b789f6271a
commit
90a1cb4630
@ -285,11 +285,18 @@ class AudioCodingModuleMtTest : public AudioCodingModuleTest {
|
|||||||
|
|
||||||
AudioCodingModuleMtTest()
|
AudioCodingModuleMtTest()
|
||||||
: AudioCodingModuleTest(),
|
: AudioCodingModuleTest(),
|
||||||
send_thread_(ThreadWrapper::CreateThread(CbSendThread, this, "send")),
|
send_thread_(ThreadWrapper::CreateThread(CbSendThread,
|
||||||
insert_packet_thread_(ThreadWrapper::CreateThread(
|
this,
|
||||||
CbInsertPacketThread, this, "insert_packet")),
|
kRealtimePriority,
|
||||||
pull_audio_thread_(ThreadWrapper::CreateThread(
|
"send")),
|
||||||
CbPullAudioThread, this, "pull_audio")),
|
insert_packet_thread_(ThreadWrapper::CreateThread(CbInsertPacketThread,
|
||||||
|
this,
|
||||||
|
kRealtimePriority,
|
||||||
|
"insert_packet")),
|
||||||
|
pull_audio_thread_(ThreadWrapper::CreateThread(CbPullAudioThread,
|
||||||
|
this,
|
||||||
|
kRealtimePriority,
|
||||||
|
"pull_audio")),
|
||||||
test_complete_(EventWrapper::Create()),
|
test_complete_(EventWrapper::Create()),
|
||||||
send_count_(0),
|
send_count_(0),
|
||||||
insert_packet_count_(0),
|
insert_packet_count_(0),
|
||||||
@ -308,11 +315,8 @@ class AudioCodingModuleMtTest : public AudioCodingModuleTest {
|
|||||||
|
|
||||||
void StartThreads() {
|
void StartThreads() {
|
||||||
ASSERT_TRUE(send_thread_->Start());
|
ASSERT_TRUE(send_thread_->Start());
|
||||||
send_thread_->SetPriority(kRealtimePriority);
|
|
||||||
ASSERT_TRUE(insert_packet_thread_->Start());
|
ASSERT_TRUE(insert_packet_thread_->Start());
|
||||||
insert_packet_thread_->SetPriority(kRealtimePriority);
|
|
||||||
ASSERT_TRUE(pull_audio_thread_->Start());
|
ASSERT_TRUE(pull_audio_thread_->Start());
|
||||||
pull_audio_thread_->SetPriority(kRealtimePriority);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void TearDown() override {
|
void TearDown() override {
|
||||||
|
@ -462,11 +462,18 @@ class AudioCodingModuleMtTestOldApi : public AudioCodingModuleTestOldApi {
|
|||||||
|
|
||||||
AudioCodingModuleMtTestOldApi()
|
AudioCodingModuleMtTestOldApi()
|
||||||
: AudioCodingModuleTestOldApi(),
|
: AudioCodingModuleTestOldApi(),
|
||||||
send_thread_(ThreadWrapper::CreateThread(CbSendThread, this, "send")),
|
send_thread_(ThreadWrapper::CreateThread(CbSendThread,
|
||||||
insert_packet_thread_(ThreadWrapper::CreateThread(
|
this,
|
||||||
CbInsertPacketThread, this, "insert_packet")),
|
kRealtimePriority,
|
||||||
pull_audio_thread_(ThreadWrapper::CreateThread(
|
"send")),
|
||||||
CbPullAudioThread, this, "pull_audio")),
|
insert_packet_thread_(ThreadWrapper::CreateThread(CbInsertPacketThread,
|
||||||
|
this,
|
||||||
|
kRealtimePriority,
|
||||||
|
"insert_packet")),
|
||||||
|
pull_audio_thread_(ThreadWrapper::CreateThread(CbPullAudioThread,
|
||||||
|
this,
|
||||||
|
kRealtimePriority,
|
||||||
|
"pull_audio")),
|
||||||
test_complete_(EventWrapper::Create()),
|
test_complete_(EventWrapper::Create()),
|
||||||
send_count_(0),
|
send_count_(0),
|
||||||
insert_packet_count_(0),
|
insert_packet_count_(0),
|
||||||
@ -485,11 +492,8 @@ class AudioCodingModuleMtTestOldApi : public AudioCodingModuleTestOldApi {
|
|||||||
|
|
||||||
void StartThreads() {
|
void StartThreads() {
|
||||||
ASSERT_TRUE(send_thread_->Start());
|
ASSERT_TRUE(send_thread_->Start());
|
||||||
send_thread_->SetPriority(kRealtimePriority);
|
|
||||||
ASSERT_TRUE(insert_packet_thread_->Start());
|
ASSERT_TRUE(insert_packet_thread_->Start());
|
||||||
insert_packet_thread_->SetPriority(kRealtimePriority);
|
|
||||||
ASSERT_TRUE(pull_audio_thread_->Start());
|
ASSERT_TRUE(pull_audio_thread_->Start());
|
||||||
pull_audio_thread_->SetPriority(kRealtimePriority);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void TearDown() {
|
void TearDown() {
|
||||||
|
@ -532,36 +532,40 @@ void APITest::Perform() {
|
|||||||
// A
|
// A
|
||||||
// PUSH
|
// PUSH
|
||||||
rtc::scoped_ptr<ThreadWrapper> myPushAudioThreadA =
|
rtc::scoped_ptr<ThreadWrapper> myPushAudioThreadA =
|
||||||
ThreadWrapper::CreateThread(PushAudioThreadA, this, "PushAudioThreadA");
|
ThreadWrapper::CreateThread(PushAudioThreadA, this, kNormalPriority,
|
||||||
|
"PushAudioThreadA");
|
||||||
CHECK_THREAD_NULLITY(myPushAudioThreadA, "Unable to start A::PUSH thread");
|
CHECK_THREAD_NULLITY(myPushAudioThreadA, "Unable to start A::PUSH thread");
|
||||||
// PULL
|
// PULL
|
||||||
rtc::scoped_ptr<ThreadWrapper> myPullAudioThreadA =
|
rtc::scoped_ptr<ThreadWrapper> myPullAudioThreadA =
|
||||||
ThreadWrapper::CreateThread(PullAudioThreadA, this, "PullAudioThreadA");
|
ThreadWrapper::CreateThread(PullAudioThreadA, this, kNormalPriority,
|
||||||
|
"PullAudioThreadA");
|
||||||
CHECK_THREAD_NULLITY(myPullAudioThreadA, "Unable to start A::PULL thread");
|
CHECK_THREAD_NULLITY(myPullAudioThreadA, "Unable to start A::PULL thread");
|
||||||
// Process
|
// Process
|
||||||
rtc::scoped_ptr<ThreadWrapper> myProcessThreadA = ThreadWrapper::CreateThread(
|
rtc::scoped_ptr<ThreadWrapper> myProcessThreadA = ThreadWrapper::CreateThread(
|
||||||
ProcessThreadA, this, "ProcessThreadA");
|
ProcessThreadA, this, kNormalPriority, "ProcessThreadA");
|
||||||
CHECK_THREAD_NULLITY(myProcessThreadA, "Unable to start A::Process thread");
|
CHECK_THREAD_NULLITY(myProcessThreadA, "Unable to start A::Process thread");
|
||||||
// API
|
// API
|
||||||
rtc::scoped_ptr<ThreadWrapper> myAPIThreadA = ThreadWrapper::CreateThread(
|
rtc::scoped_ptr<ThreadWrapper> myAPIThreadA = ThreadWrapper::CreateThread(
|
||||||
APIThreadA, this, "APIThreadA");
|
APIThreadA, this, kNormalPriority, "APIThreadA");
|
||||||
CHECK_THREAD_NULLITY(myAPIThreadA, "Unable to start A::API thread");
|
CHECK_THREAD_NULLITY(myAPIThreadA, "Unable to start A::API thread");
|
||||||
// B
|
// B
|
||||||
// PUSH
|
// PUSH
|
||||||
rtc::scoped_ptr<ThreadWrapper> myPushAudioThreadB =
|
rtc::scoped_ptr<ThreadWrapper> myPushAudioThreadB =
|
||||||
ThreadWrapper::CreateThread(PushAudioThreadB, this, "PushAudioThreadB");
|
ThreadWrapper::CreateThread(PushAudioThreadB, this, kNormalPriority,
|
||||||
|
"PushAudioThreadB");
|
||||||
CHECK_THREAD_NULLITY(myPushAudioThreadB, "Unable to start B::PUSH thread");
|
CHECK_THREAD_NULLITY(myPushAudioThreadB, "Unable to start B::PUSH thread");
|
||||||
// PULL
|
// PULL
|
||||||
rtc::scoped_ptr<ThreadWrapper> myPullAudioThreadB =
|
rtc::scoped_ptr<ThreadWrapper> myPullAudioThreadB =
|
||||||
ThreadWrapper::CreateThread(PullAudioThreadB, this, "PullAudioThreadB");
|
ThreadWrapper::CreateThread(PullAudioThreadB, this, kNormalPriority,
|
||||||
|
"PullAudioThreadB");
|
||||||
CHECK_THREAD_NULLITY(myPullAudioThreadB, "Unable to start B::PULL thread");
|
CHECK_THREAD_NULLITY(myPullAudioThreadB, "Unable to start B::PULL thread");
|
||||||
// Process
|
// Process
|
||||||
rtc::scoped_ptr<ThreadWrapper> myProcessThreadB = ThreadWrapper::CreateThread(
|
rtc::scoped_ptr<ThreadWrapper> myProcessThreadB = ThreadWrapper::CreateThread(
|
||||||
ProcessThreadB, this, "ProcessThreadB");
|
ProcessThreadB, this, kNormalPriority, "ProcessThreadB");
|
||||||
CHECK_THREAD_NULLITY(myProcessThreadB, "Unable to start B::Process thread");
|
CHECK_THREAD_NULLITY(myProcessThreadB, "Unable to start B::Process thread");
|
||||||
// API
|
// API
|
||||||
rtc::scoped_ptr<ThreadWrapper> myAPIThreadB = ThreadWrapper::CreateThread(
|
rtc::scoped_ptr<ThreadWrapper> myAPIThreadB = ThreadWrapper::CreateThread(
|
||||||
APIThreadB, this, "APIThreadB");
|
APIThreadB, this, kNormalPriority, "APIThreadB");
|
||||||
CHECK_THREAD_NULLITY(myAPIThreadB, "Unable to start B::API thread");
|
CHECK_THREAD_NULLITY(myAPIThreadB, "Unable to start B::API thread");
|
||||||
|
|
||||||
//_apiEventA->StartTimer(true, 5000);
|
//_apiEventA->StartTimer(true, 5000);
|
||||||
|
@ -22,8 +22,10 @@ static const int kEventMsg = 1;
|
|||||||
class LowLatencyEventTest : public testing::Test {
|
class LowLatencyEventTest : public testing::Test {
|
||||||
public:
|
public:
|
||||||
LowLatencyEventTest()
|
LowLatencyEventTest()
|
||||||
: process_thread_(ThreadWrapper::CreateThread(
|
: process_thread_(ThreadWrapper::CreateThread(CbThread,
|
||||||
CbThread, this, "test_thread")),
|
this,
|
||||||
|
kRealtimePriority,
|
||||||
|
"test_thread")),
|
||||||
terminated_(false),
|
terminated_(false),
|
||||||
iteration_count_(0),
|
iteration_count_(0),
|
||||||
allowed_iterations_(0) {
|
allowed_iterations_(0) {
|
||||||
@ -44,7 +46,6 @@ class LowLatencyEventTest : public testing::Test {
|
|||||||
private:
|
private:
|
||||||
void Start() {
|
void Start() {
|
||||||
EXPECT_TRUE(process_thread_->Start());
|
EXPECT_TRUE(process_thread_->Start());
|
||||||
process_thread_->SetPriority(kRealtimePriority);
|
|
||||||
}
|
}
|
||||||
void Stop() {
|
void Stop() {
|
||||||
terminated_ = true;
|
terminated_ = true;
|
||||||
|
@ -470,14 +470,13 @@ void OpenSlesInput::RecorderSimpleBufferQueueCallbackHandler(
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool OpenSlesInput::StartCbThreads() {
|
bool OpenSlesInput::StartCbThreads() {
|
||||||
rec_thread_ = ThreadWrapper::CreateThread(CbThread, this,
|
rec_thread_ = ThreadWrapper::CreateThread(CbThread, this, kRealtimePriority,
|
||||||
"opensl_rec_thread");
|
"opensl_rec_thread");
|
||||||
assert(rec_thread_.get());
|
assert(rec_thread_.get());
|
||||||
if (!rec_thread_->Start()) {
|
if (!rec_thread_->Start()) {
|
||||||
assert(false);
|
assert(false);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
rec_thread_->SetPriority(kRealtimePriority);
|
|
||||||
OPENSL_RETURN_ON_FAILURE(
|
OPENSL_RETURN_ON_FAILURE(
|
||||||
(*sles_recorder_itf_)->SetRecordState(sles_recorder_itf_,
|
(*sles_recorder_itf_)->SetRecordState(sles_recorder_itf_,
|
||||||
SL_RECORDSTATE_RECORDING),
|
SL_RECORDSTATE_RECORDING),
|
||||||
|
@ -510,7 +510,7 @@ void OpenSlesOutput::PlayerSimpleBufferQueueCallbackHandler(
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool OpenSlesOutput::StartCbThreads() {
|
bool OpenSlesOutput::StartCbThreads() {
|
||||||
play_thread_ = ThreadWrapper::CreateThread(CbThread, this,
|
play_thread_ = ThreadWrapper::CreateThread(CbThread, this, kRealtimePriority,
|
||||||
"opensl_play_thread");
|
"opensl_play_thread");
|
||||||
assert(play_thread_.get());
|
assert(play_thread_.get());
|
||||||
OPENSL_RETURN_ON_FAILURE(
|
OPENSL_RETURN_ON_FAILURE(
|
||||||
@ -522,7 +522,6 @@ bool OpenSlesOutput::StartCbThreads() {
|
|||||||
assert(false);
|
assert(false);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
play_thread_->SetPriority(kRealtimePriority);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -205,6 +205,12 @@ int32_t FileAudioDevice::StartPlayout() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// PLAYOUT
|
// PLAYOUT
|
||||||
|
const char* threadName = "webrtc_audio_module_play_thread";
|
||||||
|
_ptrThreadPlay = ThreadWrapper::CreateThread(PlayThreadFunc,
|
||||||
|
this,
|
||||||
|
kRealtimePriority,
|
||||||
|
threadName);
|
||||||
|
|
||||||
if (!_outputFilename.empty() && _outputFile.OpenFile(
|
if (!_outputFilename.empty() && _outputFile.OpenFile(
|
||||||
_outputFilename.c_str(), false, false, false) == -1) {
|
_outputFilename.c_str(), false, false, false) == -1) {
|
||||||
printf("Failed to open playout file %s!\n", _outputFilename.c_str());
|
printf("Failed to open playout file %s!\n", _outputFilename.c_str());
|
||||||
@ -214,9 +220,6 @@ int32_t FileAudioDevice::StartPlayout() {
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* threadName = "webrtc_audio_module_play_thread";
|
|
||||||
_ptrThreadPlay = ThreadWrapper::CreateThread(PlayThreadFunc, this,
|
|
||||||
threadName);
|
|
||||||
if (!_ptrThreadPlay->Start()) {
|
if (!_ptrThreadPlay->Start()) {
|
||||||
_ptrThreadPlay.reset();
|
_ptrThreadPlay.reset();
|
||||||
_playing = false;
|
_playing = false;
|
||||||
@ -224,7 +227,7 @@ int32_t FileAudioDevice::StartPlayout() {
|
|||||||
_playoutBuffer = NULL;
|
_playoutBuffer = NULL;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
_ptrThreadPlay->SetPriority(kRealtimePriority);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -278,7 +281,10 @@ int32_t FileAudioDevice::StartRecording() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const char* threadName = "webrtc_audio_module_capture_thread";
|
const char* threadName = "webrtc_audio_module_capture_thread";
|
||||||
_ptrThreadRec = ThreadWrapper::CreateThread(RecThreadFunc, this, threadName);
|
_ptrThreadRec = ThreadWrapper::CreateThread(RecThreadFunc,
|
||||||
|
this,
|
||||||
|
kRealtimePriority,
|
||||||
|
threadName);
|
||||||
|
|
||||||
if (!_ptrThreadRec->Start()) {
|
if (!_ptrThreadRec->Start()) {
|
||||||
_ptrThreadRec.reset();
|
_ptrThreadRec.reset();
|
||||||
@ -287,7 +293,6 @@ int32_t FileAudioDevice::StartRecording() {
|
|||||||
_recordingBuffer = NULL;
|
_recordingBuffer = NULL;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
_ptrThreadRec->SetPriority(kRealtimePriority);
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -107,12 +107,12 @@ int32_t AudioDeviceIOS::Init() {
|
|||||||
|
|
||||||
// Create and start capture thread
|
// Create and start capture thread
|
||||||
if (!_captureWorkerThread) {
|
if (!_captureWorkerThread) {
|
||||||
_captureWorkerThread = ThreadWrapper::CreateThread(
|
_captureWorkerThread
|
||||||
RunCapture, this, "CaptureWorkerThread");
|
= ThreadWrapper::CreateThread(RunCapture, this, kRealtimePriority,
|
||||||
|
"CaptureWorkerThread");
|
||||||
bool res = _captureWorkerThread->Start();
|
bool res = _captureWorkerThread->Start();
|
||||||
WEBRTC_TRACE(kTraceDebug, kTraceAudioDevice,
|
WEBRTC_TRACE(kTraceDebug, kTraceAudioDevice,
|
||||||
_id, "CaptureWorkerThread started (res=%d)", res);
|
_id, "CaptureWorkerThread started (res=%d)", res);
|
||||||
_captureWorkerThread->SetPriority(kRealtimePriority);
|
|
||||||
} else {
|
} else {
|
||||||
WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice,
|
WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice,
|
||||||
_id, "Thread already created");
|
_id, "Thread already created");
|
||||||
|
@ -1365,8 +1365,10 @@ int32_t AudioDeviceLinuxALSA::StartRecording()
|
|||||||
}
|
}
|
||||||
// RECORDING
|
// RECORDING
|
||||||
const char* threadName = "webrtc_audio_module_capture_thread";
|
const char* threadName = "webrtc_audio_module_capture_thread";
|
||||||
_ptrThreadRec = ThreadWrapper::CreateThread(
|
_ptrThreadRec = ThreadWrapper::CreateThread(RecThreadFunc,
|
||||||
RecThreadFunc, this, threadName);
|
this,
|
||||||
|
kRealtimePriority,
|
||||||
|
threadName);
|
||||||
|
|
||||||
if (!_ptrThreadRec->Start())
|
if (!_ptrThreadRec->Start())
|
||||||
{
|
{
|
||||||
@ -1378,7 +1380,6 @@ int32_t AudioDeviceLinuxALSA::StartRecording()
|
|||||||
_recordingBuffer = NULL;
|
_recordingBuffer = NULL;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
_ptrThreadRec->SetPriority(kRealtimePriority);
|
|
||||||
|
|
||||||
errVal = LATE(snd_pcm_prepare)(_handleRecord);
|
errVal = LATE(snd_pcm_prepare)(_handleRecord);
|
||||||
if (errVal < 0)
|
if (errVal < 0)
|
||||||
@ -1519,7 +1520,9 @@ int32_t AudioDeviceLinuxALSA::StartPlayout()
|
|||||||
|
|
||||||
// PLAYOUT
|
// PLAYOUT
|
||||||
const char* threadName = "webrtc_audio_module_play_thread";
|
const char* threadName = "webrtc_audio_module_play_thread";
|
||||||
_ptrThreadPlay = ThreadWrapper::CreateThread(PlayThreadFunc, this,
|
_ptrThreadPlay = ThreadWrapper::CreateThread(PlayThreadFunc,
|
||||||
|
this,
|
||||||
|
kRealtimePriority,
|
||||||
threadName);
|
threadName);
|
||||||
if (!_ptrThreadPlay->Start())
|
if (!_ptrThreadPlay->Start())
|
||||||
{
|
{
|
||||||
@ -1531,7 +1534,6 @@ int32_t AudioDeviceLinuxALSA::StartPlayout()
|
|||||||
_playoutBuffer = NULL;
|
_playoutBuffer = NULL;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
_ptrThreadPlay->SetPriority(kRealtimePriority);
|
|
||||||
|
|
||||||
int errVal = LATE(snd_pcm_prepare)(_handlePlayout);
|
int errVal = LATE(snd_pcm_prepare)(_handlePlayout);
|
||||||
if (errVal < 0)
|
if (errVal < 0)
|
||||||
|
@ -208,7 +208,7 @@ int32_t AudioDeviceLinuxPulse::Init()
|
|||||||
// RECORDING
|
// RECORDING
|
||||||
const char* threadName = "webrtc_audio_module_rec_thread";
|
const char* threadName = "webrtc_audio_module_rec_thread";
|
||||||
_ptrThreadRec = ThreadWrapper::CreateThread(RecThreadFunc, this,
|
_ptrThreadRec = ThreadWrapper::CreateThread(RecThreadFunc, this,
|
||||||
threadName);
|
kRealtimePriority, threadName);
|
||||||
if (!_ptrThreadRec->Start())
|
if (!_ptrThreadRec->Start())
|
||||||
{
|
{
|
||||||
WEBRTC_TRACE(kTraceCritical, kTraceAudioDevice, _id,
|
WEBRTC_TRACE(kTraceCritical, kTraceAudioDevice, _id,
|
||||||
@ -218,12 +218,10 @@ int32_t AudioDeviceLinuxPulse::Init()
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
_ptrThreadRec->SetPriority(kRealtimePriority);
|
|
||||||
|
|
||||||
// PLAYOUT
|
// PLAYOUT
|
||||||
threadName = "webrtc_audio_module_play_thread";
|
threadName = "webrtc_audio_module_play_thread";
|
||||||
_ptrThreadPlay = ThreadWrapper::CreateThread(PlayThreadFunc, this,
|
_ptrThreadPlay = ThreadWrapper::CreateThread(PlayThreadFunc, this,
|
||||||
threadName);
|
kRealtimePriority, threadName);
|
||||||
if (!_ptrThreadPlay->Start())
|
if (!_ptrThreadPlay->Start())
|
||||||
{
|
{
|
||||||
WEBRTC_TRACE(kTraceCritical, kTraceAudioDevice, _id,
|
WEBRTC_TRACE(kTraceCritical, kTraceAudioDevice, _id,
|
||||||
@ -232,7 +230,6 @@ int32_t AudioDeviceLinuxPulse::Init()
|
|||||||
_ptrThreadPlay.reset();
|
_ptrThreadPlay.reset();
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
_ptrThreadPlay->SetPriority(kRealtimePriority);
|
|
||||||
|
|
||||||
_initialized = true;
|
_initialized = true;
|
||||||
|
|
||||||
|
@ -1667,10 +1667,10 @@ int32_t AudioDeviceMac::StartRecording()
|
|||||||
|
|
||||||
DCHECK(!capture_worker_thread_.get());
|
DCHECK(!capture_worker_thread_.get());
|
||||||
capture_worker_thread_ =
|
capture_worker_thread_ =
|
||||||
ThreadWrapper::CreateThread(RunCapture, this, "CaptureWorkerThread");
|
ThreadWrapper::CreateThread(RunCapture, this, kRealtimePriority,
|
||||||
|
"CaptureWorkerThread");
|
||||||
DCHECK(capture_worker_thread_.get());
|
DCHECK(capture_worker_thread_.get());
|
||||||
capture_worker_thread_->Start();
|
capture_worker_thread_->Start();
|
||||||
capture_worker_thread_->SetPriority(kRealtimePriority);
|
|
||||||
|
|
||||||
OSStatus err = noErr;
|
OSStatus err = noErr;
|
||||||
if (_twoDevices)
|
if (_twoDevices)
|
||||||
@ -1822,9 +1822,9 @@ int32_t AudioDeviceMac::StartPlayout()
|
|||||||
|
|
||||||
DCHECK(!render_worker_thread_.get());
|
DCHECK(!render_worker_thread_.get());
|
||||||
render_worker_thread_ =
|
render_worker_thread_ =
|
||||||
ThreadWrapper::CreateThread(RunRender, this, "RenderWorkerThread");
|
ThreadWrapper::CreateThread(RunRender, this, kRealtimePriority,
|
||||||
|
"RenderWorkerThread");
|
||||||
render_worker_thread_->Start();
|
render_worker_thread_->Start();
|
||||||
render_worker_thread_->SetPriority(kRealtimePriority);
|
|
||||||
|
|
||||||
if (_twoDevices || !_recording)
|
if (_twoDevices || !_recording)
|
||||||
{
|
{
|
||||||
|
@ -228,7 +228,10 @@ int32_t AudioDeviceWindowsWave::Init()
|
|||||||
}
|
}
|
||||||
|
|
||||||
const char* threadName = "webrtc_audio_module_thread";
|
const char* threadName = "webrtc_audio_module_thread";
|
||||||
_ptrThread = ThreadWrapper::CreateThread(ThreadFunc, this, threadName);
|
_ptrThread = ThreadWrapper::CreateThread(ThreadFunc,
|
||||||
|
this,
|
||||||
|
kRealtimePriority,
|
||||||
|
threadName);
|
||||||
if (!_ptrThread->Start())
|
if (!_ptrThread->Start())
|
||||||
{
|
{
|
||||||
WEBRTC_TRACE(kTraceCritical, kTraceAudioDevice, _id,
|
WEBRTC_TRACE(kTraceCritical, kTraceAudioDevice, _id,
|
||||||
@ -236,7 +239,6 @@ int32_t AudioDeviceWindowsWave::Init()
|
|||||||
_ptrThread.reset();
|
_ptrThread.reset();
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
_ptrThread->SetPriority(kRealtimePriority);
|
|
||||||
|
|
||||||
const bool periodic(true);
|
const bool periodic(true);
|
||||||
if (!_timeEvent.StartTimer(periodic, TIMER_PERIOD_MS))
|
if (!_timeEvent.StartTimer(periodic, TIMER_PERIOD_MS))
|
||||||
|
@ -77,11 +77,10 @@ int32_t TestLoadGenerator::Start (const char *threadName)
|
|||||||
_eventPtr = EventWrapper::Create();
|
_eventPtr = EventWrapper::Create();
|
||||||
|
|
||||||
_genThread = ThreadWrapper::CreateThread(SenderThreadFunction, this,
|
_genThread = ThreadWrapper::CreateThread(SenderThreadFunction, this,
|
||||||
threadName);
|
kRealtimePriority, threadName);
|
||||||
_running = true;
|
_running = true;
|
||||||
|
|
||||||
_genThread->Start();
|
_genThread->Start();
|
||||||
_genThread->SetPriority(kRealtimePriority);
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -164,7 +164,7 @@ int32_t TestSenderReceiver::Start()
|
|||||||
}
|
}
|
||||||
|
|
||||||
_procThread = ThreadWrapper::CreateThread(ProcThreadFunction, this,
|
_procThread = ThreadWrapper::CreateThread(ProcThreadFunction, this,
|
||||||
"TestSenderReceiver");
|
kRealtimePriority, "TestSenderReceiver");
|
||||||
|
|
||||||
_running = true;
|
_running = true;
|
||||||
|
|
||||||
@ -178,7 +178,6 @@ int32_t TestSenderReceiver::Start()
|
|||||||
}
|
}
|
||||||
|
|
||||||
_procThread->Start();
|
_procThread->Start();
|
||||||
_procThread->SetPriority(kRealtimePriority);
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
@ -70,7 +70,7 @@ void ProcessThreadImpl::Start() {
|
|||||||
m.module->ProcessThreadAttached(this);
|
m.module->ProcessThreadAttached(this);
|
||||||
|
|
||||||
thread_ = ThreadWrapper::CreateThread(
|
thread_ = ThreadWrapper::CreateThread(
|
||||||
&ProcessThreadImpl::Run, this, "ProcessThread");
|
&ProcessThreadImpl::Run, this, kNormalPriority, "ProcessThread");
|
||||||
CHECK(thread_->Start());
|
CHECK(thread_->Start());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -281,9 +281,8 @@ int32_t VideoCaptureModuleV4L2::StartCapture(
|
|||||||
if (!_captureThread)
|
if (!_captureThread)
|
||||||
{
|
{
|
||||||
_captureThread = ThreadWrapper::CreateThread(
|
_captureThread = ThreadWrapper::CreateThread(
|
||||||
VideoCaptureModuleV4L2::CaptureThread, this, "CaptureThread");
|
VideoCaptureModuleV4L2::CaptureThread, this, kHighPriority);
|
||||||
_captureThread->Start();
|
_captureThread->Start();
|
||||||
_captureThread->SetPriority(kHighPriority);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Needed to start UVC camera - from the uvcview application
|
// Needed to start UVC camera - from the uvcview application
|
||||||
|
@ -142,6 +142,7 @@ int32_t VideoRenderAndroid::StartRender() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
_javaRenderThread = ThreadWrapper::CreateThread(JavaRenderThreadFun, this,
|
_javaRenderThread = ThreadWrapper::CreateThread(JavaRenderThreadFun, this,
|
||||||
|
kRealtimePriority,
|
||||||
"AndroidRenderThread");
|
"AndroidRenderThread");
|
||||||
|
|
||||||
if (_javaRenderThread->Start())
|
if (_javaRenderThread->Start())
|
||||||
@ -152,7 +153,6 @@ int32_t VideoRenderAndroid::StartRender() {
|
|||||||
"%s: Could not start send thread", __FUNCTION__);
|
"%s: Could not start send thread", __FUNCTION__);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
_javaRenderThread->SetPriority(kRealtimePriority);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -179,7 +179,8 @@ int32_t IncomingVideoStream::Start() {
|
|||||||
assert(incoming_render_thread_ == NULL);
|
assert(incoming_render_thread_ == NULL);
|
||||||
|
|
||||||
incoming_render_thread_ = ThreadWrapper::CreateThread(
|
incoming_render_thread_ = ThreadWrapper::CreateThread(
|
||||||
IncomingVideoStreamThreadFun, this, "IncomingVideoStreamThread");
|
IncomingVideoStreamThreadFun, this, kRealtimePriority,
|
||||||
|
"IncomingVideoStreamThread");
|
||||||
if (!incoming_render_thread_) {
|
if (!incoming_render_thread_) {
|
||||||
WEBRTC_TRACE(kTraceError, kTraceVideoRenderer, module_id_,
|
WEBRTC_TRACE(kTraceError, kTraceVideoRenderer, module_id_,
|
||||||
"%s: No thread", __FUNCTION__);
|
"%s: No thread", __FUNCTION__);
|
||||||
@ -194,7 +195,6 @@ int32_t IncomingVideoStream::Start() {
|
|||||||
"%s: Could not start send thread", __FUNCTION__);
|
"%s: Could not start send thread", __FUNCTION__);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
incoming_render_thread_->SetPriority(kRealtimePriority);
|
|
||||||
deliver_buffer_event_.StartTimer(false, KEventStartupTimeMS);
|
deliver_buffer_event_.StartTimer(false, KEventStartupTimeMS);
|
||||||
|
|
||||||
running_ = true;
|
running_ = true;
|
||||||
|
@ -33,7 +33,7 @@ VideoRenderIosGles20::VideoRenderIosGles20(VideoRenderIosView* view,
|
|||||||
gles_context_([view context]),
|
gles_context_([view context]),
|
||||||
is_rendering_(true) {
|
is_rendering_(true) {
|
||||||
screen_update_thread_ = ThreadWrapper::CreateThread(
|
screen_update_thread_ = ThreadWrapper::CreateThread(
|
||||||
ScreenUpdateThreadProc, this, "ScreenUpdateGles20");
|
ScreenUpdateThreadProc, this, kRealtimePriority);
|
||||||
screen_update_event_ = EventWrapper::Create();
|
screen_update_event_ = EventWrapper::Create();
|
||||||
GetWindowRect(window_rect_);
|
GetWindowRect(window_rect_);
|
||||||
}
|
}
|
||||||
@ -83,7 +83,6 @@ int VideoRenderIosGles20::Init() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
screen_update_thread_->Start();
|
screen_update_thread_->Start();
|
||||||
screen_update_thread_->SetPriority(kRealtimePriority);
|
|
||||||
|
|
||||||
// Start the event triggering the render process
|
// Start the event triggering the render process
|
||||||
unsigned int monitor_freq = 60;
|
unsigned int monitor_freq = 60;
|
||||||
|
@ -395,8 +395,7 @@ _renderingIsPaused( false),
|
|||||||
{
|
{
|
||||||
//WEBRTC_TRACE(kTraceInfo, kTraceVideoRenderer, _id, "%s");
|
//WEBRTC_TRACE(kTraceInfo, kTraceVideoRenderer, _id, "%s");
|
||||||
|
|
||||||
_screenUpdateThread = ThreadWrapper::CreateThread(
|
_screenUpdateThread = ThreadWrapper::CreateThread(ScreenUpdateThreadProc, this, kRealtimePriority);
|
||||||
ScreenUpdateThreadProc, this, "ScreenUpdate");
|
|
||||||
_screenUpdateEvent = EventWrapper::Create();
|
_screenUpdateEvent = EventWrapper::Create();
|
||||||
|
|
||||||
if(!IsValidWindowPtr(_windowRef))
|
if(!IsValidWindowPtr(_windowRef))
|
||||||
@ -512,8 +511,7 @@ _renderingIsPaused( false),
|
|||||||
//WEBRTC_TRACE(kTraceDebug, "%s:%d Constructor", __FUNCTION__, __LINE__);
|
//WEBRTC_TRACE(kTraceDebug, "%s:%d Constructor", __FUNCTION__, __LINE__);
|
||||||
// _renderCritSec = CriticalSectionWrapper::CreateCriticalSection();
|
// _renderCritSec = CriticalSectionWrapper::CreateCriticalSection();
|
||||||
|
|
||||||
_screenUpdateThread = ThreadWrapper::CreateThread(
|
_screenUpdateThread = ThreadWrapper::CreateThread(ScreenUpdateThreadProc, this, kRealtimePriority);
|
||||||
ScreenUpdateThreadProc, this, "ScreenUpdateThread");
|
|
||||||
_screenUpdateEvent = EventWrapper::Create();
|
_screenUpdateEvent = EventWrapper::Create();
|
||||||
|
|
||||||
GetWindowRect(_windowRect);
|
GetWindowRect(_windowRect);
|
||||||
@ -739,7 +737,6 @@ int VideoRenderAGL::Init()
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
_screenUpdateThread->Start();
|
_screenUpdateThread->Start();
|
||||||
_screenUpdateThread->SetPriority(kRealtimePriority);
|
|
||||||
|
|
||||||
// Start the event triggering the render process
|
// Start the event triggering the render process
|
||||||
unsigned int monitorFreq = 60;
|
unsigned int monitorFreq = 60;
|
||||||
@ -1880,7 +1877,6 @@ int32_t VideoRenderAGL::StartRender()
|
|||||||
UnlockAGLCntx();
|
UnlockAGLCntx();
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
_screenUpdateThread->SetPriority(kRealtimePriority);
|
|
||||||
if(FALSE == _screenUpdateEvent->StartTimer(true, 1000/MONITOR_FREQ))
|
if(FALSE == _screenUpdateEvent->StartTimer(true, 1000/MONITOR_FREQ))
|
||||||
{
|
{
|
||||||
//WEBRTC_TRACE(kTraceError, kTraceVideoRenderer, _id, "%s:%d Failed to start screenUpdateEvent", __FUNCTION__, __LINE__);
|
//WEBRTC_TRACE(kTraceError, kTraceVideoRenderer, _id, "%s:%d Failed to start screenUpdateEvent", __FUNCTION__, __LINE__);
|
||||||
@ -1891,8 +1887,7 @@ int32_t VideoRenderAGL::StartRender()
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
_screenUpdateThread = ThreadWrapper::CreateThread(ScreenUpdateThreadProc,
|
_screenUpdateThread = ThreadWrapper::CreateThread(ScreenUpdateThreadProc, this, kRealtimePriority);
|
||||||
this, "ScreenUpdate");
|
|
||||||
_screenUpdateEvent = EventWrapper::Create();
|
_screenUpdateEvent = EventWrapper::Create();
|
||||||
|
|
||||||
if (!_screenUpdateThread)
|
if (!_screenUpdateThread)
|
||||||
@ -1903,7 +1898,6 @@ int32_t VideoRenderAGL::StartRender()
|
|||||||
}
|
}
|
||||||
|
|
||||||
_screenUpdateThread->Start();
|
_screenUpdateThread->Start();
|
||||||
_screenUpdateThread->SetPriority(kRealtimePriority);
|
|
||||||
_screenUpdateEvent->StartTimer(true, 1000/MONITOR_FREQ);
|
_screenUpdateEvent->StartTimer(true, 1000/MONITOR_FREQ);
|
||||||
|
|
||||||
//WEBRTC_TRACE(kTraceInfo, kTraceVideoRenderer, _id, "%s:%d Started screenUpdateThread", __FUNCTION__, __LINE__);
|
//WEBRTC_TRACE(kTraceInfo, kTraceVideoRenderer, _id, "%s:%d Started screenUpdateThread", __FUNCTION__, __LINE__);
|
||||||
|
@ -380,8 +380,7 @@ _renderingIsPaused (FALSE),
|
|||||||
_windowRefSuperView(NULL),
|
_windowRefSuperView(NULL),
|
||||||
_windowRefSuperViewFrame(NSMakeRect(0,0,0,0))
|
_windowRefSuperViewFrame(NSMakeRect(0,0,0,0))
|
||||||
{
|
{
|
||||||
_screenUpdateThread = ThreadWrapper::CreateThread(ScreenUpdateThreadProc,
|
_screenUpdateThread = ThreadWrapper::CreateThread(ScreenUpdateThreadProc, this, kRealtimePriority);
|
||||||
this, "ScreenUpdateNSOpenGL");
|
|
||||||
_screenUpdateEvent = EventWrapper::Create();
|
_screenUpdateEvent = EventWrapper::Create();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -438,8 +437,6 @@ int32_t VideoRenderNSOpenGL::StartRender()
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
_screenUpdateThread->SetPriority(kRealtimePriority);
|
|
||||||
|
|
||||||
UnlockAGLCntx();
|
UnlockAGLCntx();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -719,7 +716,6 @@ int VideoRenderNSOpenGL::Init()
|
|||||||
}
|
}
|
||||||
|
|
||||||
_screenUpdateThread->Start();
|
_screenUpdateThread->Start();
|
||||||
_screenUpdateThread->SetPriority(kRealtimePriority);
|
|
||||||
|
|
||||||
// Start the event triggering the render process
|
// Start the event triggering the render process
|
||||||
unsigned int monitorFreq = 60;
|
unsigned int monitorFreq = 60;
|
||||||
|
@ -295,8 +295,8 @@ VideoRenderDirect3D9::VideoRenderDirect3D9(Trace* trace,
|
|||||||
_totalMemory(0),
|
_totalMemory(0),
|
||||||
_availableMemory(0)
|
_availableMemory(0)
|
||||||
{
|
{
|
||||||
_screenUpdateThread = ThreadWrapper::CreateThread(
|
_screenUpdateThread = ThreadWrapper::CreateThread(ScreenUpdateThreadProc,
|
||||||
ScreenUpdateThreadProc, this, "ScreenUpdateThread");
|
this, kRealtimePriority);
|
||||||
_screenUpdateEvent = EventWrapper::Create();
|
_screenUpdateEvent = EventWrapper::Create();
|
||||||
SetRect(&_originalHwndRect, 0, 0, 0, 0);
|
SetRect(&_originalHwndRect, 0, 0, 0, 0);
|
||||||
}
|
}
|
||||||
@ -547,7 +547,6 @@ int32_t VideoRenderDirect3D9::Init()
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
_screenUpdateThread->Start();
|
_screenUpdateThread->Start();
|
||||||
_screenUpdateThread->SetPriority(kRealtimePriority);
|
|
||||||
|
|
||||||
// Start the event triggering the render process
|
// Start the event triggering the render process
|
||||||
unsigned int monitorFreq = 60;
|
unsigned int monitorFreq = 60;
|
||||||
|
@ -16,10 +16,6 @@
|
|||||||
#ifndef WEBRTC_SYSTEM_WRAPPERS_INTERFACE_THREAD_WRAPPER_H_
|
#ifndef WEBRTC_SYSTEM_WRAPPERS_INTERFACE_THREAD_WRAPPER_H_
|
||||||
#define WEBRTC_SYSTEM_WRAPPERS_INTERFACE_THREAD_WRAPPER_H_
|
#define WEBRTC_SYSTEM_WRAPPERS_INTERFACE_THREAD_WRAPPER_H_
|
||||||
|
|
||||||
#if defined(WEBRTC_WIN)
|
|
||||||
#include <windows.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "webrtc/base/scoped_ptr.h"
|
#include "webrtc/base/scoped_ptr.h"
|
||||||
#include "webrtc/common_types.h"
|
#include "webrtc/common_types.h"
|
||||||
#include "webrtc/typedefs.h"
|
#include "webrtc/typedefs.h"
|
||||||
@ -32,19 +28,11 @@ namespace webrtc {
|
|||||||
typedef bool(*ThreadRunFunction)(void*);
|
typedef bool(*ThreadRunFunction)(void*);
|
||||||
|
|
||||||
enum ThreadPriority {
|
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,
|
kLowPriority = 1,
|
||||||
kNormalPriority = 2,
|
kNormalPriority = 2,
|
||||||
kHighPriority = 3,
|
kHighPriority = 3,
|
||||||
kHighestPriority = 4,
|
kHighestPriority = 4,
|
||||||
kRealtimePriority = 5
|
kRealtimePriority = 5
|
||||||
#endif
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// Represents a simple worker thread. The implementation must be assumed
|
// Represents a simple worker thread. The implementation must be assumed
|
||||||
@ -64,8 +52,11 @@ class ThreadWrapper {
|
|||||||
// prio Thread priority. May require root/admin rights.
|
// prio Thread priority. May require root/admin rights.
|
||||||
// thread_name NULL terminated thread name, will be visable in the Windows
|
// thread_name NULL terminated thread name, will be visable in the Windows
|
||||||
// debugger.
|
// 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<ThreadWrapper> CreateThread(ThreadRunFunction func,
|
static rtc::scoped_ptr<ThreadWrapper> CreateThread(ThreadRunFunction func,
|
||||||
void* obj, const char* thread_name);
|
void* obj, ThreadPriority prio = kNormalPriority,
|
||||||
|
const char* thread_name = 0);
|
||||||
|
|
||||||
// Get the current thread's thread ID.
|
// Get the current thread's thread ID.
|
||||||
// NOTE: This is a static method. It returns the id of the calling thread,
|
// NOTE: This is a static method. It returns the id of the calling thread,
|
||||||
@ -84,10 +75,6 @@ class ThreadWrapper {
|
|||||||
// Multiple tries to Stop are allowed (e.g. to wait longer than 2 seconds).
|
// 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.
|
// It's ok to call Stop() even if the spawned thread has been reclaimed.
|
||||||
virtual bool Stop() = 0;
|
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
|
} // namespace webrtc
|
||||||
|
@ -145,7 +145,7 @@ class CondVarTest : public ::testing::Test {
|
|||||||
|
|
||||||
virtual void SetUp() {
|
virtual void SetUp() {
|
||||||
thread_ = ThreadWrapper::CreateThread(&WaitingRunFunction,
|
thread_ = ThreadWrapper::CreateThread(&WaitingRunFunction,
|
||||||
&baton_, "CondVarTest");
|
&baton_);
|
||||||
ASSERT_TRUE(thread_->Start());
|
ASSERT_TRUE(thread_->Start());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -79,7 +79,7 @@ TEST_F(CritSectTest, ThreadWakesOnce) NO_THREAD_SAFETY_ANALYSIS {
|
|||||||
CriticalSectionWrapper::CreateCriticalSection();
|
CriticalSectionWrapper::CreateCriticalSection();
|
||||||
ProtectedCount count(crit_sect);
|
ProtectedCount count(crit_sect);
|
||||||
rtc::scoped_ptr<ThreadWrapper> thread = ThreadWrapper::CreateThread(
|
rtc::scoped_ptr<ThreadWrapper> thread = ThreadWrapper::CreateThread(
|
||||||
&LockUnlockThenStopRunFunction, &count, "ThreadWakesOnce");
|
&LockUnlockThenStopRunFunction, &count);
|
||||||
crit_sect->Enter();
|
crit_sect->Enter();
|
||||||
ASSERT_TRUE(thread->Start());
|
ASSERT_TRUE(thread->Start());
|
||||||
SwitchProcess();
|
SwitchProcess();
|
||||||
@ -106,7 +106,7 @@ TEST_F(CritSectTest, ThreadWakesTwice) NO_THREAD_SAFETY_ANALYSIS {
|
|||||||
CriticalSectionWrapper::CreateCriticalSection();
|
CriticalSectionWrapper::CreateCriticalSection();
|
||||||
ProtectedCount count(crit_sect);
|
ProtectedCount count(crit_sect);
|
||||||
rtc::scoped_ptr<ThreadWrapper> thread = ThreadWrapper::CreateThread(
|
rtc::scoped_ptr<ThreadWrapper> thread = ThreadWrapper::CreateThread(
|
||||||
&LockUnlockRunFunction, &count, "ThreadWakesTwice");
|
&LockUnlockRunFunction, &count);
|
||||||
crit_sect->Enter(); // Make sure counter stays 0 until we wait for it.
|
crit_sect->Enter(); // Make sure counter stays 0 until we wait for it.
|
||||||
ASSERT_TRUE(thread->Start());
|
ASSERT_TRUE(thread->Start());
|
||||||
crit_sect->Leave();
|
crit_sect->Leave();
|
||||||
|
@ -349,11 +349,13 @@ int DataLogImpl::CreateLog() {
|
|||||||
|
|
||||||
int DataLogImpl::Init() {
|
int DataLogImpl::Init() {
|
||||||
file_writer_thread_ = ThreadWrapper::CreateThread(
|
file_writer_thread_ = ThreadWrapper::CreateThread(
|
||||||
DataLogImpl::Run, instance_, "DataLog");
|
DataLogImpl::Run,
|
||||||
|
instance_,
|
||||||
|
kHighestPriority,
|
||||||
|
"DataLog");
|
||||||
bool success = file_writer_thread_->Start();
|
bool success = file_writer_thread_->Start();
|
||||||
if (!success)
|
if (!success)
|
||||||
return -1;
|
return -1;
|
||||||
file_writer_thread_->SetPriority(kHighestPriority);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -154,11 +154,11 @@ bool EventPosix::StartTimer(bool periodic, unsigned long time) {
|
|||||||
// Start the timer thread
|
// Start the timer thread
|
||||||
timer_event_ = static_cast<EventPosix*>(EventWrapper::Create());
|
timer_event_ = static_cast<EventPosix*>(EventWrapper::Create());
|
||||||
const char* thread_name = "WebRtc_event_timer_thread";
|
const char* thread_name = "WebRtc_event_timer_thread";
|
||||||
timer_thread_ = ThreadWrapper::CreateThread(Run, this, thread_name);
|
timer_thread_ = ThreadWrapper::CreateThread(Run, this, kRealtimePriority,
|
||||||
|
thread_name);
|
||||||
periodic_ = periodic;
|
periodic_ = periodic;
|
||||||
time_ = time;
|
time_ = time;
|
||||||
bool started = timer_thread_->Start();
|
bool started = timer_thread_->Start();
|
||||||
timer_thread_->SetPriority(kRealtimePriority);
|
|
||||||
pthread_mutex_unlock(&mutex_);
|
pthread_mutex_unlock(&mutex_);
|
||||||
|
|
||||||
return started;
|
return started;
|
||||||
|
@ -25,9 +25,10 @@ typedef ThreadPosix ThreadType;
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
rtc::scoped_ptr<ThreadWrapper> ThreadWrapper::CreateThread(
|
rtc::scoped_ptr<ThreadWrapper> ThreadWrapper::CreateThread(
|
||||||
ThreadRunFunction func, void* obj, const char* thread_name) {
|
ThreadRunFunction func, void* obj, ThreadPriority prio,
|
||||||
|
const char* thread_name) {
|
||||||
return rtc::scoped_ptr<ThreadWrapper>(
|
return rtc::scoped_ptr<ThreadWrapper>(
|
||||||
new ThreadType(func, obj, thread_name)).Pass();
|
new ThreadType(func, obj, prio, thread_name)).Pass();
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace webrtc
|
} // namespace webrtc
|
||||||
|
@ -69,9 +69,10 @@ void* ThreadPosix::StartThread(void* param) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ThreadPosix::ThreadPosix(ThreadRunFunction func, void* obj,
|
ThreadPosix::ThreadPosix(ThreadRunFunction func, void* obj,
|
||||||
const char* thread_name)
|
ThreadPriority prio, const char* thread_name)
|
||||||
: run_function_(func),
|
: run_function_(func),
|
||||||
obj_(obj),
|
obj_(obj),
|
||||||
|
prio_(prio),
|
||||||
stop_event_(false, false),
|
stop_event_(false, false),
|
||||||
name_(thread_name ? thread_name : "webrtc"),
|
name_(thread_name ? thread_name : "webrtc"),
|
||||||
thread_(0) {
|
thread_(0) {
|
||||||
@ -111,38 +112,6 @@ bool ThreadPosix::Stop() {
|
|||||||
return true;
|
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() {
|
void ThreadPosix::Run() {
|
||||||
if (!name_.empty()) {
|
if (!name_.empty()) {
|
||||||
// Setting the thread name may fail (harmlessly) if running inside a
|
// Setting the thread name may fail (harmlessly) if running inside a
|
||||||
@ -154,6 +123,27 @@ void ThreadPosix::Run() {
|
|||||||
#endif
|
#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
|
// It's a requirement that for successful thread creation that the run
|
||||||
// function be called at least once (see RunFunctionIsCalled unit test),
|
// function be called at least once (see RunFunctionIsCalled unit test),
|
||||||
// so to fullfill that requirement, we use a |do| loop and not |while|.
|
// so to fullfill that requirement, we use a |do| loop and not |while|.
|
||||||
|
@ -25,15 +25,14 @@ int ConvertToSystemPriority(ThreadPriority priority, int min_prio,
|
|||||||
|
|
||||||
class ThreadPosix : public ThreadWrapper {
|
class ThreadPosix : public ThreadWrapper {
|
||||||
public:
|
public:
|
||||||
ThreadPosix(ThreadRunFunction func, void* obj, const char* thread_name);
|
ThreadPosix(ThreadRunFunction func, void* obj, ThreadPriority prio,
|
||||||
|
const char* thread_name);
|
||||||
~ThreadPosix() override;
|
~ThreadPosix() override;
|
||||||
|
|
||||||
// From ThreadWrapper.
|
// From ThreadWrapper.
|
||||||
bool Start() override;
|
bool Start() override;
|
||||||
bool Stop() override;
|
bool Stop() override;
|
||||||
|
|
||||||
bool SetPriority(ThreadPriority priority) override;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static void* StartThread(void* param);
|
static void* StartThread(void* param);
|
||||||
|
|
||||||
@ -42,6 +41,7 @@ class ThreadPosix : public ThreadWrapper {
|
|||||||
rtc::ThreadChecker thread_checker_;
|
rtc::ThreadChecker thread_checker_;
|
||||||
ThreadRunFunction const run_function_;
|
ThreadRunFunction const run_function_;
|
||||||
void* const obj_;
|
void* const obj_;
|
||||||
|
ThreadPriority prio_;
|
||||||
rtc::Event stop_event_;
|
rtc::Event stop_event_;
|
||||||
const std::string name_;
|
const std::string name_;
|
||||||
|
|
||||||
|
@ -24,7 +24,7 @@ bool NullRunFunction(void* obj) {
|
|||||||
|
|
||||||
TEST(ThreadTest, StartStop) {
|
TEST(ThreadTest, StartStop) {
|
||||||
rtc::scoped_ptr<ThreadWrapper> thread = ThreadWrapper::CreateThread(
|
rtc::scoped_ptr<ThreadWrapper> thread = ThreadWrapper::CreateThread(
|
||||||
&NullRunFunction, nullptr, "ThreadTest");
|
&NullRunFunction, NULL);
|
||||||
ASSERT_TRUE(thread->Start());
|
ASSERT_TRUE(thread->Start());
|
||||||
EXPECT_TRUE(thread->Stop());
|
EXPECT_TRUE(thread->Stop());
|
||||||
}
|
}
|
||||||
@ -40,7 +40,7 @@ bool SetFlagRunFunction(void* obj) {
|
|||||||
TEST(ThreadTest, RunFunctionIsCalled) {
|
TEST(ThreadTest, RunFunctionIsCalled) {
|
||||||
bool flag = false;
|
bool flag = false;
|
||||||
rtc::scoped_ptr<ThreadWrapper> thread = ThreadWrapper::CreateThread(
|
rtc::scoped_ptr<ThreadWrapper> thread = ThreadWrapper::CreateThread(
|
||||||
&SetFlagRunFunction, &flag, "RunFunctionIsCalled");
|
&SetFlagRunFunction, &flag);
|
||||||
ASSERT_TRUE(thread->Start());
|
ASSERT_TRUE(thread->Start());
|
||||||
|
|
||||||
// At this point, the flag may be either true or false.
|
// At this point, the flag may be either true or false.
|
||||||
|
@ -55,9 +55,10 @@ void SetThreadName(DWORD dwThreadID, LPCSTR szThreadName) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ThreadWindows::ThreadWindows(ThreadRunFunction func, void* obj,
|
ThreadWindows::ThreadWindows(ThreadRunFunction func, void* obj,
|
||||||
const char* thread_name)
|
ThreadPriority prio, const char* thread_name)
|
||||||
: run_function_(func),
|
: run_function_(func),
|
||||||
obj_(obj),
|
obj_(obj),
|
||||||
|
prio_(prio),
|
||||||
stop_(false),
|
stop_(false),
|
||||||
thread_(NULL),
|
thread_(NULL),
|
||||||
name_(thread_name ? thread_name : "webrtc") {
|
name_(thread_name ? thread_name : "webrtc") {
|
||||||
@ -97,6 +98,28 @@ bool ThreadWindows::Start() {
|
|||||||
return false;
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -113,11 +136,6 @@ bool ThreadWindows::Stop() {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ThreadWindows::SetPriority(ThreadPriority priority) {
|
|
||||||
DCHECK(main_thread_.CalledOnValidThread());
|
|
||||||
return thread_ && SetThreadPriority(thread_, priority);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ThreadWindows::Run() {
|
void ThreadWindows::Run() {
|
||||||
if (!name_.empty())
|
if (!name_.empty())
|
||||||
SetThreadName(static_cast<DWORD>(-1), name_.c_str());
|
SetThreadName(static_cast<DWORD>(-1), name_.c_str());
|
||||||
|
@ -21,14 +21,13 @@ namespace webrtc {
|
|||||||
|
|
||||||
class ThreadWindows : public ThreadWrapper {
|
class ThreadWindows : public ThreadWrapper {
|
||||||
public:
|
public:
|
||||||
ThreadWindows(ThreadRunFunction func, void* obj, const char* thread_name);
|
ThreadWindows(ThreadRunFunction func, void* obj, ThreadPriority prio,
|
||||||
|
const char* thread_name);
|
||||||
~ThreadWindows() override;
|
~ThreadWindows() override;
|
||||||
|
|
||||||
bool Start() override;
|
bool Start() override;
|
||||||
bool Stop() override;
|
bool Stop() override;
|
||||||
|
|
||||||
bool SetPriority(ThreadPriority priority) override;
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void Run();
|
void Run();
|
||||||
|
|
||||||
@ -38,6 +37,8 @@ class ThreadWindows : public ThreadWrapper {
|
|||||||
ThreadRunFunction const run_function_;
|
ThreadRunFunction const run_function_;
|
||||||
void* const obj_;
|
void* const obj_;
|
||||||
bool stop_;
|
bool stop_;
|
||||||
|
// TODO(tommi): Consider having a SetPriority method instead of this variable.
|
||||||
|
ThreadPriority prio_;
|
||||||
HANDLE thread_;
|
HANDLE thread_;
|
||||||
const std::string name_;
|
const std::string name_;
|
||||||
rtc::ThreadChecker main_thread_;
|
rtc::ThreadChecker main_thread_;
|
||||||
|
@ -537,11 +537,7 @@ bool UdpSocket2WorkerWindows::Start()
|
|||||||
{
|
{
|
||||||
WEBRTC_TRACE(kTraceStateInfo, kTraceTransport, -1,
|
WEBRTC_TRACE(kTraceStateInfo, kTraceTransport, -1,
|
||||||
"Start UdpSocket2WorkerWindows");
|
"Start UdpSocket2WorkerWindows");
|
||||||
if (!_pThread->Start())
|
return _pThread->Start();
|
||||||
return false;
|
|
||||||
|
|
||||||
_pThread->SetPriority(kRealtimePriority);
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool UdpSocket2WorkerWindows::Stop()
|
bool UdpSocket2WorkerWindows::Stop()
|
||||||
@ -556,7 +552,8 @@ int32_t UdpSocket2WorkerWindows::Init()
|
|||||||
if(!_init)
|
if(!_init)
|
||||||
{
|
{
|
||||||
const char* threadName = "UdpSocket2ManagerWindows_thread";
|
const char* threadName = "UdpSocket2ManagerWindows_thread";
|
||||||
_pThread = ThreadWrapper::CreateThread(Run, this, threadName);
|
_pThread = ThreadWrapper::CreateThread(Run, this, kRealtimePriority,
|
||||||
|
threadName);
|
||||||
_init = true;
|
_init = true;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -189,6 +189,7 @@ UdpSocketManagerPosixImpl::UdpSocketManagerPosixImpl()
|
|||||||
{
|
{
|
||||||
_critSectList = CriticalSectionWrapper::CreateCriticalSection();
|
_critSectList = CriticalSectionWrapper::CreateCriticalSection();
|
||||||
_thread = ThreadWrapper::CreateThread(UdpSocketManagerPosixImpl::Run, this,
|
_thread = ThreadWrapper::CreateThread(UdpSocketManagerPosixImpl::Run, this,
|
||||||
|
kRealtimePriority,
|
||||||
"UdpSocketManagerPosixImplThread");
|
"UdpSocketManagerPosixImplThread");
|
||||||
FD_ZERO(&_readFds);
|
FD_ZERO(&_readFds);
|
||||||
WEBRTC_TRACE(kTraceMemory, kTraceTransport, -1,
|
WEBRTC_TRACE(kTraceMemory, kTraceTransport, -1,
|
||||||
@ -227,10 +228,7 @@ bool UdpSocketManagerPosixImpl::Start()
|
|||||||
|
|
||||||
WEBRTC_TRACE(kTraceStateInfo, kTraceTransport, -1,
|
WEBRTC_TRACE(kTraceStateInfo, kTraceTransport, -1,
|
||||||
"Start UdpSocketManagerPosix");
|
"Start UdpSocketManagerPosix");
|
||||||
if (!_thread->Start())
|
return _thread->Start();
|
||||||
return false;
|
|
||||||
_thread->SetPriority(kRealtimePriority);
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool UdpSocketManagerPosixImpl::Stop()
|
bool UdpSocketManagerPosixImpl::Stop()
|
||||||
|
@ -20,8 +20,7 @@ namespace test {
|
|||||||
DirectTransport::DirectTransport()
|
DirectTransport::DirectTransport()
|
||||||
: lock_(CriticalSectionWrapper::CreateCriticalSection()),
|
: lock_(CriticalSectionWrapper::CreateCriticalSection()),
|
||||||
packet_event_(EventWrapper::Create()),
|
packet_event_(EventWrapper::Create()),
|
||||||
thread_(ThreadWrapper::CreateThread(
|
thread_(ThreadWrapper::CreateThread(NetworkProcess, this)),
|
||||||
NetworkProcess, this, "NetworkProcess")),
|
|
||||||
clock_(Clock::GetRealTimeClock()),
|
clock_(Clock::GetRealTimeClock()),
|
||||||
shutting_down_(false),
|
shutting_down_(false),
|
||||||
fake_network_(FakeNetworkPipe::Config()) {
|
fake_network_(FakeNetworkPipe::Config()) {
|
||||||
@ -32,8 +31,7 @@ DirectTransport::DirectTransport(
|
|||||||
const FakeNetworkPipe::Config& config)
|
const FakeNetworkPipe::Config& config)
|
||||||
: lock_(CriticalSectionWrapper::CreateCriticalSection()),
|
: lock_(CriticalSectionWrapper::CreateCriticalSection()),
|
||||||
packet_event_(EventWrapper::Create()),
|
packet_event_(EventWrapper::Create()),
|
||||||
thread_(ThreadWrapper::CreateThread(
|
thread_(ThreadWrapper::CreateThread(NetworkProcess, this)),
|
||||||
NetworkProcess, this, "NetworkProcess")),
|
|
||||||
clock_(Clock::GetRealTimeClock()),
|
clock_(Clock::GetRealTimeClock()),
|
||||||
shutting_down_(false),
|
shutting_down_(false),
|
||||||
fake_network_(config) {
|
fake_network_(config) {
|
||||||
|
@ -55,15 +55,14 @@ int32_t FakeAudioDevice::Init() {
|
|||||||
|
|
||||||
if (!tick_->StartTimer(true, 10))
|
if (!tick_->StartTimer(true, 10))
|
||||||
return -1;
|
return -1;
|
||||||
thread_ = ThreadWrapper::CreateThread(FakeAudioDevice::Run, this,
|
thread_ = ThreadWrapper::CreateThread(
|
||||||
"FakeAudioDevice");
|
FakeAudioDevice::Run, this, webrtc::kHighPriority, "FakeAudioDevice");
|
||||||
if (thread_.get() == NULL)
|
if (thread_.get() == NULL)
|
||||||
return -1;
|
return -1;
|
||||||
if (!thread_->Start()) {
|
if (!thread_->Start()) {
|
||||||
thread_.reset();
|
thread_.reset();
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
thread_->SetPriority(webrtc::kHighPriority);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -90,7 +90,9 @@ bool FrameGeneratorCapturer::Init() {
|
|||||||
|
|
||||||
if (!tick_->StartTimer(true, 1000 / target_fps_))
|
if (!tick_->StartTimer(true, 1000 / target_fps_))
|
||||||
return false;
|
return false;
|
||||||
thread_ = ThreadWrapper::CreateThread(FrameGeneratorCapturer::Run, this,
|
thread_ = ThreadWrapper::CreateThread(FrameGeneratorCapturer::Run,
|
||||||
|
this,
|
||||||
|
webrtc::kHighPriority,
|
||||||
"FrameGeneratorCapturer");
|
"FrameGeneratorCapturer");
|
||||||
if (thread_.get() == NULL)
|
if (thread_.get() == NULL)
|
||||||
return false;
|
return false;
|
||||||
@ -98,7 +100,6 @@ bool FrameGeneratorCapturer::Init() {
|
|||||||
thread_.reset();
|
thread_.reset();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
thread_->SetPriority(webrtc::kHighPriority);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -108,7 +108,7 @@ class VideoAnalyzer : public PacketReceiver,
|
|||||||
|
|
||||||
for (uint32_t i = 0; i < num_cores; ++i) {
|
for (uint32_t i = 0; i < num_cores; ++i) {
|
||||||
rtc::scoped_ptr<ThreadWrapper> thread =
|
rtc::scoped_ptr<ThreadWrapper> thread =
|
||||||
ThreadWrapper::CreateThread(&FrameComparisonThread, this, "Analyzer");
|
ThreadWrapper::CreateThread(&FrameComparisonThread, this);
|
||||||
EXPECT_TRUE(thread->Start());
|
EXPECT_TRUE(thread->Start());
|
||||||
comparison_thread_pool_.push_back(thread.release());
|
comparison_thread_pool_.push_back(thread.release());
|
||||||
}
|
}
|
||||||
|
@ -47,7 +47,8 @@ ViEAutoTestWindowManager::ViEAutoTestWindowManager()
|
|||||||
_window2(NULL),
|
_window2(NULL),
|
||||||
_terminate(false),
|
_terminate(false),
|
||||||
_eventThread(webrtc::ThreadWrapper::CreateThread(
|
_eventThread(webrtc::ThreadWrapper::CreateThread(
|
||||||
EventProcess, this, "ViEAutotestEventThread")),
|
EventProcess, this, webrtc::kNormalPriority,
|
||||||
|
"ViEAutotestEventThread")),
|
||||||
_crit(*webrtc::CriticalSectionWrapper::CreateCriticalSection()),
|
_crit(*webrtc::CriticalSectionWrapper::CreateCriticalSection()),
|
||||||
_hwnd1(NULL),
|
_hwnd1(NULL),
|
||||||
_hwnd2(NULL),
|
_hwnd2(NULL),
|
||||||
|
@ -61,8 +61,7 @@ bool ViEFakeCamera::StartCameraInNewThread(
|
|||||||
// Set up a thread which runs the fake camera. The capturer object is
|
// Set up a thread which runs the fake camera. The capturer object is
|
||||||
// thread-safe.
|
// thread-safe.
|
||||||
camera_thread_ = webrtc::ThreadWrapper::CreateThread(
|
camera_thread_ = webrtc::ThreadWrapper::CreateThread(
|
||||||
StreamVideoFileRepeatedlyIntoCaptureDevice, file_capture_device_,
|
StreamVideoFileRepeatedlyIntoCaptureDevice, file_capture_device_);
|
||||||
"StreamVideoFileRepeatedlyIntoCaptureDevice");
|
|
||||||
camera_thread_->Start();
|
camera_thread_->Start();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -37,7 +37,8 @@ ViEToFileRenderer::ViEToFileRenderer()
|
|||||||
output_path_(),
|
output_path_(),
|
||||||
output_filename_(),
|
output_filename_(),
|
||||||
thread_(webrtc::ThreadWrapper::CreateThread(
|
thread_(webrtc::ThreadWrapper::CreateThread(
|
||||||
ViEToFileRenderer::RunRenderThread, this, "ViEToFileRendererThread")),
|
ViEToFileRenderer::RunRenderThread,
|
||||||
|
this, webrtc::kNormalPriority, "ViEToFileRendererThread")),
|
||||||
frame_queue_cs_(webrtc::CriticalSectionWrapper::CreateCriticalSection()),
|
frame_queue_cs_(webrtc::CriticalSectionWrapper::CreateCriticalSection()),
|
||||||
frame_render_event_(webrtc::EventWrapper::Create()),
|
frame_render_event_(webrtc::EventWrapper::Create()),
|
||||||
render_queue_(),
|
render_queue_(),
|
||||||
|
@ -41,7 +41,8 @@ TbExternalTransport::TbExternalTransport(
|
|||||||
receive_channels_(receive_channels),
|
receive_channels_(receive_channels),
|
||||||
_vieNetwork(vieNetwork),
|
_vieNetwork(vieNetwork),
|
||||||
_thread(webrtc::ThreadWrapper::CreateThread(
|
_thread(webrtc::ThreadWrapper::CreateThread(
|
||||||
ViEExternalTransportRun, this, "AutotestTransport")),
|
ViEExternalTransportRun, this, webrtc::kHighPriority,
|
||||||
|
"AutotestTransport")),
|
||||||
_event(*webrtc::EventWrapper::Create()),
|
_event(*webrtc::EventWrapper::Create()),
|
||||||
_crit(*webrtc::CriticalSectionWrapper::CreateCriticalSection()),
|
_crit(*webrtc::CriticalSectionWrapper::CreateCriticalSection()),
|
||||||
_statCrit(*webrtc::CriticalSectionWrapper::CreateCriticalSection()),
|
_statCrit(*webrtc::CriticalSectionWrapper::CreateCriticalSection()),
|
||||||
@ -76,7 +77,6 @@ TbExternalTransport::TbExternalTransport(
|
|||||||
srand((int) webrtc::TickTime::MicrosecondTimestamp());
|
srand((int) webrtc::TickTime::MicrosecondTimestamp());
|
||||||
memset(&network_parameters_, 0, sizeof(NetworkParameters));
|
memset(&network_parameters_, 0, sizeof(NetworkParameters));
|
||||||
_thread->Start();
|
_thread->Start();
|
||||||
_thread->SetPriority(webrtc::kHighPriority);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TbExternalTransport::~TbExternalTransport()
|
TbExternalTransport::~TbExternalTransport()
|
||||||
|
@ -68,8 +68,10 @@ ViECapturer::ViECapturer(int capture_id,
|
|||||||
module_process_thread_(module_process_thread),
|
module_process_thread_(module_process_thread),
|
||||||
capture_id_(capture_id),
|
capture_id_(capture_id),
|
||||||
incoming_frame_cs_(CriticalSectionWrapper::CreateCriticalSection()),
|
incoming_frame_cs_(CriticalSectionWrapper::CreateCriticalSection()),
|
||||||
capture_thread_(ThreadWrapper::CreateThread(
|
capture_thread_(ThreadWrapper::CreateThread(ViECaptureThreadFunction,
|
||||||
ViECaptureThreadFunction, this, "ViECaptureThread")),
|
this,
|
||||||
|
kHighPriority,
|
||||||
|
"ViECaptureThread")),
|
||||||
capture_event_(*EventWrapper::Create()),
|
capture_event_(*EventWrapper::Create()),
|
||||||
deliver_event_(*EventWrapper::Create()),
|
deliver_event_(*EventWrapper::Create()),
|
||||||
stop_(0),
|
stop_(0),
|
||||||
@ -91,7 +93,6 @@ ViECapturer::ViECapturer(int capture_id,
|
|||||||
new OveruseFrameDetector(Clock::GetRealTimeClock(),
|
new OveruseFrameDetector(Clock::GetRealTimeClock(),
|
||||||
cpu_overuse_metrics_observer_.get())) {
|
cpu_overuse_metrics_observer_.get())) {
|
||||||
capture_thread_->Start();
|
capture_thread_->Start();
|
||||||
capture_thread_->SetPriority(kHighPriority);
|
|
||||||
module_process_thread_.RegisterModule(overuse_detector_.get());
|
module_process_thread_.RegisterModule(overuse_detector_.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1839,9 +1839,9 @@ int32_t ViEChannel::StartDecodeThread() {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
decode_thread_ = ThreadWrapper::CreateThread(ChannelDecodeThreadFunction,
|
decode_thread_ = ThreadWrapper::CreateThread(ChannelDecodeThreadFunction,
|
||||||
this, "DecodingThread");
|
this, kHighestPriority,
|
||||||
|
"DecodingThread");
|
||||||
decode_thread_->Start();
|
decode_thread_->Start();
|
||||||
decode_thread_->SetPriority(kHighestPriority);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -188,7 +188,8 @@ ThreadTest::~ThreadTest()
|
|||||||
|
|
||||||
ThreadTest::ThreadTest()
|
ThreadTest::ThreadTest()
|
||||||
{
|
{
|
||||||
_thread = ThreadWrapper::CreateThread(Run, this, "ThreadTest thread");
|
_thread = ThreadWrapper::CreateThread(Run, this, kNormalPriority,
|
||||||
|
"ThreadTest thread");
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ThreadTest::Run(void* ptr)
|
bool ThreadTest::Run(void* ptr)
|
||||||
|
@ -27,10 +27,10 @@ FakeExternalTransport::FakeExternalTransport(webrtc::VoENetwork* ptr)
|
|||||||
const char* thread_name = "external_thread";
|
const char* thread_name = "external_thread";
|
||||||
lock_ = webrtc::CriticalSectionWrapper::CreateCriticalSection();
|
lock_ = webrtc::CriticalSectionWrapper::CreateCriticalSection();
|
||||||
event_ = webrtc::EventWrapper::Create();
|
event_ = webrtc::EventWrapper::Create();
|
||||||
thread_ = webrtc::ThreadWrapper::CreateThread(Run, this, thread_name);
|
thread_ = webrtc::ThreadWrapper::CreateThread(
|
||||||
|
Run, this, webrtc::kHighPriority, thread_name);
|
||||||
if (thread_) {
|
if (thread_) {
|
||||||
thread_->Start();
|
thread_->Start();
|
||||||
thread_->SetPriority(webrtc::kHighPriority);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -29,8 +29,7 @@ class LoopBackTransport : public webrtc::Transport {
|
|||||||
LoopBackTransport(webrtc::VoENetwork* voe_network)
|
LoopBackTransport(webrtc::VoENetwork* voe_network)
|
||||||
: crit_(webrtc::CriticalSectionWrapper::CreateCriticalSection()),
|
: crit_(webrtc::CriticalSectionWrapper::CreateCriticalSection()),
|
||||||
packet_event_(webrtc::EventWrapper::Create()),
|
packet_event_(webrtc::EventWrapper::Create()),
|
||||||
thread_(webrtc::ThreadWrapper::CreateThread(
|
thread_(webrtc::ThreadWrapper::CreateThread(NetworkProcess, this)),
|
||||||
NetworkProcess, this, "LoopBackTransport")),
|
|
||||||
voe_network_(voe_network), transmitted_packets_(0) {
|
voe_network_(voe_network), transmitted_packets_(0) {
|
||||||
thread_->Start();
|
thread_->Start();
|
||||||
}
|
}
|
||||||
|
@ -334,8 +334,9 @@ int VoEStressTest::MultipleThreadsTest() {
|
|||||||
int rnd(0);
|
int rnd(0);
|
||||||
|
|
||||||
// Start extra thread
|
// Start extra thread
|
||||||
|
const char* threadName = "StressTest Extra API Thread";
|
||||||
_ptrExtraApiThread = ThreadWrapper::CreateThread(RunExtraApi, this,
|
_ptrExtraApiThread = ThreadWrapper::CreateThread(RunExtraApi, this,
|
||||||
"StressTestExtraApiThread");
|
kNormalPriority, threadName);
|
||||||
VALIDATE_STRESS(!_ptrExtraApiThread->Start());
|
VALIDATE_STRESS(!_ptrExtraApiThread->Start());
|
||||||
|
|
||||||
// Some possible extensions include:
|
// Some possible extensions include:
|
||||||
|
Loading…
Reference in New Issue
Block a user