Remove SetNotAlive method from the thread class.
Also cleaning up methods with the same name in other classes that are derived from the above method. R=perkj@webrtc.org Review URL: https://webrtc-codereview.appspot.com/41759004 Cr-Commit-Position: refs/heads/master@{#8242} git-svn-id: http://webrtc.googlecode.com/svn/trunk@8242 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
parent
c5f697135e
commit
875c97ed9d
@ -227,7 +227,6 @@ int32_t AudioRecordJni::Terminate() {
|
|||||||
ThreadWrapper* tmpThread = _ptrThreadRec;
|
ThreadWrapper* tmpThread = _ptrThreadRec;
|
||||||
_ptrThreadRec = NULL;
|
_ptrThreadRec = NULL;
|
||||||
_critSect.Leave();
|
_critSect.Leave();
|
||||||
tmpThread->SetNotAlive();
|
|
||||||
// Release again, we might have returned to waiting state
|
// Release again, we might have returned to waiting state
|
||||||
_timeEventRec.Set();
|
_timeEventRec.Set();
|
||||||
if (tmpThread->Stop())
|
if (tmpThread->Stop())
|
||||||
|
@ -221,7 +221,6 @@ int32_t AudioTrackJni::Terminate() {
|
|||||||
ThreadWrapper* tmpThread = _ptrThreadPlay;
|
ThreadWrapper* tmpThread = _ptrThreadPlay;
|
||||||
_ptrThreadPlay = NULL;
|
_ptrThreadPlay = NULL;
|
||||||
_critSect.Leave();
|
_critSect.Leave();
|
||||||
tmpThread->SetNotAlive();
|
|
||||||
_timeEventPlay.Set();
|
_timeEventPlay.Set();
|
||||||
if (tmpThread->Stop())
|
if (tmpThread->Stop())
|
||||||
{
|
{
|
||||||
|
@ -218,8 +218,6 @@ int32_t AudioDeviceLinuxALSA::Terminate()
|
|||||||
_ptrThreadRec = NULL;
|
_ptrThreadRec = NULL;
|
||||||
_critSect.Leave();
|
_critSect.Leave();
|
||||||
|
|
||||||
tmpThread->SetNotAlive();
|
|
||||||
|
|
||||||
if (tmpThread->Stop())
|
if (tmpThread->Stop())
|
||||||
{
|
{
|
||||||
delete tmpThread;
|
delete tmpThread;
|
||||||
@ -240,8 +238,6 @@ int32_t AudioDeviceLinuxALSA::Terminate()
|
|||||||
_ptrThreadPlay = NULL;
|
_ptrThreadPlay = NULL;
|
||||||
_critSect.Leave();
|
_critSect.Leave();
|
||||||
|
|
||||||
tmpThread->SetNotAlive();
|
|
||||||
|
|
||||||
if (tmpThread->Stop())
|
if (tmpThread->Stop())
|
||||||
{
|
{
|
||||||
delete tmpThread;
|
delete tmpThread;
|
||||||
|
@ -280,7 +280,6 @@ int32_t AudioDeviceLinuxPulse::Terminate()
|
|||||||
_ptrThreadRec = NULL;
|
_ptrThreadRec = NULL;
|
||||||
UnLock();
|
UnLock();
|
||||||
|
|
||||||
tmpThread->SetNotAlive();
|
|
||||||
_timeEventRec.Set();
|
_timeEventRec.Set();
|
||||||
if (tmpThread->Stop())
|
if (tmpThread->Stop())
|
||||||
{
|
{
|
||||||
@ -301,7 +300,6 @@ int32_t AudioDeviceLinuxPulse::Terminate()
|
|||||||
_ptrThreadPlay = NULL;
|
_ptrThreadPlay = NULL;
|
||||||
_critSect.Leave();
|
_critSect.Leave();
|
||||||
|
|
||||||
tmpThread->SetNotAlive();
|
|
||||||
_timeEventPlay.Set();
|
_timeEventPlay.Set();
|
||||||
if (tmpThread->Stop())
|
if (tmpThread->Stop())
|
||||||
{
|
{
|
||||||
|
@ -330,7 +330,6 @@ int32_t AudioDeviceWindowsWave::Terminate()
|
|||||||
_ptrThread = NULL;
|
_ptrThread = NULL;
|
||||||
_critSect.Leave();
|
_critSect.Leave();
|
||||||
|
|
||||||
tmpThread->SetNotAlive();
|
|
||||||
_timeEvent.Set();
|
_timeEvent.Set();
|
||||||
|
|
||||||
if (tmpThread->Stop())
|
if (tmpThread->Stop())
|
||||||
|
@ -918,7 +918,6 @@ MatlabEngine::~MatlabEngine()
|
|||||||
|
|
||||||
if (_plotThread)
|
if (_plotThread)
|
||||||
{
|
{
|
||||||
_plotThread->SetNotAlive();
|
|
||||||
_running = false;
|
_running = false;
|
||||||
_eventPtr->Set();
|
_eventPtr->Set();
|
||||||
|
|
||||||
|
@ -100,7 +100,6 @@ int32_t TestLoadGenerator::Stop ()
|
|||||||
|
|
||||||
if (_genThread)
|
if (_genThread)
|
||||||
{
|
{
|
||||||
_genThread->SetNotAlive();
|
|
||||||
_running = false;
|
_running = false;
|
||||||
_eventPtr->Set();
|
_eventPtr->Set();
|
||||||
|
|
||||||
|
@ -199,7 +199,6 @@ int32_t TestSenderReceiver::Stop ()
|
|||||||
|
|
||||||
if (_procThread)
|
if (_procThread)
|
||||||
{
|
{
|
||||||
_procThread->SetNotAlive();
|
|
||||||
_running = false;
|
_running = false;
|
||||||
_eventPtr->Set();
|
_eventPtr->Set();
|
||||||
|
|
||||||
|
@ -457,8 +457,6 @@ bool AviRecorder::StopThread()
|
|||||||
|
|
||||||
if(_thread)
|
if(_thread)
|
||||||
{
|
{
|
||||||
_thread->SetNotAlive();
|
|
||||||
|
|
||||||
ThreadWrapper* thread = _thread;
|
ThreadWrapper* thread = _thread;
|
||||||
_thread = NULL;
|
_thread = NULL;
|
||||||
|
|
||||||
|
@ -65,8 +65,6 @@ int32_t ProcessThreadImpl::Stop()
|
|||||||
_critSectModules->Enter();
|
_critSectModules->Enter();
|
||||||
if(_thread)
|
if(_thread)
|
||||||
{
|
{
|
||||||
_thread->SetNotAlive();
|
|
||||||
|
|
||||||
ThreadWrapper* thread = _thread;
|
ThreadWrapper* thread = _thread;
|
||||||
_thread = NULL;
|
_thread = NULL;
|
||||||
|
|
||||||
|
@ -47,17 +47,17 @@ VideoCaptureModule* VideoCaptureImpl::Create(const int32_t id,
|
|||||||
}
|
}
|
||||||
|
|
||||||
VideoCaptureModuleV4L2::VideoCaptureModuleV4L2(const int32_t id)
|
VideoCaptureModuleV4L2::VideoCaptureModuleV4L2(const int32_t id)
|
||||||
: VideoCaptureImpl(id),
|
: VideoCaptureImpl(id),
|
||||||
_captureThread(NULL),
|
_captureThread(NULL),
|
||||||
_captureCritSect(CriticalSectionWrapper::CreateCriticalSection()),
|
_captureCritSect(CriticalSectionWrapper::CreateCriticalSection()),
|
||||||
_deviceId(-1),
|
_deviceId(-1),
|
||||||
_deviceFd(-1),
|
_deviceFd(-1),
|
||||||
_buffersAllocatedByDevice(-1),
|
_buffersAllocatedByDevice(-1),
|
||||||
_currentWidth(-1),
|
_currentWidth(-1),
|
||||||
_currentHeight(-1),
|
_currentHeight(-1),
|
||||||
_currentFrameRate(-1),
|
_currentFrameRate(-1),
|
||||||
_captureStarted(false),
|
_captureStarted(false),
|
||||||
_captureVideoType(kVideoI420),
|
_captureVideoType(kVideoI420),
|
||||||
_pool(NULL)
|
_pool(NULL)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@ -306,7 +306,6 @@ int32_t VideoCaptureModuleV4L2::StopCapture()
|
|||||||
{
|
{
|
||||||
if (_captureThread) {
|
if (_captureThread) {
|
||||||
// Make sure the capture thread stop stop using the critsect.
|
// Make sure the capture thread stop stop using the critsect.
|
||||||
_captureThread->SetNotAlive();
|
|
||||||
if (_captureThread->Stop()) {
|
if (_captureThread->Stop()) {
|
||||||
delete _captureThread;
|
delete _captureThread;
|
||||||
_captureThread = NULL;
|
_captureThread = NULL;
|
||||||
|
@ -178,7 +178,6 @@ int32_t VideoRenderAndroid::StopRender() {
|
|||||||
|
|
||||||
_javaShutdownEvent.Wait(3000);
|
_javaShutdownEvent.Wait(3000);
|
||||||
CriticalSectionScoped cs(&_critSect);
|
CriticalSectionScoped cs(&_critSect);
|
||||||
_javaRenderThread->SetNotAlive();
|
|
||||||
if (_javaRenderThread->Stop()) {
|
if (_javaRenderThread->Stop()) {
|
||||||
delete _javaRenderThread;
|
delete _javaRenderThread;
|
||||||
_javaRenderThread = NULL;
|
_javaRenderThread = NULL;
|
||||||
|
@ -250,7 +250,6 @@ int32_t IncomingVideoStream::Stop() {
|
|||||||
if (incoming_render_thread_) {
|
if (incoming_render_thread_) {
|
||||||
ThreadWrapper* thread = incoming_render_thread_;
|
ThreadWrapper* thread = incoming_render_thread_;
|
||||||
incoming_render_thread_ = NULL;
|
incoming_render_thread_ = NULL;
|
||||||
thread->SetNotAlive();
|
|
||||||
#ifndef WIN32_
|
#ifndef WIN32_
|
||||||
deliver_buffer_event_.StopTimer();
|
deliver_buffer_event_.StopTimer();
|
||||||
#endif
|
#endif
|
||||||
|
@ -46,7 +46,6 @@ VideoRenderIosGles20::~VideoRenderIosGles20() {
|
|||||||
screen_update_thread_ = NULL;
|
screen_update_thread_ = NULL;
|
||||||
|
|
||||||
if (thread_wrapper) {
|
if (thread_wrapper) {
|
||||||
thread_wrapper->SetNotAlive();
|
|
||||||
screen_update_event_->Set();
|
screen_update_event_->Set();
|
||||||
screen_update_event_->StopTimer();
|
screen_update_event_->StopTimer();
|
||||||
|
|
||||||
|
@ -685,7 +685,6 @@ VideoRenderAGL::~VideoRenderAGL()
|
|||||||
|
|
||||||
if (tmpPtr)
|
if (tmpPtr)
|
||||||
{
|
{
|
||||||
tmpPtr->SetNotAlive();
|
|
||||||
_screenUpdateEvent->Set();
|
_screenUpdateEvent->Set();
|
||||||
_screenUpdateEvent->StopTimer();
|
_screenUpdateEvent->StopTimer();
|
||||||
|
|
||||||
@ -868,7 +867,6 @@ int VideoRenderAGL::StopThread()
|
|||||||
|
|
||||||
if (tmpPtr)
|
if (tmpPtr)
|
||||||
{
|
{
|
||||||
tmpPtr->SetNotAlive();
|
|
||||||
_screenUpdateEvent->Set();
|
_screenUpdateEvent->Set();
|
||||||
if (tmpPtr->Stop())
|
if (tmpPtr->Stop())
|
||||||
{
|
{
|
||||||
|
@ -664,7 +664,6 @@ VideoRenderNSOpenGL::~VideoRenderNSOpenGL()
|
|||||||
|
|
||||||
if (tmpPtr)
|
if (tmpPtr)
|
||||||
{
|
{
|
||||||
tmpPtr->SetNotAlive();
|
|
||||||
_screenUpdateEvent->Set();
|
_screenUpdateEvent->Set();
|
||||||
_screenUpdateEvent->StopTimer();
|
_screenUpdateEvent->StopTimer();
|
||||||
|
|
||||||
@ -873,7 +872,6 @@ int VideoRenderNSOpenGL::StopThread()
|
|||||||
|
|
||||||
if (tmpPtr)
|
if (tmpPtr)
|
||||||
{
|
{
|
||||||
tmpPtr->SetNotAlive();
|
|
||||||
_screenUpdateEvent->Set();
|
_screenUpdateEvent->Set();
|
||||||
if (tmpPtr->Stop())
|
if (tmpPtr->Stop())
|
||||||
{
|
{
|
||||||
|
@ -312,7 +312,6 @@ VideoRenderDirect3D9::~VideoRenderDirect3D9()
|
|||||||
_screenUpdateThread = NULL;
|
_screenUpdateThread = NULL;
|
||||||
if (tmpPtr)
|
if (tmpPtr)
|
||||||
{
|
{
|
||||||
tmpPtr->SetNotAlive();
|
|
||||||
_screenUpdateEvent->Set();
|
_screenUpdateEvent->Set();
|
||||||
_screenUpdateEvent->StopTimer();
|
_screenUpdateEvent->StopTimer();
|
||||||
|
|
||||||
@ -515,7 +514,7 @@ int VideoRenderDirect3D9::InitDevice()
|
|||||||
{ 1.0f, -1.0f, 0.0f, 0xffffffff, 1, 1 }, { 1.0f, 1.0f, 0.0f,
|
{ 1.0f, -1.0f, 0.0f, 0xffffffff, 1, 1 }, { 1.0f, 1.0f, 0.0f,
|
||||||
0xffffffff, 1, 0 } };
|
0xffffffff, 1, 0 } };
|
||||||
|
|
||||||
// Create the vertex buffer.
|
// Create the vertex buffer.
|
||||||
if (FAILED(_pd3dDevice->CreateVertexBuffer(sizeof(Vertices), 0,
|
if (FAILED(_pd3dDevice->CreateVertexBuffer(sizeof(Vertices), 0,
|
||||||
D3DFVF_CUSTOMVERTEX,
|
D3DFVF_CUSTOMVERTEX,
|
||||||
D3DPOOL_DEFAULT, &_pVB, NULL )))
|
D3DPOOL_DEFAULT, &_pVB, NULL )))
|
||||||
@ -837,7 +836,7 @@ int32_t VideoRenderDirect3D9::DeleteChannel(const uint32_t streamId)
|
|||||||
if (ddIt != _d3dChannels.end())
|
if (ddIt != _d3dChannels.end())
|
||||||
{
|
{
|
||||||
delete ddIt->second;
|
delete ddIt->second;
|
||||||
_d3dChannels.erase(ddIt);
|
_d3dChannels.erase(ddIt);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
@ -853,7 +852,7 @@ VideoRenderCallback* VideoRenderDirect3D9::CreateChannel(const uint32_t channel,
|
|||||||
CriticalSectionScoped cs(&_refD3DCritsect);
|
CriticalSectionScoped cs(&_refD3DCritsect);
|
||||||
|
|
||||||
//FIXME this should be done in VideoAPIWindows? stop the frame deliver first
|
//FIXME this should be done in VideoAPIWindows? stop the frame deliver first
|
||||||
//remove the old channel
|
//remove the old channel
|
||||||
DeleteChannel(channel);
|
DeleteChannel(channel);
|
||||||
|
|
||||||
D3D9Channel* d3dChannel = new D3D9Channel(_pd3dDevice,
|
D3D9Channel* d3dChannel = new D3D9Channel(_pd3dDevice,
|
||||||
@ -890,9 +889,8 @@ int32_t VideoRenderDirect3D9::GetStreamSettings(const uint32_t channel,
|
|||||||
"Direct3D render failed to find channel");
|
"Direct3D render failed to find channel");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
// Only allow one stream per channel, demuxing is
|
// Only allow one stream per channel, demuxing is
|
||||||
return ddobj->GetStreamSettings(0, zOrder, left, top, right, bottom);
|
return ddobj->GetStreamSettings(0, zOrder, left, top, right, bottom);
|
||||||
//return ddobj->GetStreamSettings(streamId, zOrder, left, top, right, bottom);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int VideoRenderDirect3D9::UpdateVerticeBuffer(LPDIRECT3DVERTEXBUFFER9 pVB,
|
int VideoRenderDirect3D9::UpdateVerticeBuffer(LPDIRECT3DVERTEXBUFFER9 pVB,
|
||||||
@ -1092,7 +1090,7 @@ int32_t VideoRenderDirect3D9::SetBitmap(const void* bitMap,
|
|||||||
int pitch = bmap.bmWidth * 4;
|
int pitch = bmap.bmWidth * 4;
|
||||||
|
|
||||||
if (pbi.bmiHeader.biBitCount == 24)
|
if (pbi.bmiHeader.biBitCount == 24)
|
||||||
{
|
{
|
||||||
ConvertRGB24ToARGB(srcPtr, dstPtr, bmap.bmWidth, bmap.bmHeight, 0);
|
ConvertRGB24ToARGB(srcPtr, dstPtr, bmap.bmWidth, bmap.bmHeight, 0);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -1168,7 +1166,7 @@ int32_t VideoRenderDirect3D9::ConfigureRenderer(const uint32_t channel,
|
|||||||
"Direct3D render failed to find channel");
|
"Direct3D render failed to find channel");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
// Only allow one stream per channel, demuxing is
|
// Only allow one stream per channel, demuxing is
|
||||||
ddobj->SetStreamSettings(0, zOrder, left, top, right, bottom);
|
ddobj->SetStreamSettings(0, zOrder, left, top, right, bottom);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -69,11 +69,6 @@ class ThreadWrapper {
|
|||||||
// TODO(tommi): Move outside of the ThreadWrapper class to avoid confusion.
|
// TODO(tommi): Move outside of the ThreadWrapper class to avoid confusion.
|
||||||
static uint32_t GetThreadId();
|
static uint32_t GetThreadId();
|
||||||
|
|
||||||
// Non blocking termination of the spawned thread. Note that it is not safe
|
|
||||||
// to delete this class until the spawned thread has been reclaimed.
|
|
||||||
// TODO(tommi): Remove this method.
|
|
||||||
virtual void SetNotAlive() = 0;
|
|
||||||
|
|
||||||
// Tries to spawns a thread and returns true if that was successful.
|
// Tries to spawns a thread and returns true if that was successful.
|
||||||
// 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
|
||||||
|
@ -157,7 +157,6 @@ class CondVarTest : public ::testing::Test {
|
|||||||
// Thus, we need to pin it down inside its Run function (between Grab
|
// Thus, we need to pin it down inside its Run function (between Grab
|
||||||
// and Pass).
|
// and Pass).
|
||||||
ASSERT_TRUE(baton_.Pass(kShortWaitMs));
|
ASSERT_TRUE(baton_.Pass(kShortWaitMs));
|
||||||
thread_->SetNotAlive();
|
|
||||||
ASSERT_TRUE(baton_.Grab(kShortWaitMs));
|
ASSERT_TRUE(baton_.Grab(kShortWaitMs));
|
||||||
ASSERT_TRUE(thread_->Stop());
|
ASSERT_TRUE(thread_->Stop());
|
||||||
delete thread_;
|
delete thread_;
|
||||||
|
@ -129,7 +129,6 @@ TEST_F(CritSectTest, ThreadWakesTwice) NO_THREAD_SAFETY_ANALYSIS {
|
|||||||
EXPECT_EQ(count_before, count.Count());
|
EXPECT_EQ(count_before, count.Count());
|
||||||
crit_sect->Leave();
|
crit_sect->Leave();
|
||||||
|
|
||||||
thread->SetNotAlive(); // Tell thread to exit once run function finishes.
|
|
||||||
SwitchProcess();
|
SwitchProcess();
|
||||||
EXPECT_TRUE(WaitForCount(count_before + 1, &count));
|
EXPECT_TRUE(WaitForCount(count_before + 1, &count));
|
||||||
EXPECT_TRUE(thread->Stop());
|
EXPECT_TRUE(thread->Stop());
|
||||||
|
@ -444,7 +444,6 @@ void DataLogImpl::Process() {
|
|||||||
|
|
||||||
void DataLogImpl::StopThread() {
|
void DataLogImpl::StopThread() {
|
||||||
if (file_writer_thread_ != NULL) {
|
if (file_writer_thread_ != NULL) {
|
||||||
file_writer_thread_->SetNotAlive();
|
|
||||||
flush_event_->Set();
|
flush_event_->Set();
|
||||||
// Call Stop() repeatedly, waiting for the Flush() call in Process() to
|
// Call Stop() repeatedly, waiting for the Flush() call in Process() to
|
||||||
// finish.
|
// finish.
|
||||||
|
@ -266,9 +266,6 @@ bool EventPosix::Process() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool EventPosix::StopTimer() {
|
bool EventPosix::StopTimer() {
|
||||||
if (timer_thread_) {
|
|
||||||
timer_thread_->SetNotAlive();
|
|
||||||
}
|
|
||||||
if (timer_event_) {
|
if (timer_event_) {
|
||||||
timer_event_->Set();
|
timer_event_->Set();
|
||||||
}
|
}
|
||||||
|
@ -118,10 +118,6 @@ bool ThreadPosix::Start(unsigned int& thread_id) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ThreadPosix::SetNotAlive() {
|
|
||||||
DCHECK(thread_checker_.CalledOnValidThread());
|
|
||||||
}
|
|
||||||
|
|
||||||
bool ThreadPosix::Stop() {
|
bool ThreadPosix::Stop() {
|
||||||
DCHECK(thread_checker_.CalledOnValidThread());
|
DCHECK(thread_checker_.CalledOnValidThread());
|
||||||
if (!thread_id_)
|
if (!thread_id_)
|
||||||
|
@ -32,7 +32,6 @@ class ThreadPosix : public ThreadWrapper {
|
|||||||
~ThreadPosix() override;
|
~ThreadPosix() override;
|
||||||
|
|
||||||
// From ThreadWrapper.
|
// From ThreadWrapper.
|
||||||
void SetNotAlive() override;
|
|
||||||
bool Start(unsigned int& id) override;
|
bool Start(unsigned int& id) override;
|
||||||
bool Stop() override;
|
bool Stop() override;
|
||||||
|
|
||||||
|
@ -89,10 +89,6 @@ bool ThreadWindows::Start(unsigned int& id) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ThreadWindows::SetNotAlive() {
|
|
||||||
DCHECK(main_thread_.CalledOnValidThread());
|
|
||||||
}
|
|
||||||
|
|
||||||
bool ThreadWindows::Stop() {
|
bool ThreadWindows::Stop() {
|
||||||
DCHECK(main_thread_.CalledOnValidThread());
|
DCHECK(main_thread_.CalledOnValidThread());
|
||||||
if (thread_) {
|
if (thread_) {
|
||||||
|
@ -27,7 +27,6 @@ class ThreadWindows : public ThreadWrapper {
|
|||||||
|
|
||||||
bool Start(unsigned int& id) override;
|
bool Start(unsigned int& id) override;
|
||||||
bool Stop() override;
|
bool Stop() override;
|
||||||
void SetNotAlive() override;
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void Run();
|
void Run();
|
||||||
|
@ -103,7 +103,6 @@ bool TraceImpl::StopThread() {
|
|||||||
// messages?
|
// messages?
|
||||||
SleepMs(10);
|
SleepMs(10);
|
||||||
|
|
||||||
thread_.SetNotAlive();
|
|
||||||
// Make sure the thread finishes as quickly as possible (instead of having
|
// Make sure the thread finishes as quickly as possible (instead of having
|
||||||
// to wait for the timeout).
|
// to wait for the timeout).
|
||||||
event_.Set();
|
event_.Set();
|
||||||
|
@ -268,12 +268,6 @@ bool UdpSocket2ManagerWindows::StopWorkerThreads()
|
|||||||
_managerNumber,
|
_managerNumber,
|
||||||
_numActiveSockets);
|
_numActiveSockets);
|
||||||
|
|
||||||
// Set worker threads to not alive so that they will stop calling
|
|
||||||
// UdpSocket2WorkerWindows::Run().
|
|
||||||
for (WorkerList::iterator iter = _workerThreadsList.begin();
|
|
||||||
iter != _workerThreadsList.end(); ++iter) {
|
|
||||||
(*iter)->SetNotAlive();
|
|
||||||
}
|
|
||||||
// Release all threads waiting for GetQueuedCompletionStatus(..).
|
// Release all threads waiting for GetQueuedCompletionStatus(..).
|
||||||
if(_ioCompletionHandle)
|
if(_ioCompletionHandle)
|
||||||
{
|
{
|
||||||
@ -559,13 +553,6 @@ bool UdpSocket2WorkerWindows::Stop()
|
|||||||
return _pThread->Stop();
|
return _pThread->Stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
void UdpSocket2WorkerWindows::SetNotAlive()
|
|
||||||
{
|
|
||||||
WEBRTC_TRACE(kTraceStateInfo, kTraceTransport, -1,
|
|
||||||
"SetNotAlive UdpSocket2WorkerWindows");
|
|
||||||
_pThread->SetNotAlive();
|
|
||||||
}
|
|
||||||
|
|
||||||
int32_t UdpSocket2WorkerWindows::Init()
|
int32_t UdpSocket2WorkerWindows::Init()
|
||||||
{
|
{
|
||||||
if(!_init)
|
if(!_init)
|
||||||
|
@ -100,7 +100,6 @@ public:
|
|||||||
virtual bool Start();
|
virtual bool Start();
|
||||||
virtual bool Stop();
|
virtual bool Stop();
|
||||||
virtual int32_t Init();
|
virtual int32_t Init();
|
||||||
virtual void SetNotAlive();
|
|
||||||
protected:
|
protected:
|
||||||
static bool Run(ThreadObj obj);
|
static bool Run(ThreadObj obj);
|
||||||
bool Process();
|
bool Process();
|
||||||
|
@ -102,8 +102,6 @@ int ViEAutoTestWindowManager::CreateWindows(AutoTestRect window1Size,
|
|||||||
}
|
}
|
||||||
|
|
||||||
int ViEAutoTestWindowManager::TerminateWindows() {
|
int ViEAutoTestWindowManager::TerminateWindows() {
|
||||||
_eventThread.SetNotAlive();
|
|
||||||
|
|
||||||
_terminate = true;
|
_terminate = true;
|
||||||
if (_eventThread.Stop()) {
|
if (_eventThread.Stop()) {
|
||||||
_crit.Enter();
|
_crit.Enter();
|
||||||
|
@ -72,7 +72,6 @@ bool ViEToFileRenderer::PrepareForRendering(
|
|||||||
void ViEToFileRenderer::StopRendering() {
|
void ViEToFileRenderer::StopRendering() {
|
||||||
assert(output_file_ != NULL);
|
assert(output_file_ != NULL);
|
||||||
if (thread_.get() != NULL) {
|
if (thread_.get() != NULL) {
|
||||||
thread_->SetNotAlive();
|
|
||||||
// Signal that a frame is ready to be written to file.
|
// Signal that a frame is ready to be written to file.
|
||||||
frame_render_event_->Set();
|
frame_render_event_->Set();
|
||||||
// Call Stop() repeatedly, waiting for ProcessRenderQueue() to finish.
|
// Call Stop() repeatedly, waiting for ProcessRenderQueue() to finish.
|
||||||
|
@ -86,7 +86,6 @@ TbExternalTransport::TbExternalTransport(
|
|||||||
|
|
||||||
TbExternalTransport::~TbExternalTransport()
|
TbExternalTransport::~TbExternalTransport()
|
||||||
{
|
{
|
||||||
_thread.SetNotAlive();
|
|
||||||
_event.Set();
|
_event.Set();
|
||||||
if (_thread.Stop())
|
if (_thread.Stop())
|
||||||
{
|
{
|
||||||
|
@ -49,6 +49,7 @@ ViECapturer::ViECapturer(int capture_id,
|
|||||||
"ViECaptureThread")),
|
"ViECaptureThread")),
|
||||||
capture_event_(*EventWrapper::Create()),
|
capture_event_(*EventWrapper::Create()),
|
||||||
deliver_event_(*EventWrapper::Create()),
|
deliver_event_(*EventWrapper::Create()),
|
||||||
|
stop_(false),
|
||||||
effect_filter_(NULL),
|
effect_filter_(NULL),
|
||||||
image_proc_module_(NULL),
|
image_proc_module_(NULL),
|
||||||
image_proc_module_ref_counter_(0),
|
image_proc_module_ref_counter_(0),
|
||||||
@ -70,12 +71,8 @@ ViECapturer::~ViECapturer() {
|
|||||||
module_process_thread_.DeRegisterModule(overuse_detector_.get());
|
module_process_thread_.DeRegisterModule(overuse_detector_.get());
|
||||||
|
|
||||||
// Stop the thread.
|
// Stop the thread.
|
||||||
deliver_cs_->Enter();
|
stop_ = true;
|
||||||
capture_cs_->Enter();
|
|
||||||
capture_thread_.SetNotAlive();
|
|
||||||
capture_event_.Set();
|
capture_event_.Set();
|
||||||
capture_cs_->Leave();
|
|
||||||
deliver_cs_->Leave();
|
|
||||||
|
|
||||||
// Stop the camera input.
|
// Stop the camera input.
|
||||||
if (capture_module_) {
|
if (capture_module_) {
|
||||||
@ -454,6 +451,9 @@ bool ViECapturer::ViECaptureThreadFunction(void* obj) {
|
|||||||
bool ViECapturer::ViECaptureProcess() {
|
bool ViECapturer::ViECaptureProcess() {
|
||||||
int64_t capture_time = -1;
|
int64_t capture_time = -1;
|
||||||
if (capture_event_.Wait(kThreadWaitTimeMs) == kEventSignaled) {
|
if (capture_event_.Wait(kThreadWaitTimeMs) == kEventSignaled) {
|
||||||
|
if (stop_)
|
||||||
|
return false;
|
||||||
|
|
||||||
overuse_detector_->FrameProcessingStarted();
|
overuse_detector_->FrameProcessingStarted();
|
||||||
int64_t encode_start_time = -1;
|
int64_t encode_start_time = -1;
|
||||||
deliver_cs_->Enter();
|
deliver_cs_->Enter();
|
||||||
|
@ -168,6 +168,8 @@ class ViECapturer
|
|||||||
EventWrapper& capture_event_;
|
EventWrapper& capture_event_;
|
||||||
EventWrapper& deliver_event_;
|
EventWrapper& deliver_event_;
|
||||||
|
|
||||||
|
bool stop_;
|
||||||
|
|
||||||
scoped_ptr<I420VideoFrame> captured_frame_;
|
scoped_ptr<I420VideoFrame> captured_frame_;
|
||||||
scoped_ptr<I420VideoFrame> deliver_frame_;
|
scoped_ptr<I420VideoFrame> deliver_frame_;
|
||||||
|
|
||||||
|
@ -1703,7 +1703,6 @@ int32_t ViEChannel::StopDecodeThread() {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
decode_thread_->SetNotAlive();
|
|
||||||
if (decode_thread_->Stop()) {
|
if (decode_thread_->Stop()) {
|
||||||
delete decode_thread_;
|
delete decode_thread_;
|
||||||
} else {
|
} else {
|
||||||
|
@ -185,7 +185,6 @@ ThreadTest::~ThreadTest()
|
|||||||
{
|
{
|
||||||
if (_thread)
|
if (_thread)
|
||||||
{
|
{
|
||||||
_thread->SetNotAlive();
|
|
||||||
if (_thread->Stop())
|
if (_thread->Stop())
|
||||||
{
|
{
|
||||||
delete _thread;
|
delete _thread;
|
||||||
@ -272,7 +271,6 @@ bool ThreadTest::Process()
|
|||||||
"sending instance started from thread");
|
"sending instance started from thread");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
_thread->SetNotAlive();
|
|
||||||
_thread->Stop();
|
_thread->Stop();
|
||||||
|
|
||||||
//res = veData1.jvm->DetachCurrentThread();
|
//res = veData1.jvm->DetachCurrentThread();
|
||||||
|
@ -38,7 +38,6 @@ FakeExternalTransport::FakeExternalTransport(webrtc::VoENetwork* ptr)
|
|||||||
|
|
||||||
FakeExternalTransport::~FakeExternalTransport() {
|
FakeExternalTransport::~FakeExternalTransport() {
|
||||||
if (thread_) {
|
if (thread_) {
|
||||||
thread_->SetNotAlive();
|
|
||||||
event_->Set();
|
event_->Set();
|
||||||
if (thread_->Stop()) {
|
if (thread_->Stop()) {
|
||||||
delete thread_;
|
delete thread_;
|
||||||
|
Loading…
Reference in New Issue
Block a user