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