Remove thread id from ThreadWrapper::Start().
Removes ThreadPosix::InitParams and a corresponding wait for an event. This unblocks ThreadPosix::Start which had to wait for thread scheduling for an event to trigger on the spawned thread, giving faster Start() calls. BUG=4413 R=tommi@webrtc.org Review URL: https://webrtc-codereview.appspot.com/43699004 Cr-Commit-Position: refs/heads/master@{#8709} git-svn-id: http://webrtc.googlecode.com/svn/trunk@8709 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
@@ -314,10 +314,9 @@ class AudioCodingModuleMtTest : public AudioCodingModuleTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void StartThreads() {
|
void StartThreads() {
|
||||||
unsigned int thread_id = 0;
|
ASSERT_TRUE(send_thread_->Start());
|
||||||
ASSERT_TRUE(send_thread_->Start(thread_id));
|
ASSERT_TRUE(insert_packet_thread_->Start());
|
||||||
ASSERT_TRUE(insert_packet_thread_->Start(thread_id));
|
ASSERT_TRUE(pull_audio_thread_->Start());
|
||||||
ASSERT_TRUE(pull_audio_thread_->Start(thread_id));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void TearDown() override {
|
void TearDown() override {
|
||||||
|
@@ -446,10 +446,9 @@ class AudioCodingModuleMtTestOldApi : public AudioCodingModuleTestOldApi {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void StartThreads() {
|
void StartThreads() {
|
||||||
unsigned int thread_id = 0;
|
ASSERT_TRUE(send_thread_->Start());
|
||||||
ASSERT_TRUE(send_thread_->Start(thread_id));
|
ASSERT_TRUE(insert_packet_thread_->Start());
|
||||||
ASSERT_TRUE(insert_packet_thread_->Start(thread_id));
|
ASSERT_TRUE(pull_audio_thread_->Start());
|
||||||
ASSERT_TRUE(pull_audio_thread_->Start(thread_id));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void TearDown() {
|
void TearDown() {
|
||||||
|
@@ -38,8 +38,7 @@ namespace webrtc {
|
|||||||
#define MAX_FILE_NAME_LENGTH_BYTE 500
|
#define MAX_FILE_NAME_LENGTH_BYTE 500
|
||||||
#define CHECK_THREAD_NULLITY(myThread, S) \
|
#define CHECK_THREAD_NULLITY(myThread, S) \
|
||||||
if(myThread != NULL) { \
|
if(myThread != NULL) { \
|
||||||
unsigned int i; \
|
(myThread)->Start(); \
|
||||||
(myThread)->Start(i); \
|
|
||||||
} else { \
|
} else { \
|
||||||
ADD_FAILURE() << S; \
|
ADD_FAILURE() << S; \
|
||||||
}
|
}
|
||||||
|
@@ -45,8 +45,7 @@ class LowLatencyEventTest : public testing::Test {
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
void Start() {
|
void Start() {
|
||||||
unsigned int thread_id = 0;
|
EXPECT_TRUE(process_thread_->Start());
|
||||||
EXPECT_TRUE(process_thread_->Start(thread_id));
|
|
||||||
}
|
}
|
||||||
void Stop() {
|
void Stop() {
|
||||||
terminated_ = true;
|
terminated_ = true;
|
||||||
|
@@ -475,8 +475,7 @@ bool OpenSlesInput::StartCbThreads() {
|
|||||||
kRealtimePriority,
|
kRealtimePriority,
|
||||||
"opensl_rec_thread"));
|
"opensl_rec_thread"));
|
||||||
assert(rec_thread_.get());
|
assert(rec_thread_.get());
|
||||||
unsigned int thread_id = 0;
|
if (!rec_thread_->Start()) {
|
||||||
if (!rec_thread_->Start(thread_id)) {
|
|
||||||
assert(false);
|
assert(false);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@@ -520,8 +520,7 @@ bool OpenSlesOutput::StartCbThreads() {
|
|||||||
SL_PLAYSTATE_PLAYING),
|
SL_PLAYSTATE_PLAYING),
|
||||||
false);
|
false);
|
||||||
|
|
||||||
unsigned int thread_id = 0;
|
if (!play_thread_->Start()) {
|
||||||
if (!play_thread_->Start(thread_id)) {
|
|
||||||
assert(false);
|
assert(false);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@@ -37,8 +37,6 @@ FileAudioDevice::FileAudioDevice(const int32_t id,
|
|||||||
_playoutFramesIn10MS(0),
|
_playoutFramesIn10MS(0),
|
||||||
_ptrThreadRec(NULL),
|
_ptrThreadRec(NULL),
|
||||||
_ptrThreadPlay(NULL),
|
_ptrThreadPlay(NULL),
|
||||||
_recThreadID(0),
|
|
||||||
_playThreadID(0),
|
|
||||||
_playing(false),
|
_playing(false),
|
||||||
_recording(false),
|
_recording(false),
|
||||||
_lastCallPlayoutMillis(0),
|
_lastCallPlayoutMillis(0),
|
||||||
@@ -230,8 +228,7 @@ int32_t FileAudioDevice::StartPlayout() {
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int threadID(0);
|
if (!_ptrThreadPlay->Start()) {
|
||||||
if (!_ptrThreadPlay->Start(threadID)) {
|
|
||||||
_playing = false;
|
_playing = false;
|
||||||
delete _ptrThreadPlay;
|
delete _ptrThreadPlay;
|
||||||
_ptrThreadPlay = NULL;
|
_ptrThreadPlay = NULL;
|
||||||
@@ -239,7 +236,6 @@ int32_t FileAudioDevice::StartPlayout() {
|
|||||||
_playoutBuffer = NULL;
|
_playoutBuffer = NULL;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
_playThreadID = threadID;
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -307,8 +303,7 @@ int32_t FileAudioDevice::StartRecording() {
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int threadID(0);
|
if (!_ptrThreadRec->Start()) {
|
||||||
if (!_ptrThreadRec->Start(threadID)) {
|
|
||||||
_recording = false;
|
_recording = false;
|
||||||
delete _ptrThreadRec;
|
delete _ptrThreadRec;
|
||||||
_ptrThreadRec = NULL;
|
_ptrThreadRec = NULL;
|
||||||
@@ -316,7 +311,6 @@ int32_t FileAudioDevice::StartRecording() {
|
|||||||
_recordingBuffer = NULL;
|
_recordingBuffer = NULL;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
_recThreadID = threadID;
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@@ -180,8 +180,6 @@ class FileAudioDevice : public AudioDeviceGeneric {
|
|||||||
|
|
||||||
ThreadWrapper* _ptrThreadRec;
|
ThreadWrapper* _ptrThreadRec;
|
||||||
ThreadWrapper* _ptrThreadPlay;
|
ThreadWrapper* _ptrThreadPlay;
|
||||||
uint32_t _recThreadID;
|
|
||||||
uint32_t _playThreadID;
|
|
||||||
|
|
||||||
bool _playing;
|
bool _playing;
|
||||||
bool _recording;
|
bool _recording;
|
||||||
|
@@ -215,7 +215,6 @@ class AudioDeviceIOS : public AudioDeviceGeneric {
|
|||||||
CriticalSectionWrapper& _critSect;
|
CriticalSectionWrapper& _critSect;
|
||||||
|
|
||||||
ThreadWrapper* _captureWorkerThread;
|
ThreadWrapper* _captureWorkerThread;
|
||||||
uint32_t _captureWorkerThreadId;
|
|
||||||
|
|
||||||
int32_t _id;
|
int32_t _id;
|
||||||
|
|
||||||
|
@@ -22,7 +22,6 @@ AudioDeviceIOS::AudioDeviceIOS(const int32_t id)
|
|||||||
_ptrAudioBuffer(NULL),
|
_ptrAudioBuffer(NULL),
|
||||||
_critSect(*CriticalSectionWrapper::CreateCriticalSection()),
|
_critSect(*CriticalSectionWrapper::CreateCriticalSection()),
|
||||||
_captureWorkerThread(NULL),
|
_captureWorkerThread(NULL),
|
||||||
_captureWorkerThreadId(0),
|
|
||||||
_id(id),
|
_id(id),
|
||||||
_auVoiceProcessing(NULL),
|
_auVoiceProcessing(NULL),
|
||||||
_audioInterruptionObserver(NULL),
|
_audioInterruptionObserver(NULL),
|
||||||
@@ -120,9 +119,7 @@ int32_t AudioDeviceIOS::Init() {
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int threadID(0);
|
bool res = _captureWorkerThread->Start();
|
||||||
bool res = _captureWorkerThread->Start(threadID);
|
|
||||||
_captureWorkerThreadId = static_cast<uint32_t>(threadID);
|
|
||||||
WEBRTC_TRACE(kTraceDebug, kTraceAudioDevice,
|
WEBRTC_TRACE(kTraceDebug, kTraceAudioDevice,
|
||||||
_id, "CaptureWorkerThread started (res=%d)", res);
|
_id, "CaptureWorkerThread started (res=%d)", res);
|
||||||
} else {
|
} else {
|
||||||
|
@@ -66,8 +66,6 @@ AudioDeviceLinuxALSA::AudioDeviceLinuxALSA(const int32_t id) :
|
|||||||
_critSect(*CriticalSectionWrapper::CreateCriticalSection()),
|
_critSect(*CriticalSectionWrapper::CreateCriticalSection()),
|
||||||
_ptrThreadRec(NULL),
|
_ptrThreadRec(NULL),
|
||||||
_ptrThreadPlay(NULL),
|
_ptrThreadPlay(NULL),
|
||||||
_recThreadID(0),
|
|
||||||
_playThreadID(0),
|
|
||||||
_id(id),
|
_id(id),
|
||||||
_mixerManager(id),
|
_mixerManager(id),
|
||||||
_inputDeviceIndex(0),
|
_inputDeviceIndex(0),
|
||||||
@@ -1401,8 +1399,7 @@ int32_t AudioDeviceLinuxALSA::StartRecording()
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int threadID(0);
|
if (!_ptrThreadRec->Start())
|
||||||
if (!_ptrThreadRec->Start(threadID))
|
|
||||||
{
|
{
|
||||||
WEBRTC_TRACE(kTraceCritical, kTraceAudioDevice, _id,
|
WEBRTC_TRACE(kTraceCritical, kTraceAudioDevice, _id,
|
||||||
" failed to start the rec audio thread");
|
" failed to start the rec audio thread");
|
||||||
@@ -1413,7 +1410,6 @@ int32_t AudioDeviceLinuxALSA::StartRecording()
|
|||||||
_recordingBuffer = NULL;
|
_recordingBuffer = NULL;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
_recThreadID = threadID;
|
|
||||||
|
|
||||||
errVal = LATE(snd_pcm_prepare)(_handleRecord);
|
errVal = LATE(snd_pcm_prepare)(_handleRecord);
|
||||||
if (errVal < 0)
|
if (errVal < 0)
|
||||||
@@ -1573,8 +1569,7 @@ int32_t AudioDeviceLinuxALSA::StartPlayout()
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int threadID(0);
|
if (!_ptrThreadPlay->Start())
|
||||||
if (!_ptrThreadPlay->Start(threadID))
|
|
||||||
{
|
{
|
||||||
WEBRTC_TRACE(kTraceCritical, kTraceAudioDevice, _id,
|
WEBRTC_TRACE(kTraceCritical, kTraceAudioDevice, _id,
|
||||||
" failed to start the play audio thread");
|
" failed to start the play audio thread");
|
||||||
@@ -1585,7 +1580,6 @@ int32_t AudioDeviceLinuxALSA::StartPlayout()
|
|||||||
_playoutBuffer = NULL;
|
_playoutBuffer = NULL;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
_playThreadID = threadID;
|
|
||||||
|
|
||||||
int errVal = LATE(snd_pcm_prepare)(_handlePlayout);
|
int errVal = LATE(snd_pcm_prepare)(_handlePlayout);
|
||||||
if (errVal < 0)
|
if (errVal < 0)
|
||||||
|
@@ -187,8 +187,6 @@ private:
|
|||||||
|
|
||||||
ThreadWrapper* _ptrThreadRec;
|
ThreadWrapper* _ptrThreadRec;
|
||||||
ThreadWrapper* _ptrThreadPlay;
|
ThreadWrapper* _ptrThreadPlay;
|
||||||
uint32_t _recThreadID;
|
|
||||||
uint32_t _playThreadID;
|
|
||||||
|
|
||||||
int32_t _id;
|
int32_t _id;
|
||||||
|
|
||||||
|
@@ -42,8 +42,6 @@ AudioDeviceLinuxPulse::AudioDeviceLinuxPulse(const int32_t id) :
|
|||||||
_playStartEvent(*EventWrapper::Create()),
|
_playStartEvent(*EventWrapper::Create()),
|
||||||
_ptrThreadPlay(NULL),
|
_ptrThreadPlay(NULL),
|
||||||
_ptrThreadRec(NULL),
|
_ptrThreadRec(NULL),
|
||||||
_recThreadID(0),
|
|
||||||
_playThreadID(0),
|
|
||||||
_id(id),
|
_id(id),
|
||||||
_mixerManager(id),
|
_mixerManager(id),
|
||||||
_inputDeviceIndex(0),
|
_inputDeviceIndex(0),
|
||||||
@@ -221,8 +219,7 @@ int32_t AudioDeviceLinuxPulse::Init()
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int threadID(0);
|
if (!_ptrThreadRec->Start())
|
||||||
if (!_ptrThreadRec->Start(threadID))
|
|
||||||
{
|
{
|
||||||
WEBRTC_TRACE(kTraceCritical, kTraceAudioDevice, _id,
|
WEBRTC_TRACE(kTraceCritical, kTraceAudioDevice, _id,
|
||||||
" failed to start the rec audio thread");
|
" failed to start the rec audio thread");
|
||||||
@@ -231,7 +228,6 @@ int32_t AudioDeviceLinuxPulse::Init()
|
|||||||
_ptrThreadRec = NULL;
|
_ptrThreadRec = NULL;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
_recThreadID = threadID;
|
|
||||||
|
|
||||||
// PLAYOUT
|
// PLAYOUT
|
||||||
threadName = "webrtc_audio_module_play_thread";
|
threadName = "webrtc_audio_module_play_thread";
|
||||||
@@ -244,8 +240,7 @@ int32_t AudioDeviceLinuxPulse::Init()
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
threadID = 0;
|
if (!_ptrThreadPlay->Start())
|
||||||
if (!_ptrThreadPlay->Start(threadID))
|
|
||||||
{
|
{
|
||||||
WEBRTC_TRACE(kTraceCritical, kTraceAudioDevice, _id,
|
WEBRTC_TRACE(kTraceCritical, kTraceAudioDevice, _id,
|
||||||
" failed to start the play audio thread");
|
" failed to start the play audio thread");
|
||||||
@@ -254,7 +249,6 @@ int32_t AudioDeviceLinuxPulse::Init()
|
|||||||
_ptrThreadPlay = NULL;
|
_ptrThreadPlay = NULL;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
_playThreadID = threadID;
|
|
||||||
|
|
||||||
_initialized = true;
|
_initialized = true;
|
||||||
|
|
||||||
|
@@ -290,8 +290,6 @@ private:
|
|||||||
|
|
||||||
ThreadWrapper* _ptrThreadPlay;
|
ThreadWrapper* _ptrThreadPlay;
|
||||||
ThreadWrapper* _ptrThreadRec;
|
ThreadWrapper* _ptrThreadRec;
|
||||||
uint32_t _recThreadID;
|
|
||||||
uint32_t _playThreadID;
|
|
||||||
int32_t _id;
|
int32_t _id;
|
||||||
|
|
||||||
AudioMixerManagerLinuxPulse _mixerManager;
|
AudioMixerManagerLinuxPulse _mixerManager;
|
||||||
|
@@ -109,8 +109,6 @@ AudioDeviceMac::AudioDeviceMac(const int32_t id) :
|
|||||||
_critSect(*CriticalSectionWrapper::CreateCriticalSection()),
|
_critSect(*CriticalSectionWrapper::CreateCriticalSection()),
|
||||||
_stopEventRec(*EventWrapper::Create()),
|
_stopEventRec(*EventWrapper::Create()),
|
||||||
_stopEvent(*EventWrapper::Create()),
|
_stopEvent(*EventWrapper::Create()),
|
||||||
capture_worker_thread_id_(0),
|
|
||||||
render_worker_thread_id_(0),
|
|
||||||
_id(id),
|
_id(id),
|
||||||
_mixerManager(id),
|
_mixerManager(id),
|
||||||
_inputDeviceIndex(0),
|
_inputDeviceIndex(0),
|
||||||
@@ -1760,7 +1758,7 @@ int32_t AudioDeviceMac::StartRecording()
|
|||||||
ThreadWrapper::CreateThread(RunCapture, this, kRealtimePriority,
|
ThreadWrapper::CreateThread(RunCapture, this, kRealtimePriority,
|
||||||
"CaptureWorkerThread"));
|
"CaptureWorkerThread"));
|
||||||
DCHECK(capture_worker_thread_.get());
|
DCHECK(capture_worker_thread_.get());
|
||||||
capture_worker_thread_->Start(capture_worker_thread_id_);
|
capture_worker_thread_->Start();
|
||||||
|
|
||||||
OSStatus err = noErr;
|
OSStatus err = noErr;
|
||||||
if (_twoDevices)
|
if (_twoDevices)
|
||||||
@@ -1914,7 +1912,7 @@ int32_t AudioDeviceMac::StartPlayout()
|
|||||||
render_worker_thread_.reset(
|
render_worker_thread_.reset(
|
||||||
ThreadWrapper::CreateThread(RunRender, this, kRealtimePriority,
|
ThreadWrapper::CreateThread(RunRender, this, kRealtimePriority,
|
||||||
"RenderWorkerThread"));
|
"RenderWorkerThread"));
|
||||||
render_worker_thread_->Start(render_worker_thread_id_);
|
render_worker_thread_->Start();
|
||||||
|
|
||||||
if (_twoDevices || !_recording)
|
if (_twoDevices || !_recording)
|
||||||
{
|
{
|
||||||
|
@@ -280,11 +280,9 @@ private:
|
|||||||
|
|
||||||
// Only valid/running between calls to StartRecording and StopRecording.
|
// Only valid/running between calls to StartRecording and StopRecording.
|
||||||
rtc::scoped_ptr<ThreadWrapper> capture_worker_thread_;
|
rtc::scoped_ptr<ThreadWrapper> capture_worker_thread_;
|
||||||
unsigned int capture_worker_thread_id_;
|
|
||||||
|
|
||||||
// Only valid/running between calls to StartPlayout and StopPlayout.
|
// Only valid/running between calls to StartPlayout and StopPlayout.
|
||||||
rtc::scoped_ptr<ThreadWrapper> render_worker_thread_;
|
rtc::scoped_ptr<ThreadWrapper> render_worker_thread_;
|
||||||
unsigned int render_worker_thread_id_;
|
|
||||||
|
|
||||||
int32_t _id;
|
int32_t _id;
|
||||||
|
|
||||||
|
@@ -57,7 +57,6 @@ AudioDeviceWindowsWave::AudioDeviceWindowsWave(const int32_t id) :
|
|||||||
_hShutdownSetVolumeEvent(NULL),
|
_hShutdownSetVolumeEvent(NULL),
|
||||||
_hSetCaptureVolumeEvent(NULL),
|
_hSetCaptureVolumeEvent(NULL),
|
||||||
_ptrThread(NULL),
|
_ptrThread(NULL),
|
||||||
_threadID(0),
|
|
||||||
_critSectCb(*CriticalSectionWrapper::CreateCriticalSection()),
|
_critSectCb(*CriticalSectionWrapper::CreateCriticalSection()),
|
||||||
_id(id),
|
_id(id),
|
||||||
_mixerManager(id),
|
_mixerManager(id),
|
||||||
@@ -242,8 +241,7 @@ int32_t AudioDeviceWindowsWave::Init()
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int threadID(0);
|
if (!_ptrThread->Start())
|
||||||
if (!_ptrThread->Start(threadID))
|
|
||||||
{
|
{
|
||||||
WEBRTC_TRACE(kTraceCritical, kTraceAudioDevice, _id,
|
WEBRTC_TRACE(kTraceCritical, kTraceAudioDevice, _id,
|
||||||
"failed to start the audio thread");
|
"failed to start the audio thread");
|
||||||
@@ -251,7 +249,6 @@ int32_t AudioDeviceWindowsWave::Init()
|
|||||||
_ptrThread = NULL;
|
_ptrThread = NULL;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
_threadID = threadID;
|
|
||||||
|
|
||||||
const bool periodic(true);
|
const bool periodic(true);
|
||||||
if (!_timeEvent.StartTimer(periodic, TIMER_PERIOD_MS))
|
if (!_timeEvent.StartTimer(periodic, TIMER_PERIOD_MS))
|
||||||
|
@@ -222,7 +222,6 @@ private:
|
|||||||
HANDLE _hSetCaptureVolumeEvent;
|
HANDLE _hSetCaptureVolumeEvent;
|
||||||
|
|
||||||
ThreadWrapper* _ptrThread;
|
ThreadWrapper* _ptrThread;
|
||||||
uint32_t _threadID;
|
|
||||||
|
|
||||||
CriticalSectionWrapper& _critSectCb;
|
CriticalSectionWrapper& _critSectCb;
|
||||||
|
|
||||||
|
@@ -907,9 +907,7 @@ _numPlots(0)
|
|||||||
|
|
||||||
_running = true;
|
_running = true;
|
||||||
|
|
||||||
unsigned int tid;
|
_plotThread->Start();
|
||||||
_plotThread->Start(tid);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
MatlabEngine::~MatlabEngine()
|
MatlabEngine::~MatlabEngine()
|
||||||
|
@@ -87,8 +87,7 @@ int32_t TestLoadGenerator::Start (const char *threadName)
|
|||||||
|
|
||||||
_running = true;
|
_running = true;
|
||||||
|
|
||||||
unsigned int tid;
|
_genThread->Start();
|
||||||
_genThread->Start(tid);
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@@ -183,8 +183,7 @@ int32_t TestSenderReceiver::Start()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int tid;
|
_procThread->Start();
|
||||||
_procThread->Start(tid);
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
@@ -71,8 +71,7 @@ void ProcessThreadImpl::Start() {
|
|||||||
|
|
||||||
thread_.reset(ThreadWrapper::CreateThread(
|
thread_.reset(ThreadWrapper::CreateThread(
|
||||||
&ProcessThreadImpl::Run, this, kNormalPriority, "ProcessThread"));
|
&ProcessThreadImpl::Run, this, kNormalPriority, "ProcessThread"));
|
||||||
unsigned int id;
|
CHECK(thread_->Start());
|
||||||
CHECK(thread_->Start(id));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProcessThreadImpl::Stop() {
|
void ProcessThreadImpl::Stop() {
|
||||||
|
@@ -284,8 +284,7 @@ int32_t VideoCaptureModuleV4L2::StartCapture(
|
|||||||
{
|
{
|
||||||
_captureThread = ThreadWrapper::CreateThread(
|
_captureThread = ThreadWrapper::CreateThread(
|
||||||
VideoCaptureModuleV4L2::CaptureThread, this, kHighPriority);
|
VideoCaptureModuleV4L2::CaptureThread, this, kHighPriority);
|
||||||
unsigned int id;
|
_captureThread->Start();
|
||||||
_captureThread->Start(id);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Needed to start UVC camera - from the uvcview application
|
// Needed to start UVC camera - from the uvcview application
|
||||||
|
@@ -275,8 +275,7 @@ int MTRxTxTest(CmdArgs& args)
|
|||||||
|
|
||||||
if (mainSenderThread != NULL)
|
if (mainSenderThread != NULL)
|
||||||
{
|
{
|
||||||
unsigned int tid;
|
mainSenderThread->Start();
|
||||||
mainSenderThread->Start(tid);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -286,8 +285,7 @@ int MTRxTxTest(CmdArgs& args)
|
|||||||
|
|
||||||
if (intSenderThread != NULL)
|
if (intSenderThread != NULL)
|
||||||
{
|
{
|
||||||
unsigned int tid;
|
intSenderThread->Start();
|
||||||
intSenderThread->Start(tid);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -303,8 +301,7 @@ int MTRxTxTest(CmdArgs& args)
|
|||||||
|
|
||||||
if (processingThread != NULL)
|
if (processingThread != NULL)
|
||||||
{
|
{
|
||||||
unsigned int tid;
|
processingThread->Start();
|
||||||
processingThread->Start(tid);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -314,8 +311,7 @@ int MTRxTxTest(CmdArgs& args)
|
|||||||
|
|
||||||
if (decodeThread != NULL)
|
if (decodeThread != NULL)
|
||||||
{
|
{
|
||||||
unsigned int tid;
|
decodeThread->Start();
|
||||||
decodeThread->Start(tid);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@@ -123,10 +123,9 @@ int RtpPlayMT(const CmdArgs& args) {
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int dummy_thread_id;
|
player_thread->Start();
|
||||||
player_thread->Start(dummy_thread_id);
|
processing_thread->Start();
|
||||||
processing_thread->Start(dummy_thread_id);
|
decode_thread->Start();
|
||||||
decode_thread->Start(dummy_thread_id);
|
|
||||||
|
|
||||||
wait_event->Wait(kConfigMaxRuntimeMs);
|
wait_event->Wait(kConfigMaxRuntimeMs);
|
||||||
|
|
||||||
|
@@ -152,10 +152,9 @@ int32_t VideoRenderAndroid::StartRender() {
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int tId = 0;
|
if (_javaRenderThread->Start())
|
||||||
if (_javaRenderThread->Start(tId))
|
|
||||||
WEBRTC_TRACE(kTraceInfo, kTraceVideoRenderer, _id,
|
WEBRTC_TRACE(kTraceInfo, kTraceVideoRenderer, _id,
|
||||||
"%s: thread started: %u", __FUNCTION__, tId);
|
"%s: thread started", __FUNCTION__);
|
||||||
else {
|
else {
|
||||||
WEBRTC_TRACE(kTraceError, kTraceVideoRenderer, _id,
|
WEBRTC_TRACE(kTraceError, kTraceVideoRenderer, _id,
|
||||||
"%s: Could not start send thread", __FUNCTION__);
|
"%s: Could not start send thread", __FUNCTION__);
|
||||||
|
@@ -187,10 +187,9 @@ int32_t IncomingVideoStream::Start() {
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int t_id = 0;
|
if (incoming_render_thread_->Start()) {
|
||||||
if (incoming_render_thread_->Start(t_id)) {
|
|
||||||
WEBRTC_TRACE(kTraceInfo, kTraceVideoRenderer, module_id_,
|
WEBRTC_TRACE(kTraceInfo, kTraceVideoRenderer, module_id_,
|
||||||
"%s: thread started: %u", __FUNCTION__, t_id);
|
"%s: thread started", __FUNCTION__);
|
||||||
} else {
|
} else {
|
||||||
WEBRTC_TRACE(kTraceError, kTraceVideoRenderer, module_id_,
|
WEBRTC_TRACE(kTraceError, kTraceVideoRenderer, module_id_,
|
||||||
"%s: Could not start send thread", __FUNCTION__);
|
"%s: Could not start send thread", __FUNCTION__);
|
||||||
|
@@ -90,8 +90,7 @@ int VideoRenderIosGles20::Init() {
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int thread_id;
|
screen_update_thread_->Start();
|
||||||
screen_update_thread_->Start(thread_id);
|
|
||||||
|
|
||||||
// Start the event triggering the render process
|
// Start the event triggering the render process
|
||||||
unsigned int monitor_freq = 60;
|
unsigned int monitor_freq = 60;
|
||||||
|
@@ -393,7 +393,6 @@ _windowEventHandlerRef( NULL),
|
|||||||
_currentViewBounds( ),
|
_currentViewBounds( ),
|
||||||
_lastViewBounds( ),
|
_lastViewBounds( ),
|
||||||
_renderingIsPaused( false),
|
_renderingIsPaused( false),
|
||||||
_threadID( )
|
|
||||||
|
|
||||||
{
|
{
|
||||||
//WEBRTC_TRACE(kTraceInfo, kTraceVideoRenderer, _id, "%s");
|
//WEBRTC_TRACE(kTraceInfo, kTraceVideoRenderer, _id, "%s");
|
||||||
@@ -511,7 +510,6 @@ _windowEventHandlerRef( NULL),
|
|||||||
_currentViewBounds( ),
|
_currentViewBounds( ),
|
||||||
_lastViewBounds( ),
|
_lastViewBounds( ),
|
||||||
_renderingIsPaused( false),
|
_renderingIsPaused( false),
|
||||||
_threadID( )
|
|
||||||
{
|
{
|
||||||
//WEBRTC_TRACE(kTraceDebug, "%s:%d Constructor", __FUNCTION__, __LINE__);
|
//WEBRTC_TRACE(kTraceDebug, "%s:%d Constructor", __FUNCTION__, __LINE__);
|
||||||
// _renderCritSec = CriticalSectionWrapper::CreateCriticalSection();
|
// _renderCritSec = CriticalSectionWrapper::CreateCriticalSection();
|
||||||
@@ -744,8 +742,7 @@ int VideoRenderAGL::Init()
|
|||||||
//WEBRTC_TRACE(kTraceError, "%s:%d Thread not created", __FUNCTION__, __LINE__);
|
//WEBRTC_TRACE(kTraceError, "%s:%d Thread not created", __FUNCTION__, __LINE__);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
unsigned int threadId;
|
_screenUpdateThread->Start();
|
||||||
_screenUpdateThread->Start(threadId);
|
|
||||||
|
|
||||||
// Start the event triggering the render process
|
// Start the event triggering the render process
|
||||||
unsigned int monitorFreq = 60;
|
unsigned int monitorFreq = 60;
|
||||||
@@ -1881,7 +1878,7 @@ int32_t VideoRenderAGL::StartRender()
|
|||||||
//WEBRTC_TRACE(kTraceInfo, kTraceVideoRenderer, _id, "%s:%d Rendering is paused. Restarting now", __FUNCTION__, __LINE__);
|
//WEBRTC_TRACE(kTraceInfo, kTraceVideoRenderer, _id, "%s:%d Rendering is paused. Restarting now", __FUNCTION__, __LINE__);
|
||||||
|
|
||||||
// we already have the thread. Most likely StopRender() was called and they were paused
|
// we already have the thread. Most likely StopRender() was called and they were paused
|
||||||
if(FALSE == _screenUpdateThread->Start(_threadID))
|
if(FALSE == _screenUpdateThread->Start())
|
||||||
{
|
{
|
||||||
//WEBRTC_TRACE(kTraceError, kTraceVideoRenderer, _id, "%s:%d Failed to start screenUpdateThread", __FUNCTION__, __LINE__);
|
//WEBRTC_TRACE(kTraceError, kTraceVideoRenderer, _id, "%s:%d Failed to start screenUpdateThread", __FUNCTION__, __LINE__);
|
||||||
UnlockAGLCntx();
|
UnlockAGLCntx();
|
||||||
@@ -1907,7 +1904,7 @@ int32_t VideoRenderAGL::StartRender()
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
_screenUpdateThread->Start(_threadID);
|
_screenUpdateThread->Start();
|
||||||
_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__);
|
||||||
|
@@ -168,8 +168,6 @@ class VideoRenderAGL {
|
|||||||
HIRect _currentViewBounds;
|
HIRect _currentViewBounds;
|
||||||
HIRect _lastViewBounds;
|
HIRect _lastViewBounds;
|
||||||
bool _renderingIsPaused;
|
bool _renderingIsPaused;
|
||||||
unsigned int _threadID;
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace webrtc
|
} // namespace webrtc
|
||||||
|
@@ -179,7 +179,6 @@ private: // variables
|
|||||||
int _windowHeight;
|
int _windowHeight;
|
||||||
std::map<int, VideoChannelNSOpenGL*> _nsglChannels;
|
std::map<int, VideoChannelNSOpenGL*> _nsglChannels;
|
||||||
std::multimap<int, int> _zOrderToChannel;
|
std::multimap<int, int> _zOrderToChannel;
|
||||||
unsigned int _threadID;
|
|
||||||
bool _renderingIsPaused;
|
bool _renderingIsPaused;
|
||||||
NSView* _windowRefSuperView;
|
NSView* _windowRefSuperView;
|
||||||
NSRect _windowRefSuperViewFrame;
|
NSRect _windowRefSuperViewFrame;
|
||||||
|
@@ -377,7 +377,6 @@ _windowWidth( 0),
|
|||||||
_windowHeight( 0),
|
_windowHeight( 0),
|
||||||
_nsglChannels( ),
|
_nsglChannels( ),
|
||||||
_zOrderToChannel( ),
|
_zOrderToChannel( ),
|
||||||
_threadID (0),
|
|
||||||
_renderingIsPaused (FALSE),
|
_renderingIsPaused (FALSE),
|
||||||
_windowRefSuperView(NULL),
|
_windowRefSuperView(NULL),
|
||||||
_windowRefSuperViewFrame(NSMakeRect(0,0,0,0))
|
_windowRefSuperViewFrame(NSMakeRect(0,0,0,0))
|
||||||
@@ -431,7 +430,7 @@ int32_t VideoRenderNSOpenGL::StartRender()
|
|||||||
WEBRTC_TRACE(kTraceDebug, kTraceVideoRenderer, _id, "Restarting screenUpdateThread");
|
WEBRTC_TRACE(kTraceDebug, kTraceVideoRenderer, _id, "Restarting screenUpdateThread");
|
||||||
|
|
||||||
// we already have the thread. Most likely StopRender() was called and they were paused
|
// we already have the thread. Most likely StopRender() was called and they were paused
|
||||||
if(FALSE == _screenUpdateThread->Start(_threadID) ||
|
if(FALSE == _screenUpdateThread->Start() ||
|
||||||
FALSE == _screenUpdateEvent->StartTimer(true, 1000/MONITOR_FREQ))
|
FALSE == _screenUpdateEvent->StartTimer(true, 1000/MONITOR_FREQ))
|
||||||
{
|
{
|
||||||
WEBRTC_TRACE(kTraceError, kTraceVideoRenderer, _id, "Failed to restart screenUpdateThread or screenUpdateEvent");
|
WEBRTC_TRACE(kTraceError, kTraceVideoRenderer, _id, "Failed to restart screenUpdateThread or screenUpdateEvent");
|
||||||
@@ -718,7 +717,7 @@ int VideoRenderNSOpenGL::Init()
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
_screenUpdateThread->Start(_threadID);
|
_screenUpdateThread->Start();
|
||||||
|
|
||||||
// Start the event triggering the render process
|
// Start the event triggering the render process
|
||||||
unsigned int monitorFreq = 60;
|
unsigned int monitorFreq = 60;
|
||||||
|
@@ -551,8 +551,7 @@ int32_t VideoRenderDirect3D9::Init()
|
|||||||
WEBRTC_TRACE(kTraceError, kTraceVideo, -1, "Thread not created");
|
WEBRTC_TRACE(kTraceError, kTraceVideo, -1, "Thread not created");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
unsigned int threadId;
|
_screenUpdateThread->Start();
|
||||||
_screenUpdateThread->Start(threadId);
|
|
||||||
|
|
||||||
// Start the event triggering the render process
|
// Start the event triggering the render process
|
||||||
unsigned int monitorFreq = 60;
|
unsigned int monitorFreq = 60;
|
||||||
|
@@ -73,8 +73,7 @@ class ThreadWrapper {
|
|||||||
// Additionally, it tries to set thread priority according to the priority
|
// Additionally, it tries to set thread priority according to the priority
|
||||||
// from when CreateThread was called. However, failure to set priority will
|
// from when CreateThread was called. However, failure to set priority will
|
||||||
// not result in a false return value.
|
// not result in a false return value.
|
||||||
// TODO(tommi): Remove the id parameter.
|
virtual bool Start() = 0;
|
||||||
virtual bool Start(unsigned int& id) = 0;
|
|
||||||
|
|
||||||
// Stops the spawned thread and waits for it to be reclaimed with a timeout
|
// Stops the spawned thread and waits for it to be reclaimed with a timeout
|
||||||
// of two seconds. Will return false if the thread was not reclaimed.
|
// of two seconds. Will return false if the thread was not reclaimed.
|
||||||
|
@@ -146,8 +146,7 @@ class CondVarTest : public ::testing::Test {
|
|||||||
virtual void SetUp() {
|
virtual void SetUp() {
|
||||||
thread_ = ThreadWrapper::CreateThread(&WaitingRunFunction,
|
thread_ = ThreadWrapper::CreateThread(&WaitingRunFunction,
|
||||||
&baton_);
|
&baton_);
|
||||||
unsigned int id = 42;
|
ASSERT_TRUE(thread_->Start());
|
||||||
ASSERT_TRUE(thread_->Start(id));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void TearDown() {
|
virtual void TearDown() {
|
||||||
|
@@ -80,9 +80,8 @@ TEST_F(CritSectTest, ThreadWakesOnce) NO_THREAD_SAFETY_ANALYSIS {
|
|||||||
ProtectedCount count(crit_sect);
|
ProtectedCount count(crit_sect);
|
||||||
ThreadWrapper* thread = ThreadWrapper::CreateThread(
|
ThreadWrapper* thread = ThreadWrapper::CreateThread(
|
||||||
&LockUnlockThenStopRunFunction, &count);
|
&LockUnlockThenStopRunFunction, &count);
|
||||||
unsigned int id = 42;
|
|
||||||
crit_sect->Enter();
|
crit_sect->Enter();
|
||||||
ASSERT_TRUE(thread->Start(id));
|
ASSERT_TRUE(thread->Start());
|
||||||
SwitchProcess();
|
SwitchProcess();
|
||||||
// The critical section is of reentrant mode, so this should not release
|
// The critical section is of reentrant mode, so this should not release
|
||||||
// the lock, even though count.Count() locks and unlocks the critical section
|
// the lock, even though count.Count() locks and unlocks the critical section
|
||||||
@@ -109,9 +108,8 @@ TEST_F(CritSectTest, ThreadWakesTwice) NO_THREAD_SAFETY_ANALYSIS {
|
|||||||
ProtectedCount count(crit_sect);
|
ProtectedCount count(crit_sect);
|
||||||
ThreadWrapper* thread = ThreadWrapper::CreateThread(&LockUnlockRunFunction,
|
ThreadWrapper* thread = ThreadWrapper::CreateThread(&LockUnlockRunFunction,
|
||||||
&count);
|
&count);
|
||||||
unsigned int id = 42;
|
|
||||||
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(id));
|
ASSERT_TRUE(thread->Start());
|
||||||
crit_sect->Leave();
|
crit_sect->Leave();
|
||||||
|
|
||||||
// The thread is capable of grabbing the lock multiple times,
|
// The thread is capable of grabbing the lock multiple times,
|
||||||
|
@@ -358,8 +358,7 @@ int DataLogImpl::Init() {
|
|||||||
"DataLog");
|
"DataLog");
|
||||||
if (file_writer_thread_ == NULL)
|
if (file_writer_thread_ == NULL)
|
||||||
return -1;
|
return -1;
|
||||||
unsigned int thread_id = 0;
|
bool success = file_writer_thread_->Start();
|
||||||
bool success = file_writer_thread_->Start(thread_id);
|
|
||||||
if (!success)
|
if (!success)
|
||||||
return -1;
|
return -1;
|
||||||
return 0;
|
return 0;
|
||||||
|
@@ -205,8 +205,7 @@ bool EventPosix::StartTimer(bool periodic, unsigned long time) {
|
|||||||
thread_name);
|
thread_name);
|
||||||
periodic_ = periodic;
|
periodic_ = periodic;
|
||||||
time_ = time;
|
time_ = time;
|
||||||
unsigned int id = 0;
|
bool started = timer_thread_->Start();
|
||||||
bool started = timer_thread_->Start(id);
|
|
||||||
pthread_mutex_unlock(&mutex_);
|
pthread_mutex_unlock(&mutex_);
|
||||||
|
|
||||||
return started;
|
return started;
|
||||||
|
@@ -62,18 +62,8 @@ int ConvertToSystemPriority(ThreadPriority priority, int min_prio,
|
|||||||
return low_prio;
|
return low_prio;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct ThreadPosix::InitParams {
|
|
||||||
InitParams(ThreadPosix* thread)
|
|
||||||
: me(thread), started(EventWrapper::Create()) {
|
|
||||||
}
|
|
||||||
ThreadPosix* me;
|
|
||||||
rtc::scoped_ptr<EventWrapper> started;
|
|
||||||
};
|
|
||||||
|
|
||||||
// static
|
|
||||||
void* ThreadPosix::StartThread(void* param) {
|
void* ThreadPosix::StartThread(void* param) {
|
||||||
auto params = static_cast<InitParams*>(param);
|
static_cast<ThreadPosix*>(param)->Run();
|
||||||
params->me->Run(params);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -82,9 +72,9 @@ ThreadPosix::ThreadPosix(ThreadRunFunction func, ThreadObj obj,
|
|||||||
: run_function_(func),
|
: run_function_(func),
|
||||||
obj_(obj),
|
obj_(obj),
|
||||||
prio_(prio),
|
prio_(prio),
|
||||||
|
started_(false),
|
||||||
stop_event_(true, false),
|
stop_event_(true, false),
|
||||||
name_(thread_name ? thread_name : "webrtc"),
|
name_(thread_name ? thread_name : "webrtc"),
|
||||||
thread_id_(0),
|
|
||||||
thread_(0) {
|
thread_(0) {
|
||||||
DCHECK(name_.length() < kThreadMaxNameLength);
|
DCHECK(name_.length() < kThreadMaxNameLength);
|
||||||
}
|
}
|
||||||
@@ -97,44 +87,34 @@ ThreadPosix::~ThreadPosix() {
|
|||||||
DCHECK(thread_checker_.CalledOnValidThread());
|
DCHECK(thread_checker_.CalledOnValidThread());
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ThreadPosix::Start(unsigned int& thread_id) {
|
// TODO(pbos): Make Start void, calling code really doesn't support failures
|
||||||
|
// here.
|
||||||
|
bool ThreadPosix::Start() {
|
||||||
DCHECK(thread_checker_.CalledOnValidThread());
|
DCHECK(thread_checker_.CalledOnValidThread());
|
||||||
DCHECK(!thread_id_) << "Thread already started?";
|
|
||||||
|
|
||||||
ThreadAttributes attr;
|
ThreadAttributes attr;
|
||||||
// Set the stack stack size to 1M.
|
// Set the stack stack size to 1M.
|
||||||
pthread_attr_setstacksize(&attr, 1024 * 1024);
|
pthread_attr_setstacksize(&attr, 1024 * 1024);
|
||||||
|
|
||||||
InitParams params(this);
|
CHECK_EQ(0, pthread_create(&thread_, &attr, &StartThread, this));
|
||||||
int result = pthread_create(&thread_, &attr, &StartThread, ¶ms);
|
started_ = true;
|
||||||
if (result != 0)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
CHECK_EQ(kEventSignaled, params.started->Wait(WEBRTC_EVENT_INFINITE));
|
|
||||||
DCHECK_NE(thread_id_, 0);
|
|
||||||
|
|
||||||
thread_id = thread_id_;
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ThreadPosix::Stop() {
|
bool ThreadPosix::Stop() {
|
||||||
DCHECK(thread_checker_.CalledOnValidThread());
|
DCHECK(thread_checker_.CalledOnValidThread());
|
||||||
if (!thread_id_)
|
if (!started_)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
stop_event_.Set();
|
stop_event_.Set();
|
||||||
CHECK_EQ(0, pthread_join(thread_, nullptr));
|
CHECK_EQ(0, pthread_join(thread_, nullptr));
|
||||||
thread_id_ = 0;
|
started_ = false;
|
||||||
stop_event_.Reset();
|
stop_event_.Reset();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ThreadPosix::Run(ThreadPosix::InitParams* params) {
|
void ThreadPosix::Run() {
|
||||||
thread_id_ = rtc::CurrentThreadId();
|
|
||||||
params->started->Set();
|
|
||||||
|
|
||||||
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
|
||||||
// sandbox. Ignore failures if they happen.
|
// sandbox. Ignore failures if they happen.
|
||||||
|
@@ -30,23 +30,22 @@ class ThreadPosix : public ThreadWrapper {
|
|||||||
~ThreadPosix() override;
|
~ThreadPosix() override;
|
||||||
|
|
||||||
// From ThreadWrapper.
|
// From ThreadWrapper.
|
||||||
bool Start(unsigned int& id) override;
|
bool Start() override;
|
||||||
bool Stop() override;
|
bool Stop() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static void* StartThread(void* param);
|
static void* StartThread(void* param);
|
||||||
|
|
||||||
struct InitParams;
|
void Run();
|
||||||
void Run(InitParams* params);
|
|
||||||
|
|
||||||
rtc::ThreadChecker thread_checker_;
|
rtc::ThreadChecker thread_checker_;
|
||||||
ThreadRunFunction const run_function_;
|
ThreadRunFunction const run_function_;
|
||||||
void* const obj_;
|
void* const obj_;
|
||||||
ThreadPriority prio_;
|
ThreadPriority prio_;
|
||||||
|
bool started_;
|
||||||
rtc::Event stop_event_;
|
rtc::Event stop_event_;
|
||||||
const std::string name_;
|
const std::string name_;
|
||||||
|
|
||||||
pid_t thread_id_;
|
|
||||||
pthread_t thread_;
|
pthread_t thread_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -24,8 +24,7 @@ bool NullRunFunction(void* obj) {
|
|||||||
|
|
||||||
TEST(ThreadTest, StartStop) {
|
TEST(ThreadTest, StartStop) {
|
||||||
ThreadWrapper* thread = ThreadWrapper::CreateThread(&NullRunFunction, NULL);
|
ThreadWrapper* thread = ThreadWrapper::CreateThread(&NullRunFunction, NULL);
|
||||||
unsigned int id = 42;
|
ASSERT_TRUE(thread->Start());
|
||||||
ASSERT_TRUE(thread->Start(id));
|
|
||||||
EXPECT_TRUE(thread->Stop());
|
EXPECT_TRUE(thread->Stop());
|
||||||
delete thread;
|
delete thread;
|
||||||
}
|
}
|
||||||
@@ -42,8 +41,7 @@ TEST(ThreadTest, RunFunctionIsCalled) {
|
|||||||
bool flag = false;
|
bool flag = false;
|
||||||
ThreadWrapper* thread = ThreadWrapper::CreateThread(&SetFlagRunFunction,
|
ThreadWrapper* thread = ThreadWrapper::CreateThread(&SetFlagRunFunction,
|
||||||
&flag);
|
&flag);
|
||||||
unsigned int id = 42;
|
ASSERT_TRUE(thread->Start());
|
||||||
ASSERT_TRUE(thread->Start(id));
|
|
||||||
|
|
||||||
// At this point, the flag may be either true or false.
|
// At this point, the flag may be either true or false.
|
||||||
EXPECT_TRUE(thread->Stop());
|
EXPECT_TRUE(thread->Stop());
|
||||||
|
@@ -81,7 +81,7 @@ DWORD WINAPI ThreadWindows::StartThread(void* param) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ThreadWindows::Start(unsigned int& id) {
|
bool ThreadWindows::Start() {
|
||||||
DCHECK(main_thread_.CalledOnValidThread());
|
DCHECK(main_thread_.CalledOnValidThread());
|
||||||
DCHECK(!thread_);
|
DCHECK(!thread_);
|
||||||
|
|
||||||
@@ -98,8 +98,6 @@ bool ThreadWindows::Start(unsigned int& id) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
id = thread_id;
|
|
||||||
|
|
||||||
if (prio_ != kNormalPriority) {
|
if (prio_ != kNormalPriority) {
|
||||||
int priority = THREAD_PRIORITY_NORMAL;
|
int priority = THREAD_PRIORITY_NORMAL;
|
||||||
switch (prio_) {
|
switch (prio_) {
|
||||||
|
@@ -25,7 +25,7 @@ class ThreadWindows : public ThreadWrapper {
|
|||||||
const char* thread_name);
|
const char* thread_name);
|
||||||
~ThreadWindows() override;
|
~ThreadWindows() override;
|
||||||
|
|
||||||
bool Start(unsigned int& id) override;
|
bool Start() override;
|
||||||
bool Stop() override;
|
bool Stop() override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
@@ -540,10 +540,9 @@ UdpSocket2WorkerWindows::~UdpSocket2WorkerWindows()
|
|||||||
|
|
||||||
bool UdpSocket2WorkerWindows::Start()
|
bool UdpSocket2WorkerWindows::Start()
|
||||||
{
|
{
|
||||||
unsigned int id = 0;
|
|
||||||
WEBRTC_TRACE(kTraceStateInfo, kTraceTransport, -1,
|
WEBRTC_TRACE(kTraceStateInfo, kTraceTransport, -1,
|
||||||
"Start UdpSocket2WorkerWindows");
|
"Start UdpSocket2WorkerWindows");
|
||||||
return _pThread->Start(id);
|
return _pThread->Start();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool UdpSocket2WorkerWindows::Stop()
|
bool UdpSocket2WorkerWindows::Stop()
|
||||||
|
@@ -226,7 +226,6 @@ UdpSocketManagerPosixImpl::~UdpSocketManagerPosixImpl()
|
|||||||
|
|
||||||
bool UdpSocketManagerPosixImpl::Start()
|
bool UdpSocketManagerPosixImpl::Start()
|
||||||
{
|
{
|
||||||
unsigned int id = 0;
|
|
||||||
if (_thread == NULL)
|
if (_thread == NULL)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
@@ -234,7 +233,7 @@ bool UdpSocketManagerPosixImpl::Start()
|
|||||||
|
|
||||||
WEBRTC_TRACE(kTraceStateInfo, kTraceTransport, -1,
|
WEBRTC_TRACE(kTraceStateInfo, kTraceTransport, -1,
|
||||||
"Start UdpSocketManagerPosix");
|
"Start UdpSocketManagerPosix");
|
||||||
return _thread->Start(id);
|
return _thread->Start();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool UdpSocketManagerPosixImpl::Stop()
|
bool UdpSocketManagerPosixImpl::Stop()
|
||||||
|
@@ -24,8 +24,7 @@ DirectTransport::DirectTransport()
|
|||||||
clock_(Clock::GetRealTimeClock()),
|
clock_(Clock::GetRealTimeClock()),
|
||||||
shutting_down_(false),
|
shutting_down_(false),
|
||||||
fake_network_(FakeNetworkPipe::Config()) {
|
fake_network_(FakeNetworkPipe::Config()) {
|
||||||
unsigned int thread_id;
|
EXPECT_TRUE(thread_->Start());
|
||||||
EXPECT_TRUE(thread_->Start(thread_id));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
DirectTransport::DirectTransport(
|
DirectTransport::DirectTransport(
|
||||||
@@ -36,8 +35,7 @@ DirectTransport::DirectTransport(
|
|||||||
clock_(Clock::GetRealTimeClock()),
|
clock_(Clock::GetRealTimeClock()),
|
||||||
shutting_down_(false),
|
shutting_down_(false),
|
||||||
fake_network_(config) {
|
fake_network_(config) {
|
||||||
unsigned int thread_id;
|
EXPECT_TRUE(thread_->Start());
|
||||||
EXPECT_TRUE(thread_->Start(thread_id));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
DirectTransport::~DirectTransport() { StopSending(); }
|
DirectTransport::~DirectTransport() { StopSending(); }
|
||||||
|
@@ -59,8 +59,7 @@ int32_t FakeAudioDevice::Init() {
|
|||||||
FakeAudioDevice::Run, this, webrtc::kHighPriority, "FakeAudioDevice"));
|
FakeAudioDevice::Run, this, webrtc::kHighPriority, "FakeAudioDevice"));
|
||||||
if (thread_.get() == NULL)
|
if (thread_.get() == NULL)
|
||||||
return -1;
|
return -1;
|
||||||
unsigned int thread_id;
|
if (!thread_->Start()) {
|
||||||
if (!thread_->Start(thread_id)) {
|
|
||||||
thread_.reset();
|
thread_.reset();
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@@ -96,8 +96,7 @@ bool FrameGeneratorCapturer::Init() {
|
|||||||
"FrameGeneratorCapturer"));
|
"FrameGeneratorCapturer"));
|
||||||
if (thread_.get() == NULL)
|
if (thread_.get() == NULL)
|
||||||
return false;
|
return false;
|
||||||
unsigned int thread_id;
|
if (!thread_->Start()) {
|
||||||
if (!thread_->Start(thread_id)) {
|
|
||||||
thread_.reset();
|
thread_.reset();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@@ -111,8 +111,7 @@ class VideoAnalyzer : public PacketReceiver,
|
|||||||
ThreadWrapper* thread =
|
ThreadWrapper* thread =
|
||||||
ThreadWrapper::CreateThread(&FrameComparisonThread, this);
|
ThreadWrapper::CreateThread(&FrameComparisonThread, this);
|
||||||
comparison_thread_pool_.push_back(thread);
|
comparison_thread_pool_.push_back(thread);
|
||||||
unsigned int id;
|
EXPECT_TRUE(thread->Start());
|
||||||
EXPECT_TRUE(thread->Start(id));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -86,8 +86,7 @@ int ViEAutoTestWindowManager::CreateWindows(AutoTestRect window1Size,
|
|||||||
memcpy(_hwnd1Title, window1Title, TITLE_LENGTH);
|
memcpy(_hwnd1Title, window1Title, TITLE_LENGTH);
|
||||||
memcpy(_hwnd2Title, window2Title, TITLE_LENGTH);
|
memcpy(_hwnd2Title, window2Title, TITLE_LENGTH);
|
||||||
|
|
||||||
unsigned int tId = 0;
|
_eventThread.Start();
|
||||||
_eventThread.Start(tId);
|
|
||||||
|
|
||||||
do {
|
do {
|
||||||
_crit.Enter();
|
_crit.Enter();
|
||||||
|
@@ -64,8 +64,7 @@ bool ViEFakeCamera::StartCameraInNewThread(
|
|||||||
// thread-safe.
|
// thread-safe.
|
||||||
camera_thread_ = webrtc::ThreadWrapper::CreateThread(
|
camera_thread_ = webrtc::ThreadWrapper::CreateThread(
|
||||||
StreamVideoFileRepeatedlyIntoCaptureDevice, file_capture_device_);
|
StreamVideoFileRepeatedlyIntoCaptureDevice, file_capture_device_);
|
||||||
unsigned int id;
|
camera_thread_->Start();
|
||||||
camera_thread_->Start(id);
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@@ -65,8 +65,7 @@ bool ViEToFileRenderer::PrepareForRendering(
|
|||||||
|
|
||||||
output_filename_ = output_filename;
|
output_filename_ = output_filename;
|
||||||
output_path_ = output_path;
|
output_path_ = output_path;
|
||||||
unsigned int tid;
|
return thread_->Start();
|
||||||
return thread_->Start(tid);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ViEToFileRenderer::StopRendering() {
|
void ViEToFileRenderer::StopRendering() {
|
||||||
|
@@ -76,9 +76,8 @@ TbExternalTransport::TbExternalTransport(
|
|||||||
previous_drop_(false)
|
previous_drop_(false)
|
||||||
{
|
{
|
||||||
srand((int) webrtc::TickTime::MicrosecondTimestamp());
|
srand((int) webrtc::TickTime::MicrosecondTimestamp());
|
||||||
unsigned int tId = 0;
|
|
||||||
memset(&network_parameters_, 0, sizeof(NetworkParameters));
|
memset(&network_parameters_, 0, sizeof(NetworkParameters));
|
||||||
_thread.Start(tId);
|
_thread.Start();
|
||||||
}
|
}
|
||||||
|
|
||||||
TbExternalTransport::~TbExternalTransport()
|
TbExternalTransport::~TbExternalTransport()
|
||||||
|
@@ -88,8 +88,7 @@ ViECapturer::ViECapturer(int capture_id,
|
|||||||
overuse_detector_(
|
overuse_detector_(
|
||||||
new OveruseFrameDetector(Clock::GetRealTimeClock(),
|
new OveruseFrameDetector(Clock::GetRealTimeClock(),
|
||||||
cpu_overuse_metrics_observer_.get())) {
|
cpu_overuse_metrics_observer_.get())) {
|
||||||
unsigned int t_id = 0;
|
if (!capture_thread_.Start()) {
|
||||||
if (!capture_thread_.Start(t_id)) {
|
|
||||||
assert(false);
|
assert(false);
|
||||||
}
|
}
|
||||||
module_process_thread_.RegisterModule(overuse_detector_.get());
|
module_process_thread_.RegisterModule(overuse_detector_.get());
|
||||||
|
@@ -1846,8 +1846,7 @@ int32_t ViEChannel::StartDecodeThread() {
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int thread_id;
|
if (decode_thread_->Start() == false) {
|
||||||
if (decode_thread_->Start(thread_id) == false) {
|
|
||||||
delete decode_thread_;
|
delete decode_thread_;
|
||||||
decode_thread_ = NULL;
|
decode_thread_ = NULL;
|
||||||
LOG(LS_ERROR) << "Could not start decode thread.";
|
LOG(LS_ERROR) << "Could not start decode thread.";
|
||||||
|
@@ -281,8 +281,7 @@ int ThreadTest::RunTest()
|
|||||||
{
|
{
|
||||||
if (_thread)
|
if (_thread)
|
||||||
{
|
{
|
||||||
unsigned int id;
|
_thread->Start();
|
||||||
_thread->Start(id);
|
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@@ -31,8 +31,7 @@ FakeExternalTransport::FakeExternalTransport(webrtc::VoENetwork* ptr)
|
|||||||
thread_ = webrtc::ThreadWrapper::CreateThread(
|
thread_ = webrtc::ThreadWrapper::CreateThread(
|
||||||
Run, this, webrtc::kHighPriority, thread_name);
|
Run, this, webrtc::kHighPriority, thread_name);
|
||||||
if (thread_) {
|
if (thread_) {
|
||||||
unsigned int id;
|
thread_->Start();
|
||||||
thread_->Start(id);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -31,8 +31,7 @@ class LoopBackTransport : public webrtc::Transport {
|
|||||||
packet_event_(webrtc::EventWrapper::Create()),
|
packet_event_(webrtc::EventWrapper::Create()),
|
||||||
thread_(webrtc::ThreadWrapper::CreateThread(NetworkProcess, this)),
|
thread_(webrtc::ThreadWrapper::CreateThread(NetworkProcess, this)),
|
||||||
voe_network_(voe_network), transmitted_packets_(0) {
|
voe_network_(voe_network), transmitted_packets_(0) {
|
||||||
unsigned int id;
|
thread_->Start();
|
||||||
thread_->Start(id);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
~LoopBackTransport() { thread_->Stop(); }
|
~LoopBackTransport() { thread_->Stop(); }
|
||||||
|
@@ -338,8 +338,7 @@ int VoEStressTest::MultipleThreadsTest() {
|
|||||||
const char* threadName = "StressTest Extra API Thread";
|
const char* threadName = "StressTest Extra API Thread";
|
||||||
_ptrExtraApiThread = ThreadWrapper::CreateThread(RunExtraApi, this,
|
_ptrExtraApiThread = ThreadWrapper::CreateThread(RunExtraApi, this,
|
||||||
kNormalPriority, threadName);
|
kNormalPriority, threadName);
|
||||||
unsigned int id(0);
|
VALIDATE_STRESS(!_ptrExtraApiThread->Start());
|
||||||
VALIDATE_STRESS(!_ptrExtraApiThread->Start(id));
|
|
||||||
|
|
||||||
// Some possible extensions include:
|
// Some possible extensions include:
|
||||||
// Add more API calls to randomize
|
// Add more API calls to randomize
|
||||||
|
Reference in New Issue
Block a user