Use scoped_ptr for ThreadWrapper::CreateThread.
BUG= R=henrika@webrtc.org, pbos@webrtc.org Review URL: https://webrtc-codereview.appspot.com/45799004 Cr-Commit-Position: refs/heads/master@{#8794} git-svn-id: http://webrtc.googlecode.com/svn/trunk@8794 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
@@ -531,39 +531,41 @@ void APITest::Perform() {
|
||||
//--- THREADS
|
||||
// A
|
||||
// PUSH
|
||||
ThreadWrapper* myPushAudioThreadA = ThreadWrapper::CreateThread(
|
||||
PushAudioThreadA, this, kNormalPriority, "PushAudioThreadA");
|
||||
rtc::scoped_ptr<ThreadWrapper> myPushAudioThreadA =
|
||||
ThreadWrapper::CreateThread(PushAudioThreadA, this, kNormalPriority,
|
||||
"PushAudioThreadA");
|
||||
CHECK_THREAD_NULLITY(myPushAudioThreadA, "Unable to start A::PUSH thread");
|
||||
// PULL
|
||||
ThreadWrapper* myPullAudioThreadA = ThreadWrapper::CreateThread(
|
||||
PullAudioThreadA, this, kNormalPriority, "PullAudioThreadA");
|
||||
rtc::scoped_ptr<ThreadWrapper> myPullAudioThreadA =
|
||||
ThreadWrapper::CreateThread(PullAudioThreadA, this, kNormalPriority,
|
||||
"PullAudioThreadA");
|
||||
CHECK_THREAD_NULLITY(myPullAudioThreadA, "Unable to start A::PULL thread");
|
||||
// Process
|
||||
ThreadWrapper* myProcessThreadA = ThreadWrapper::CreateThread(
|
||||
rtc::scoped_ptr<ThreadWrapper> myProcessThreadA = ThreadWrapper::CreateThread(
|
||||
ProcessThreadA, this, kNormalPriority, "ProcessThreadA");
|
||||
CHECK_THREAD_NULLITY(myProcessThreadA, "Unable to start A::Process thread");
|
||||
// API
|
||||
ThreadWrapper* myAPIThreadA = ThreadWrapper::CreateThread(APIThreadA, this,
|
||||
kNormalPriority,
|
||||
"APIThreadA");
|
||||
rtc::scoped_ptr<ThreadWrapper> myAPIThreadA = ThreadWrapper::CreateThread(
|
||||
APIThreadA, this, kNormalPriority, "APIThreadA");
|
||||
CHECK_THREAD_NULLITY(myAPIThreadA, "Unable to start A::API thread");
|
||||
// B
|
||||
// PUSH
|
||||
ThreadWrapper* myPushAudioThreadB = ThreadWrapper::CreateThread(
|
||||
PushAudioThreadB, this, kNormalPriority, "PushAudioThreadB");
|
||||
rtc::scoped_ptr<ThreadWrapper> myPushAudioThreadB =
|
||||
ThreadWrapper::CreateThread(PushAudioThreadB, this, kNormalPriority,
|
||||
"PushAudioThreadB");
|
||||
CHECK_THREAD_NULLITY(myPushAudioThreadB, "Unable to start B::PUSH thread");
|
||||
// PULL
|
||||
ThreadWrapper* myPullAudioThreadB = ThreadWrapper::CreateThread(
|
||||
PullAudioThreadB, this, kNormalPriority, "PullAudioThreadB");
|
||||
rtc::scoped_ptr<ThreadWrapper> myPullAudioThreadB =
|
||||
ThreadWrapper::CreateThread(PullAudioThreadB, this, kNormalPriority,
|
||||
"PullAudioThreadB");
|
||||
CHECK_THREAD_NULLITY(myPullAudioThreadB, "Unable to start B::PULL thread");
|
||||
// Process
|
||||
ThreadWrapper* myProcessThreadB = ThreadWrapper::CreateThread(
|
||||
rtc::scoped_ptr<ThreadWrapper> myProcessThreadB = ThreadWrapper::CreateThread(
|
||||
ProcessThreadB, this, kNormalPriority, "ProcessThreadB");
|
||||
CHECK_THREAD_NULLITY(myProcessThreadB, "Unable to start B::Process thread");
|
||||
// API
|
||||
ThreadWrapper* myAPIThreadB = ThreadWrapper::CreateThread(APIThreadB, this,
|
||||
kNormalPriority,
|
||||
"APIThreadB");
|
||||
rtc::scoped_ptr<ThreadWrapper> myAPIThreadB = ThreadWrapper::CreateThread(
|
||||
APIThreadB, this, kNormalPriority, "APIThreadB");
|
||||
CHECK_THREAD_NULLITY(myAPIThreadB, "Unable to start B::API thread");
|
||||
|
||||
//_apiEventA->StartTimer(true, 5000);
|
||||
@@ -603,20 +605,10 @@ void APITest::Perform() {
|
||||
myProcessThreadA->Stop();
|
||||
myAPIThreadA->Stop();
|
||||
|
||||
delete myPushAudioThreadA;
|
||||
delete myPullAudioThreadA;
|
||||
delete myProcessThreadA;
|
||||
delete myAPIThreadA;
|
||||
|
||||
myPushAudioThreadB->Stop();
|
||||
myPullAudioThreadB->Stop();
|
||||
myProcessThreadB->Stop();
|
||||
myAPIThreadB->Stop();
|
||||
|
||||
delete myPushAudioThreadB;
|
||||
delete myPullAudioThreadB;
|
||||
delete myProcessThreadB;
|
||||
delete myAPIThreadB;
|
||||
}
|
||||
|
||||
void APITest::CheckVADStatus(char side) {
|
||||
|
||||
@@ -470,10 +470,8 @@ void OpenSlesInput::RecorderSimpleBufferQueueCallbackHandler(
|
||||
}
|
||||
|
||||
bool OpenSlesInput::StartCbThreads() {
|
||||
rec_thread_.reset(ThreadWrapper::CreateThread(CbThread,
|
||||
this,
|
||||
kRealtimePriority,
|
||||
"opensl_rec_thread"));
|
||||
rec_thread_ = ThreadWrapper::CreateThread(CbThread, this, kRealtimePriority,
|
||||
"opensl_rec_thread");
|
||||
assert(rec_thread_.get());
|
||||
if (!rec_thread_->Start()) {
|
||||
assert(false);
|
||||
|
||||
@@ -510,10 +510,8 @@ void OpenSlesOutput::PlayerSimpleBufferQueueCallbackHandler(
|
||||
}
|
||||
|
||||
bool OpenSlesOutput::StartCbThreads() {
|
||||
play_thread_.reset(ThreadWrapper::CreateThread(CbThread,
|
||||
this,
|
||||
kRealtimePriority,
|
||||
"opensl_play_thread"));
|
||||
play_thread_ = ThreadWrapper::CreateThread(CbThread, this, kRealtimePriority,
|
||||
"opensl_play_thread");
|
||||
assert(play_thread_.get());
|
||||
OPENSL_RETURN_ON_FAILURE(
|
||||
(*sles_player_itf_)->SetPlayState(sles_player_itf_,
|
||||
|
||||
@@ -35,8 +35,6 @@ FileAudioDevice::FileAudioDevice(const int32_t id,
|
||||
_recordingBufferSizeIn10MS(0),
|
||||
_recordingFramesIn10MS(0),
|
||||
_playoutFramesIn10MS(0),
|
||||
_ptrThreadRec(NULL),
|
||||
_ptrThreadPlay(NULL),
|
||||
_playing(false),
|
||||
_recording(false),
|
||||
_lastCallPlayoutMillis(0),
|
||||
@@ -212,12 +210,6 @@ int32_t FileAudioDevice::StartPlayout() {
|
||||
this,
|
||||
kRealtimePriority,
|
||||
threadName);
|
||||
if (_ptrThreadPlay == NULL) {
|
||||
_playing = false;
|
||||
delete [] _playoutBuffer;
|
||||
_playoutBuffer = NULL;
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (!_outputFilename.empty() && _outputFile.OpenFile(
|
||||
_outputFilename.c_str(), false, false, false) == -1) {
|
||||
@@ -229,9 +221,8 @@ int32_t FileAudioDevice::StartPlayout() {
|
||||
}
|
||||
|
||||
if (!_ptrThreadPlay->Start()) {
|
||||
_ptrThreadPlay.reset();
|
||||
_playing = false;
|
||||
delete _ptrThreadPlay;
|
||||
_ptrThreadPlay = NULL;
|
||||
delete [] _playoutBuffer;
|
||||
_playoutBuffer = NULL;
|
||||
return -1;
|
||||
@@ -247,11 +238,9 @@ int32_t FileAudioDevice::StopPlayout() {
|
||||
}
|
||||
|
||||
// stop playout thread first
|
||||
if (_ptrThreadPlay && !_ptrThreadPlay->Stop()) {
|
||||
return -1;
|
||||
} else {
|
||||
delete _ptrThreadPlay;
|
||||
_ptrThreadPlay = NULL;
|
||||
if (_ptrThreadPlay) {
|
||||
_ptrThreadPlay->Stop();
|
||||
_ptrThreadPlay.reset();
|
||||
}
|
||||
|
||||
CriticalSectionScoped lock(&_critSect);
|
||||
@@ -296,17 +285,10 @@ int32_t FileAudioDevice::StartRecording() {
|
||||
this,
|
||||
kRealtimePriority,
|
||||
threadName);
|
||||
if (_ptrThreadRec == NULL) {
|
||||
_recording = false;
|
||||
delete [] _recordingBuffer;
|
||||
_recordingBuffer = NULL;
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (!_ptrThreadRec->Start()) {
|
||||
_ptrThreadRec.reset();
|
||||
_recording = false;
|
||||
delete _ptrThreadRec;
|
||||
_ptrThreadRec = NULL;
|
||||
delete [] _recordingBuffer;
|
||||
_recordingBuffer = NULL;
|
||||
return -1;
|
||||
@@ -322,11 +304,9 @@ int32_t FileAudioDevice::StopRecording() {
|
||||
_recording = false;
|
||||
}
|
||||
|
||||
if (_ptrThreadRec && !_ptrThreadRec->Stop()) {
|
||||
return -1;
|
||||
} else {
|
||||
delete _ptrThreadRec;
|
||||
_ptrThreadRec = NULL;
|
||||
if (_ptrThreadRec) {
|
||||
_ptrThreadRec->Stop();
|
||||
_ptrThreadRec.reset();
|
||||
}
|
||||
|
||||
CriticalSectionScoped lock(&_critSect);
|
||||
|
||||
@@ -178,8 +178,8 @@ class FileAudioDevice : public AudioDeviceGeneric {
|
||||
uint32_t _recordingFramesIn10MS;
|
||||
uint32_t _playoutFramesIn10MS;
|
||||
|
||||
ThreadWrapper* _ptrThreadRec;
|
||||
ThreadWrapper* _ptrThreadPlay;
|
||||
rtc::scoped_ptr<ThreadWrapper> _ptrThreadRec;
|
||||
rtc::scoped_ptr<ThreadWrapper> _ptrThreadPlay;
|
||||
|
||||
bool _playing;
|
||||
bool _recording;
|
||||
|
||||
@@ -15,10 +15,9 @@
|
||||
|
||||
#include "webrtc/modules/audio_device/audio_device_generic.h"
|
||||
#include "webrtc/system_wrappers/interface/critical_section_wrapper.h"
|
||||
#include "webrtc/system_wrappers/interface/thread_wrapper.h"
|
||||
|
||||
namespace webrtc {
|
||||
class ThreadWrapper;
|
||||
|
||||
const uint32_t N_REC_SAMPLES_PER_SEC = 44000;
|
||||
const uint32_t N_PLAY_SAMPLES_PER_SEC = 44000;
|
||||
|
||||
@@ -214,7 +213,7 @@ class AudioDeviceIOS : public AudioDeviceGeneric {
|
||||
|
||||
CriticalSectionWrapper& _critSect;
|
||||
|
||||
ThreadWrapper* _captureWorkerThread;
|
||||
rtc::scoped_ptr<ThreadWrapper> _captureWorkerThread;
|
||||
|
||||
int32_t _id;
|
||||
|
||||
|
||||
@@ -13,7 +13,6 @@
|
||||
|
||||
#include "webrtc/modules/audio_device/ios/audio_device_ios.h"
|
||||
|
||||
#include "webrtc/system_wrappers/interface/thread_wrapper.h"
|
||||
#include "webrtc/system_wrappers/interface/trace.h"
|
||||
|
||||
namespace webrtc {
|
||||
@@ -21,7 +20,6 @@ AudioDeviceIOS::AudioDeviceIOS(const int32_t id)
|
||||
:
|
||||
_ptrAudioBuffer(NULL),
|
||||
_critSect(*CriticalSectionWrapper::CreateCriticalSection()),
|
||||
_captureWorkerThread(NULL),
|
||||
_id(id),
|
||||
_auVoiceProcessing(NULL),
|
||||
_audioInterruptionObserver(NULL),
|
||||
@@ -108,17 +106,10 @@ int32_t AudioDeviceIOS::Init() {
|
||||
_isShutDown = false;
|
||||
|
||||
// Create and start capture thread
|
||||
if (_captureWorkerThread == NULL) {
|
||||
if (!_captureWorkerThread) {
|
||||
_captureWorkerThread
|
||||
= ThreadWrapper::CreateThread(RunCapture, this, kRealtimePriority,
|
||||
"CaptureWorkerThread");
|
||||
|
||||
if (_captureWorkerThread == NULL) {
|
||||
WEBRTC_TRACE(kTraceCritical, kTraceAudioDevice,
|
||||
_id, "CreateThread() error");
|
||||
return -1;
|
||||
}
|
||||
|
||||
bool res = _captureWorkerThread->Start();
|
||||
WEBRTC_TRACE(kTraceDebug, kTraceAudioDevice,
|
||||
_id, "CaptureWorkerThread started (res=%d)", res);
|
||||
@@ -146,14 +137,13 @@ int32_t AudioDeviceIOS::Terminate() {
|
||||
|
||||
|
||||
// Stop capture thread
|
||||
if (_captureWorkerThread != NULL) {
|
||||
if (_captureWorkerThread) {
|
||||
WEBRTC_TRACE(kTraceDebug, kTraceAudioDevice,
|
||||
_id, "Stopping CaptureWorkerThread");
|
||||
bool res = _captureWorkerThread->Stop();
|
||||
WEBRTC_TRACE(kTraceDebug, kTraceAudioDevice,
|
||||
_id, "CaptureWorkerThread stopped (res=%d)", res);
|
||||
delete _captureWorkerThread;
|
||||
_captureWorkerThread = NULL;
|
||||
_captureWorkerThread.reset();
|
||||
}
|
||||
|
||||
// Shut down Audio Unit
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
|
||||
#include "webrtc/system_wrappers/interface/event_wrapper.h"
|
||||
#include "webrtc/system_wrappers/interface/sleep.h"
|
||||
#include "webrtc/system_wrappers/interface/thread_wrapper.h"
|
||||
#include "webrtc/system_wrappers/interface/trace.h"
|
||||
|
||||
webrtc_adm_linux_alsa::AlsaSymbolTable AlsaSymbolTable;
|
||||
@@ -64,8 +63,6 @@ static const unsigned int ALSA_CAPTURE_WAIT_TIMEOUT = 5; // in ms
|
||||
AudioDeviceLinuxALSA::AudioDeviceLinuxALSA(const int32_t id) :
|
||||
_ptrAudioBuffer(NULL),
|
||||
_critSect(*CriticalSectionWrapper::CreateCriticalSection()),
|
||||
_ptrThreadRec(NULL),
|
||||
_ptrThreadPlay(NULL),
|
||||
_id(id),
|
||||
_mixerManager(id),
|
||||
_inputDeviceIndex(0),
|
||||
@@ -199,7 +196,6 @@ int32_t AudioDeviceLinuxALSA::Init()
|
||||
|
||||
int32_t AudioDeviceLinuxALSA::Terminate()
|
||||
{
|
||||
|
||||
if (!_initialized)
|
||||
{
|
||||
return 0;
|
||||
@@ -212,19 +208,11 @@ int32_t AudioDeviceLinuxALSA::Terminate()
|
||||
// RECORDING
|
||||
if (_ptrThreadRec)
|
||||
{
|
||||
ThreadWrapper* tmpThread = _ptrThreadRec;
|
||||
_ptrThreadRec = NULL;
|
||||
ThreadWrapper* tmpThread = _ptrThreadRec.release();
|
||||
_critSect.Leave();
|
||||
|
||||
if (tmpThread->Stop())
|
||||
{
|
||||
tmpThread->Stop();
|
||||
delete tmpThread;
|
||||
}
|
||||
else
|
||||
{
|
||||
WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, _id,
|
||||
" failed to close down the rec audio thread");
|
||||
}
|
||||
|
||||
_critSect.Enter();
|
||||
}
|
||||
@@ -232,19 +220,11 @@ int32_t AudioDeviceLinuxALSA::Terminate()
|
||||
// PLAYOUT
|
||||
if (_ptrThreadPlay)
|
||||
{
|
||||
ThreadWrapper* tmpThread = _ptrThreadPlay;
|
||||
_ptrThreadPlay = NULL;
|
||||
ThreadWrapper* tmpThread = _ptrThreadPlay.release();
|
||||
_critSect.Leave();
|
||||
|
||||
if (tmpThread->Stop())
|
||||
{
|
||||
tmpThread->Stop();
|
||||
delete tmpThread;
|
||||
}
|
||||
else
|
||||
{
|
||||
WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, _id,
|
||||
" failed to close down the play audio thread");
|
||||
}
|
||||
|
||||
_critSect.Enter();
|
||||
}
|
||||
@@ -1389,23 +1369,13 @@ int32_t AudioDeviceLinuxALSA::StartRecording()
|
||||
this,
|
||||
kRealtimePriority,
|
||||
threadName);
|
||||
if (_ptrThreadRec == NULL)
|
||||
{
|
||||
WEBRTC_TRACE(kTraceCritical, kTraceAudioDevice, _id,
|
||||
" failed to create the rec audio thread");
|
||||
_recording = false;
|
||||
delete [] _recordingBuffer;
|
||||
_recordingBuffer = NULL;
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (!_ptrThreadRec->Start())
|
||||
{
|
||||
WEBRTC_TRACE(kTraceCritical, kTraceAudioDevice, _id,
|
||||
" failed to start the rec audio thread");
|
||||
_recording = false;
|
||||
delete _ptrThreadRec;
|
||||
_ptrThreadRec = NULL;
|
||||
_ptrThreadRec.reset();
|
||||
delete [] _recordingBuffer;
|
||||
_recordingBuffer = NULL;
|
||||
return -1;
|
||||
@@ -1462,15 +1432,10 @@ int32_t AudioDeviceLinuxALSA::StopRecording()
|
||||
_recording = false;
|
||||
}
|
||||
|
||||
if (_ptrThreadRec && !_ptrThreadRec->Stop())
|
||||
if (_ptrThreadRec)
|
||||
{
|
||||
WEBRTC_TRACE(kTraceError, kTraceAudioDevice, _id,
|
||||
" failed to stop the rec audio thread");
|
||||
return -1;
|
||||
}
|
||||
else {
|
||||
delete _ptrThreadRec;
|
||||
_ptrThreadRec = NULL;
|
||||
_ptrThreadRec->Stop();
|
||||
_ptrThreadRec.reset();
|
||||
}
|
||||
|
||||
CriticalSectionScoped lock(&_critSect);
|
||||
@@ -1559,23 +1524,12 @@ int32_t AudioDeviceLinuxALSA::StartPlayout()
|
||||
this,
|
||||
kRealtimePriority,
|
||||
threadName);
|
||||
if (_ptrThreadPlay == NULL)
|
||||
{
|
||||
WEBRTC_TRACE(kTraceCritical, kTraceAudioDevice, _id,
|
||||
" failed to create the play audio thread");
|
||||
_playing = false;
|
||||
delete [] _playoutBuffer;
|
||||
_playoutBuffer = NULL;
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (!_ptrThreadPlay->Start())
|
||||
{
|
||||
WEBRTC_TRACE(kTraceCritical, kTraceAudioDevice, _id,
|
||||
" failed to start the play audio thread");
|
||||
_playing = false;
|
||||
delete _ptrThreadPlay;
|
||||
_ptrThreadPlay = NULL;
|
||||
_ptrThreadPlay.reset();
|
||||
delete [] _playoutBuffer;
|
||||
_playoutBuffer = NULL;
|
||||
return -1;
|
||||
@@ -1614,15 +1568,10 @@ int32_t AudioDeviceLinuxALSA::StopPlayout()
|
||||
}
|
||||
|
||||
// stop playout thread first
|
||||
if (_ptrThreadPlay && !_ptrThreadPlay->Stop())
|
||||
if (_ptrThreadPlay)
|
||||
{
|
||||
WEBRTC_TRACE(kTraceError, kTraceAudioDevice, _id,
|
||||
" failed to stop the play audio thread");
|
||||
return -1;
|
||||
}
|
||||
else {
|
||||
delete _ptrThreadPlay;
|
||||
_ptrThreadPlay = NULL;
|
||||
_ptrThreadPlay->Stop();
|
||||
_ptrThreadPlay.reset();
|
||||
}
|
||||
|
||||
CriticalSectionScoped lock(&_critSect);
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
#include "webrtc/modules/audio_device/audio_device_generic.h"
|
||||
#include "webrtc/modules/audio_device/linux/audio_mixer_manager_alsa_linux.h"
|
||||
#include "webrtc/system_wrappers/interface/critical_section_wrapper.h"
|
||||
#include "webrtc/system_wrappers/interface/thread_wrapper.h"
|
||||
|
||||
#if defined(USE_X11)
|
||||
#include <X11/Xlib.h>
|
||||
@@ -26,7 +27,6 @@
|
||||
namespace webrtc
|
||||
{
|
||||
class EventWrapper;
|
||||
class ThreadWrapper;
|
||||
|
||||
class AudioDeviceLinuxALSA : public AudioDeviceGeneric
|
||||
{
|
||||
@@ -185,8 +185,8 @@ private:
|
||||
|
||||
CriticalSectionWrapper& _critSect;
|
||||
|
||||
ThreadWrapper* _ptrThreadRec;
|
||||
ThreadWrapper* _ptrThreadPlay;
|
||||
rtc::scoped_ptr<ThreadWrapper> _ptrThreadRec;
|
||||
rtc::scoped_ptr<ThreadWrapper> _ptrThreadPlay;
|
||||
|
||||
int32_t _id;
|
||||
|
||||
|
||||
@@ -15,7 +15,6 @@
|
||||
#include "webrtc/modules/audio_device/linux/audio_device_pulse_linux.h"
|
||||
|
||||
#include "webrtc/system_wrappers/interface/event_wrapper.h"
|
||||
#include "webrtc/system_wrappers/interface/thread_wrapper.h"
|
||||
#include "webrtc/system_wrappers/interface/trace.h"
|
||||
|
||||
webrtc_adm_linux_pulse::PulseAudioSymbolTable PaSymbolTable;
|
||||
@@ -40,8 +39,6 @@ AudioDeviceLinuxPulse::AudioDeviceLinuxPulse(const int32_t id) :
|
||||
_timeEventPlay(*EventWrapper::Create()),
|
||||
_recStartEvent(*EventWrapper::Create()),
|
||||
_playStartEvent(*EventWrapper::Create()),
|
||||
_ptrThreadPlay(NULL),
|
||||
_ptrThreadRec(NULL),
|
||||
_id(id),
|
||||
_mixerManager(id),
|
||||
_inputDeviceIndex(0),
|
||||
@@ -212,20 +209,12 @@ int32_t AudioDeviceLinuxPulse::Init()
|
||||
const char* threadName = "webrtc_audio_module_rec_thread";
|
||||
_ptrThreadRec = ThreadWrapper::CreateThread(RecThreadFunc, this,
|
||||
kRealtimePriority, threadName);
|
||||
if (_ptrThreadRec == NULL)
|
||||
{
|
||||
WEBRTC_TRACE(kTraceCritical, kTraceAudioDevice, _id,
|
||||
" failed to create the rec audio thread");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (!_ptrThreadRec->Start())
|
||||
{
|
||||
WEBRTC_TRACE(kTraceCritical, kTraceAudioDevice, _id,
|
||||
" failed to start the rec audio thread");
|
||||
|
||||
delete _ptrThreadRec;
|
||||
_ptrThreadRec = NULL;
|
||||
_ptrThreadRec.reset();
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -233,20 +222,12 @@ int32_t AudioDeviceLinuxPulse::Init()
|
||||
threadName = "webrtc_audio_module_play_thread";
|
||||
_ptrThreadPlay = ThreadWrapper::CreateThread(PlayThreadFunc, this,
|
||||
kRealtimePriority, threadName);
|
||||
if (_ptrThreadPlay == NULL)
|
||||
{
|
||||
WEBRTC_TRACE(kTraceCritical, kTraceAudioDevice, _id,
|
||||
" failed to create the play audio thread");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (!_ptrThreadPlay->Start())
|
||||
{
|
||||
WEBRTC_TRACE(kTraceCritical, kTraceAudioDevice, _id,
|
||||
" failed to start the play audio thread");
|
||||
|
||||
delete _ptrThreadPlay;
|
||||
_ptrThreadPlay = NULL;
|
||||
_ptrThreadPlay.reset();
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -270,19 +251,12 @@ int32_t AudioDeviceLinuxPulse::Terminate()
|
||||
// RECORDING
|
||||
if (_ptrThreadRec)
|
||||
{
|
||||
ThreadWrapper* tmpThread = _ptrThreadRec;
|
||||
_ptrThreadRec = NULL;
|
||||
ThreadWrapper* tmpThread = _ptrThreadRec.release();
|
||||
UnLock();
|
||||
|
||||
_timeEventRec.Set();
|
||||
if (tmpThread->Stop())
|
||||
{
|
||||
tmpThread->Stop();
|
||||
delete tmpThread;
|
||||
} else
|
||||
{
|
||||
WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, _id,
|
||||
" failed to close down the rec audio thread");
|
||||
}
|
||||
// Lock again since we need to protect _ptrThreadPlay.
|
||||
Lock();
|
||||
}
|
||||
@@ -290,19 +264,12 @@ int32_t AudioDeviceLinuxPulse::Terminate()
|
||||
// PLAYOUT
|
||||
if (_ptrThreadPlay)
|
||||
{
|
||||
ThreadWrapper* tmpThread = _ptrThreadPlay;
|
||||
_ptrThreadPlay = NULL;
|
||||
ThreadWrapper* tmpThread = _ptrThreadPlay.release();
|
||||
_critSect.Leave();
|
||||
|
||||
_timeEventPlay.Set();
|
||||
if (tmpThread->Stop())
|
||||
{
|
||||
tmpThread->Stop();
|
||||
delete tmpThread;
|
||||
} else
|
||||
{
|
||||
WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, _id,
|
||||
" failed to close down the play audio thread");
|
||||
}
|
||||
} else {
|
||||
UnLock();
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
#include "webrtc/modules/audio_device/audio_device_generic.h"
|
||||
#include "webrtc/modules/audio_device/linux/audio_mixer_manager_pulse_linux.h"
|
||||
#include "webrtc/system_wrappers/interface/critical_section_wrapper.h"
|
||||
#include "webrtc/system_wrappers/interface/thread_wrapper.h"
|
||||
|
||||
#include <X11/Xlib.h>
|
||||
#include <pulse/pulseaudio.h>
|
||||
@@ -87,7 +88,6 @@ const uint32_t WEBRTC_PA_CAPTURE_BUFFER_LATENCY_ADJUSTMENT = 0;
|
||||
namespace webrtc
|
||||
{
|
||||
class EventWrapper;
|
||||
class ThreadWrapper;
|
||||
|
||||
class AudioDeviceLinuxPulse: public AudioDeviceGeneric
|
||||
{
|
||||
@@ -288,8 +288,8 @@ private:
|
||||
EventWrapper& _recStartEvent;
|
||||
EventWrapper& _playStartEvent;
|
||||
|
||||
ThreadWrapper* _ptrThreadPlay;
|
||||
ThreadWrapper* _ptrThreadRec;
|
||||
rtc::scoped_ptr<ThreadWrapper> _ptrThreadPlay;
|
||||
rtc::scoped_ptr<ThreadWrapper> _ptrThreadRec;
|
||||
int32_t _id;
|
||||
|
||||
AudioMixerManagerLinuxPulse _mixerManager;
|
||||
|
||||
@@ -1754,9 +1754,9 @@ int32_t AudioDeviceMac::StartRecording()
|
||||
}
|
||||
|
||||
DCHECK(!capture_worker_thread_.get());
|
||||
capture_worker_thread_.reset(
|
||||
capture_worker_thread_ =
|
||||
ThreadWrapper::CreateThread(RunCapture, this, kRealtimePriority,
|
||||
"CaptureWorkerThread"));
|
||||
"CaptureWorkerThread");
|
||||
DCHECK(capture_worker_thread_.get());
|
||||
capture_worker_thread_->Start();
|
||||
|
||||
@@ -1909,9 +1909,9 @@ int32_t AudioDeviceMac::StartPlayout()
|
||||
}
|
||||
|
||||
DCHECK(!render_worker_thread_.get());
|
||||
render_worker_thread_.reset(
|
||||
render_worker_thread_ =
|
||||
ThreadWrapper::CreateThread(RunRender, this, kRealtimePriority,
|
||||
"RenderWorkerThread"));
|
||||
"RenderWorkerThread");
|
||||
render_worker_thread_->Start();
|
||||
|
||||
if (_twoDevices || !_recording)
|
||||
|
||||
@@ -13,7 +13,6 @@
|
||||
#include "webrtc/modules/audio_device/win/audio_device_wave_win.h"
|
||||
|
||||
#include "webrtc/system_wrappers/interface/event_wrapper.h"
|
||||
#include "webrtc/system_wrappers/interface/thread_wrapper.h"
|
||||
#include "webrtc/system_wrappers/interface/trace.h"
|
||||
|
||||
#include <windows.h>
|
||||
@@ -56,7 +55,6 @@ AudioDeviceWindowsWave::AudioDeviceWindowsWave(const int32_t id) :
|
||||
_hSetCaptureVolumeThread(NULL),
|
||||
_hShutdownSetVolumeEvent(NULL),
|
||||
_hSetCaptureVolumeEvent(NULL),
|
||||
_ptrThread(NULL),
|
||||
_critSectCb(*CriticalSectionWrapper::CreateCriticalSection()),
|
||||
_id(id),
|
||||
_mixerManager(id),
|
||||
@@ -234,19 +232,11 @@ int32_t AudioDeviceWindowsWave::Init()
|
||||
this,
|
||||
kRealtimePriority,
|
||||
threadName);
|
||||
if (_ptrThread == NULL)
|
||||
{
|
||||
WEBRTC_TRACE(kTraceCritical, kTraceAudioDevice, _id,
|
||||
"failed to create the audio thread");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (!_ptrThread->Start())
|
||||
{
|
||||
WEBRTC_TRACE(kTraceCritical, kTraceAudioDevice, _id,
|
||||
"failed to start the audio thread");
|
||||
delete _ptrThread;
|
||||
_ptrThread = NULL;
|
||||
_ptrThread.reset();
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -255,16 +245,8 @@ int32_t AudioDeviceWindowsWave::Init()
|
||||
{
|
||||
WEBRTC_TRACE(kTraceCritical, kTraceAudioDevice, _id,
|
||||
"failed to start the timer event");
|
||||
if (_ptrThread->Stop())
|
||||
{
|
||||
delete _ptrThread;
|
||||
_ptrThread = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, _id,
|
||||
"unable to stop the activated thread");
|
||||
}
|
||||
_ptrThread->Stop();
|
||||
_ptrThread.reset();
|
||||
return -1;
|
||||
}
|
||||
WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id,
|
||||
@@ -323,25 +305,15 @@ int32_t AudioDeviceWindowsWave::Terminate()
|
||||
|
||||
if (_ptrThread)
|
||||
{
|
||||
ThreadWrapper* tmpThread = _ptrThread;
|
||||
_ptrThread = NULL;
|
||||
ThreadWrapper* tmpThread = _ptrThread.release();
|
||||
_critSect.Leave();
|
||||
|
||||
_timeEvent.Set();
|
||||
|
||||
if (tmpThread->Stop())
|
||||
{
|
||||
tmpThread->Stop();
|
||||
delete tmpThread;
|
||||
}
|
||||
else
|
||||
{
|
||||
_critSect.Leave();
|
||||
WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, _id,
|
||||
"failed to close down the audio thread");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_critSect.Leave();
|
||||
}
|
||||
|
||||
@@ -13,12 +13,12 @@
|
||||
|
||||
#include "webrtc/modules/audio_device/audio_device_generic.h"
|
||||
#include "webrtc/modules/audio_device/win/audio_mixer_manager_win.h"
|
||||
#include "webrtc/system_wrappers/interface/thread_wrapper.h"
|
||||
|
||||
#pragma comment( lib, "winmm.lib" )
|
||||
|
||||
namespace webrtc {
|
||||
class EventWrapper;
|
||||
class ThreadWrapper;
|
||||
|
||||
const uint32_t TIMER_PERIOD_MS = 2;
|
||||
const uint32_t REC_CHECK_TIME_PERIOD_MS = 4;
|
||||
@@ -221,7 +221,7 @@ private:
|
||||
HANDLE _hShutdownSetVolumeEvent;
|
||||
HANDLE _hSetCaptureVolumeEvent;
|
||||
|
||||
ThreadWrapper* _ptrThread;
|
||||
rtc::scoped_ptr<ThreadWrapper> _ptrThread;
|
||||
|
||||
CriticalSectionWrapper& _critSectCb;
|
||||
|
||||
|
||||
@@ -22,7 +22,6 @@
|
||||
|
||||
#include "webrtc/system_wrappers/interface/critical_section_wrapper.h"
|
||||
#include "webrtc/system_wrappers/interface/event_wrapper.h"
|
||||
#include "webrtc/system_wrappers/interface/thread_wrapper.h"
|
||||
#include "webrtc/system_wrappers/interface/tick_util.h"
|
||||
|
||||
using namespace webrtc;
|
||||
@@ -891,22 +890,14 @@ MatlabEngine::MatlabEngine()
|
||||
:
|
||||
_critSect(CriticalSectionWrapper::CreateCriticalSection()),
|
||||
_eventPtr(NULL),
|
||||
_plotThread(NULL),
|
||||
_running(false),
|
||||
_numPlots(0)
|
||||
{
|
||||
_eventPtr = EventWrapper::Create();
|
||||
|
||||
_plotThread = ThreadWrapper::CreateThread(MatlabEngine::PlotThread, this, kLowPriority, "MatlabPlot");
|
||||
|
||||
if (_plotThread == NULL)
|
||||
{
|
||||
throw "Unable to start MatlabEngine thread";
|
||||
exit(1);
|
||||
}
|
||||
|
||||
_plotThread = ThreadWrapper::CreateThread(MatlabEngine::PlotThread, this,
|
||||
kLowPriority, "MatlabPlot");
|
||||
_running = true;
|
||||
|
||||
_plotThread->Start();
|
||||
}
|
||||
|
||||
@@ -919,18 +910,11 @@ MatlabEngine::~MatlabEngine()
|
||||
_running = false;
|
||||
_eventPtr->Set();
|
||||
|
||||
while (!_plotThread->Stop())
|
||||
{
|
||||
;
|
||||
}
|
||||
|
||||
delete _plotThread;
|
||||
_plotThread->Stop();
|
||||
}
|
||||
|
||||
_plots.clear();
|
||||
|
||||
_plotThread = NULL;
|
||||
|
||||
delete _eventPtr;
|
||||
_eventPtr = NULL;
|
||||
|
||||
|
||||
@@ -16,11 +16,11 @@
|
||||
#include <vector>
|
||||
|
||||
#include "webrtc/typedefs.h"
|
||||
#include "webrtc/system_wrappers/interface/thread_wrapper.h"
|
||||
|
||||
namespace webrtc {
|
||||
class CriticalSectionWrapper;
|
||||
class EventWrapper;
|
||||
class ThreadWrapper;
|
||||
}
|
||||
|
||||
//#define PLOT_TESTING
|
||||
@@ -160,7 +160,7 @@ private:
|
||||
std::vector<MatlabPlot *> _plots;
|
||||
webrtc::CriticalSectionWrapper *_critSect;
|
||||
webrtc::EventWrapper *_eventPtr;
|
||||
webrtc::ThreadWrapper* _plotThread;
|
||||
rtc::scoped_ptr<webrtc::ThreadWrapper> _plotThread;
|
||||
bool _running;
|
||||
int _numPlots;
|
||||
};
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
#include "webrtc/modules/rtp_rtcp/test/BWEStandAlone/TestSenderReceiver.h"
|
||||
#include "webrtc/system_wrappers/interface/critical_section_wrapper.h"
|
||||
#include "webrtc/system_wrappers/interface/event_wrapper.h"
|
||||
#include "webrtc/system_wrappers/interface/thread_wrapper.h"
|
||||
#include "webrtc/system_wrappers/interface/tick_util.h"
|
||||
|
||||
|
||||
@@ -37,7 +36,6 @@ TestLoadGenerator::TestLoadGenerator(TestSenderReceiver *sender, int32_t rtpSamp
|
||||
:
|
||||
_critSect(CriticalSectionWrapper::CreateCriticalSection()),
|
||||
_eventPtr(NULL),
|
||||
_genThread(NULL),
|
||||
_bitrateKbps(0),
|
||||
_sender(sender),
|
||||
_running(false),
|
||||
@@ -78,13 +76,8 @@ int32_t TestLoadGenerator::Start (const char *threadName)
|
||||
|
||||
_eventPtr = EventWrapper::Create();
|
||||
|
||||
_genThread = ThreadWrapper::CreateThread(SenderThreadFunction, this, kRealtimePriority, threadName);
|
||||
if (_genThread == NULL)
|
||||
{
|
||||
throw "Unable to start generator thread";
|
||||
exit(1);
|
||||
}
|
||||
|
||||
_genThread = ThreadWrapper::CreateThread(SenderThreadFunction, this,
|
||||
kRealtimePriority, threadName);
|
||||
_running = true;
|
||||
|
||||
_genThread->Start();
|
||||
@@ -102,20 +95,13 @@ int32_t TestLoadGenerator::Stop ()
|
||||
_running = false;
|
||||
_eventPtr->Set();
|
||||
|
||||
while (!_genThread->Stop())
|
||||
{
|
||||
_critSect.Leave();
|
||||
_critSect.Enter();
|
||||
}
|
||||
|
||||
delete _genThread;
|
||||
_genThread = NULL;
|
||||
_genThread->Stop();
|
||||
_genThread.reset();
|
||||
|
||||
delete _eventPtr;
|
||||
_eventPtr = NULL;
|
||||
}
|
||||
|
||||
_genThread = NULL;
|
||||
_critSect.Leave();
|
||||
return (0);
|
||||
}
|
||||
|
||||
@@ -14,13 +14,13 @@
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "webrtc/modules/interface/module_common_types.h"
|
||||
#include "webrtc/system_wrappers/interface/thread_wrapper.h"
|
||||
#include "webrtc/typedefs.h"
|
||||
|
||||
class TestSenderReceiver;
|
||||
namespace webrtc {
|
||||
class CriticalSectionWrapper;
|
||||
class EventWrapper;
|
||||
class ThreadWrapper;
|
||||
}
|
||||
|
||||
class TestLoadGenerator
|
||||
@@ -44,7 +44,7 @@ protected:
|
||||
|
||||
webrtc::CriticalSectionWrapper* _critSect;
|
||||
webrtc::EventWrapper *_eventPtr;
|
||||
webrtc::ThreadWrapper* _genThread;
|
||||
rtc::scoped_ptr<webrtc::ThreadWrapper> _genThread;
|
||||
int32_t _bitrateKbps;
|
||||
TestSenderReceiver *_sender;
|
||||
bool _running;
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
#include "webrtc/modules/rtp_rtcp/test/BWEStandAlone/TestLoadGenerator.h"
|
||||
#include "webrtc/system_wrappers/interface/critical_section_wrapper.h"
|
||||
#include "webrtc/system_wrappers/interface/event_wrapper.h"
|
||||
#include "webrtc/system_wrappers/interface/thread_wrapper.h"
|
||||
#include "webrtc/system_wrappers/interface/tick_util.h"
|
||||
#include "webrtc/test/channel_transport/udp_transport.h"
|
||||
|
||||
@@ -40,7 +39,6 @@ TestSenderReceiver::TestSenderReceiver (void)
|
||||
:
|
||||
_critSect(CriticalSectionWrapper::CreateCriticalSection()),
|
||||
_eventPtr(NULL),
|
||||
_procThread(NULL),
|
||||
_running(false),
|
||||
_payloadType(0),
|
||||
_loadGenerator(NULL),
|
||||
@@ -165,12 +163,8 @@ int32_t TestSenderReceiver::Start()
|
||||
exit(1);
|
||||
}
|
||||
|
||||
_procThread = ThreadWrapper::CreateThread(ProcThreadFunction, this, kRealtimePriority, "TestSenderReceiver");
|
||||
if (_procThread == NULL)
|
||||
{
|
||||
throw "Unable to create process thread";
|
||||
exit(1);
|
||||
}
|
||||
_procThread = ThreadWrapper::CreateThread(ProcThreadFunction, this,
|
||||
kRealtimePriority, "TestSenderReceiver");
|
||||
|
||||
_running = true;
|
||||
|
||||
@@ -201,18 +195,12 @@ int32_t TestSenderReceiver::Stop ()
|
||||
_running = false;
|
||||
_eventPtr->Set();
|
||||
|
||||
while (!_procThread->Stop())
|
||||
{
|
||||
;
|
||||
}
|
||||
_procThread->Stop();
|
||||
_procThread.reset();
|
||||
|
||||
delete _eventPtr;
|
||||
|
||||
delete _procThread;
|
||||
}
|
||||
|
||||
_procThread = NULL;
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
|
||||
#include "webrtc/modules/rtp_rtcp/interface/rtp_rtcp.h"
|
||||
#include "webrtc/modules/rtp_rtcp/interface/rtp_rtcp_defines.h"
|
||||
#include "webrtc/system_wrappers/interface/thread_wrapper.h"
|
||||
#include "webrtc/test/channel_transport/udp_transport.h"
|
||||
#include "webrtc/typedefs.h"
|
||||
|
||||
@@ -20,7 +21,6 @@ class TestLoadGenerator;
|
||||
namespace webrtc {
|
||||
class CriticalSectionWrapper;
|
||||
class EventWrapper;
|
||||
class ThreadWrapper;
|
||||
}
|
||||
|
||||
using namespace webrtc;
|
||||
@@ -138,7 +138,7 @@ private:
|
||||
UdpTransport* _transport;
|
||||
webrtc::CriticalSectionWrapper* _critSect;
|
||||
webrtc::EventWrapper *_eventPtr;
|
||||
webrtc::ThreadWrapper* _procThread;
|
||||
rtc::scoped_ptr<webrtc::ThreadWrapper> _procThread;
|
||||
bool _running;
|
||||
int8_t _payloadType;
|
||||
TestLoadGenerator* _loadGenerator;
|
||||
|
||||
@@ -69,8 +69,8 @@ void ProcessThreadImpl::Start() {
|
||||
for (ModuleCallback& m : modules_)
|
||||
m.module->ProcessThreadAttached(this);
|
||||
|
||||
thread_.reset(ThreadWrapper::CreateThread(
|
||||
&ProcessThreadImpl::Run, this, kNormalPriority, "ProcessThread"));
|
||||
thread_ = ThreadWrapper::CreateThread(
|
||||
&ProcessThreadImpl::Run, this, kNormalPriority, "ProcessThread");
|
||||
CHECK(thread_->Start());
|
||||
}
|
||||
|
||||
|
||||
@@ -24,7 +24,6 @@
|
||||
#include "webrtc/modules/video_capture/linux/video_capture_linux.h"
|
||||
#include "webrtc/system_wrappers/interface/critical_section_wrapper.h"
|
||||
#include "webrtc/system_wrappers/interface/ref_count.h"
|
||||
#include "webrtc/system_wrappers/interface/thread_wrapper.h"
|
||||
#include "webrtc/system_wrappers/interface/trace.h"
|
||||
|
||||
namespace webrtc
|
||||
@@ -48,7 +47,6 @@ VideoCaptureModule* VideoCaptureImpl::Create(const int32_t id,
|
||||
|
||||
VideoCaptureModuleV4L2::VideoCaptureModuleV4L2(const int32_t id)
|
||||
: VideoCaptureImpl(id),
|
||||
_captureThread(NULL),
|
||||
_captureCritSect(CriticalSectionWrapper::CreateCriticalSection()),
|
||||
_deviceId(-1),
|
||||
_deviceFd(-1),
|
||||
@@ -305,23 +303,14 @@ int32_t VideoCaptureModuleV4L2::StopCapture()
|
||||
{
|
||||
if (_captureThread) {
|
||||
// Make sure the capture thread stop stop using the critsect.
|
||||
if (_captureThread->Stop()) {
|
||||
delete _captureThread;
|
||||
_captureThread = NULL;
|
||||
} else
|
||||
{
|
||||
// Couldn't stop the thread, leak instead of crash.
|
||||
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceVideoCapture, -1,
|
||||
"%s: could not stop capture thread", __FUNCTION__);
|
||||
assert(false);
|
||||
}
|
||||
_captureThread->Stop();
|
||||
_captureThread.reset();
|
||||
}
|
||||
|
||||
CriticalSectionScoped cs(_captureCritSect);
|
||||
if (_captureStarted)
|
||||
{
|
||||
_captureStarted = false;
|
||||
_captureThread = NULL;
|
||||
|
||||
DeAllocateVideoBuffers();
|
||||
close(_deviceFd);
|
||||
|
||||
@@ -13,11 +13,11 @@
|
||||
|
||||
#include "webrtc/common_types.h"
|
||||
#include "webrtc/modules/video_capture/video_capture_impl.h"
|
||||
#include "webrtc/system_wrappers/interface/thread_wrapper.h"
|
||||
|
||||
namespace webrtc
|
||||
{
|
||||
class CriticalSectionWrapper;
|
||||
class ThreadWrapper;
|
||||
namespace videocapturemodule
|
||||
{
|
||||
class VideoCaptureModuleV4L2: public VideoCaptureImpl
|
||||
@@ -39,7 +39,7 @@ private:
|
||||
bool AllocateVideoBuffers();
|
||||
bool DeAllocateVideoBuffers();
|
||||
|
||||
ThreadWrapper* _captureThread;
|
||||
rtc::scoped_ptr<ThreadWrapper> _captureThread;
|
||||
CriticalSectionWrapper* _captureCritSect;
|
||||
|
||||
int32_t _deviceId;
|
||||
|
||||
@@ -13,7 +13,6 @@
|
||||
#include "webrtc/modules/video_render/video_render_internal.h"
|
||||
#include "webrtc/system_wrappers/interface/critical_section_wrapper.h"
|
||||
#include "webrtc/system_wrappers/interface/event_wrapper.h"
|
||||
#include "webrtc/system_wrappers/interface/thread_wrapper.h"
|
||||
#include "webrtc/system_wrappers/interface/tick_util.h"
|
||||
|
||||
#ifdef ANDROID
|
||||
@@ -49,8 +48,7 @@ VideoRenderAndroid::VideoRenderAndroid(
|
||||
_javaShutdownEvent(*EventWrapper::Create()),
|
||||
_javaRenderEvent(*EventWrapper::Create()),
|
||||
_lastJavaRenderEvent(0),
|
||||
_javaRenderJniEnv(NULL),
|
||||
_javaRenderThread(NULL) {
|
||||
_javaRenderJniEnv(NULL) {
|
||||
}
|
||||
|
||||
VideoRenderAndroid::~VideoRenderAndroid() {
|
||||
@@ -146,11 +144,6 @@ int32_t VideoRenderAndroid::StartRender() {
|
||||
_javaRenderThread = ThreadWrapper::CreateThread(JavaRenderThreadFun, this,
|
||||
kRealtimePriority,
|
||||
"AndroidRenderThread");
|
||||
if (!_javaRenderThread) {
|
||||
WEBRTC_TRACE(kTraceError, kTraceVideoRenderer, _id,
|
||||
"%s: No thread", __FUNCTION__);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (_javaRenderThread->Start())
|
||||
WEBRTC_TRACE(kTraceInfo, kTraceVideoRenderer, _id,
|
||||
@@ -177,16 +170,9 @@ int32_t VideoRenderAndroid::StopRender() {
|
||||
|
||||
_javaShutdownEvent.Wait(3000);
|
||||
CriticalSectionScoped cs(&_critSect);
|
||||
if (_javaRenderThread->Stop()) {
|
||||
delete _javaRenderThread;
|
||||
_javaRenderThread = NULL;
|
||||
}
|
||||
else {
|
||||
assert(false);
|
||||
WEBRTC_TRACE(kTraceWarning, kTraceVideoRenderer, _id,
|
||||
"%s: Not able to stop thread, leaking", __FUNCTION__);
|
||||
_javaRenderThread = NULL;
|
||||
}
|
||||
_javaRenderThread->Stop();
|
||||
_javaRenderThread.reset();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
#include <map>
|
||||
|
||||
#include "webrtc/modules/video_render/i_video_render.h"
|
||||
#include "webrtc/system_wrappers/interface/thread_wrapper.h"
|
||||
|
||||
|
||||
namespace webrtc {
|
||||
@@ -24,7 +25,6 @@ namespace webrtc {
|
||||
|
||||
class CriticalSectionWrapper;
|
||||
class EventWrapper;
|
||||
class ThreadWrapper;
|
||||
|
||||
// The object a module user uses to send new frames to the java renderer
|
||||
// Base class for android render streams.
|
||||
@@ -144,7 +144,7 @@ class VideoRenderAndroid: IVideoRender {
|
||||
EventWrapper& _javaRenderEvent;
|
||||
int64_t _lastJavaRenderEvent;
|
||||
JNIEnv* _javaRenderJniEnv; // JNIEnv for the java render thread.
|
||||
ThreadWrapper* _javaRenderThread;
|
||||
rtc::scoped_ptr<ThreadWrapper> _javaRenderThread;
|
||||
};
|
||||
|
||||
} // namespace webrtc
|
||||
|
||||
@@ -215,11 +215,10 @@ int32_t IncomingVideoStream::Stop() {
|
||||
ThreadWrapper* thread = NULL;
|
||||
{
|
||||
CriticalSectionScoped cs_thread(&thread_critsect_);
|
||||
if (incoming_render_thread_ != NULL) {
|
||||
thread = incoming_render_thread_;
|
||||
if (incoming_render_thread_) {
|
||||
// Setting the incoming render thread to NULL marks that we're performing
|
||||
// a shutdown and will make IncomingVideoStreamProcess abort after wakeup.
|
||||
incoming_render_thread_ = NULL;
|
||||
thread = incoming_render_thread_.release();
|
||||
deliver_buffer_event_.StopTimer();
|
||||
// Set the event to allow the thread to wake up and shut down without
|
||||
// waiting for a timeout.
|
||||
|
||||
@@ -72,7 +72,7 @@ class IncomingVideoStream : public VideoRenderCallback {
|
||||
CriticalSectionWrapper& stream_critsect_;
|
||||
CriticalSectionWrapper& thread_critsect_;
|
||||
CriticalSectionWrapper& buffer_critsect_;
|
||||
ThreadWrapper* incoming_render_thread_;
|
||||
rtc::scoped_ptr<ThreadWrapper> incoming_render_thread_;
|
||||
EventWrapper& deliver_buffer_event_;
|
||||
bool running_;
|
||||
|
||||
|
||||
@@ -17,12 +17,12 @@
|
||||
#include "webrtc/base/scoped_ptr.h"
|
||||
#include "webrtc/modules/video_render/ios/video_render_ios_channel.h"
|
||||
#include "webrtc/modules/video_render/ios/video_render_ios_view.h"
|
||||
#include "webrtc/system_wrappers/interface/thread_wrapper.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
class CriticalSectionWrapper;
|
||||
class EventWrapper;
|
||||
class ThreadWrapper;
|
||||
|
||||
class VideoRenderIosGles20 {
|
||||
public:
|
||||
@@ -64,7 +64,7 @@ class VideoRenderIosGles20 {
|
||||
private:
|
||||
rtc::scoped_ptr<CriticalSectionWrapper> gles_crit_sec_;
|
||||
EventWrapper* screen_update_event_;
|
||||
ThreadWrapper* screen_update_thread_;
|
||||
rtc::scoped_ptr<ThreadWrapper> screen_update_thread_;
|
||||
|
||||
VideoRenderIosView* view_;
|
||||
Rect window_rect_;
|
||||
|
||||
@@ -15,7 +15,6 @@
|
||||
#include "webrtc/modules/video_render/ios/video_render_ios_gles20.h"
|
||||
#include "webrtc/system_wrappers/interface/critical_section_wrapper.h"
|
||||
#include "webrtc/system_wrappers/interface/event_wrapper.h"
|
||||
#include "webrtc/system_wrappers/interface/thread_wrapper.h"
|
||||
|
||||
using namespace webrtc;
|
||||
|
||||
@@ -24,7 +23,6 @@ VideoRenderIosGles20::VideoRenderIosGles20(VideoRenderIosView* view,
|
||||
int render_id)
|
||||
: gles_crit_sec_(CriticalSectionWrapper::CreateCriticalSection()),
|
||||
screen_update_event_(0),
|
||||
screen_update_thread_(0),
|
||||
view_(view),
|
||||
window_rect_(),
|
||||
window_width_(0),
|
||||
@@ -42,16 +40,14 @@ VideoRenderIosGles20::VideoRenderIosGles20(VideoRenderIosView* view,
|
||||
|
||||
VideoRenderIosGles20::~VideoRenderIosGles20() {
|
||||
// Signal event to exit thread, then delete it
|
||||
ThreadWrapper* thread_wrapper = screen_update_thread_;
|
||||
screen_update_thread_ = NULL;
|
||||
ThreadWrapper* thread_wrapper = screen_update_thread_.release();
|
||||
|
||||
if (thread_wrapper) {
|
||||
screen_update_event_->Set();
|
||||
screen_update_event_->StopTimer();
|
||||
|
||||
if (thread_wrapper->Stop()) {
|
||||
thread_wrapper->Stop();
|
||||
delete thread_wrapper;
|
||||
}
|
||||
delete screen_update_event_;
|
||||
screen_update_event_ = NULL;
|
||||
is_rendering_ = FALSE;
|
||||
@@ -78,10 +74,6 @@ VideoRenderIosGles20::~VideoRenderIosGles20() {
|
||||
int VideoRenderIosGles20::Init() {
|
||||
CriticalSectionScoped cs(gles_crit_sec_.get());
|
||||
|
||||
if (!screen_update_thread_) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (!view_) {
|
||||
view_ = [[VideoRenderIosView alloc] init];
|
||||
}
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
#include "webrtc/common_video/libyuv/include/webrtc_libyuv.h"
|
||||
#include "webrtc/system_wrappers/interface/critical_section_wrapper.h"
|
||||
#include "webrtc/system_wrappers/interface/event_wrapper.h"
|
||||
#include "webrtc/system_wrappers/interface/thread_wrapper.h"
|
||||
#include "webrtc/system_wrappers/interface/trace.h"
|
||||
|
||||
namespace webrtc {
|
||||
@@ -368,7 +367,6 @@ _windowRef( windowRef),
|
||||
_fullScreen( fullscreen),
|
||||
_id( iId),
|
||||
_renderCritSec(*CriticalSectionWrapper::CreateCriticalSection()),
|
||||
_screenUpdateThread( 0),
|
||||
_screenUpdateEvent( 0),
|
||||
_isHIViewRef( false),
|
||||
_aglContext( 0),
|
||||
@@ -485,7 +483,6 @@ _windowRef( 0),
|
||||
_fullScreen( fullscreen),
|
||||
_id( iId),
|
||||
_renderCritSec(*CriticalSectionWrapper::CreateCriticalSection()),
|
||||
_screenUpdateThread( 0),
|
||||
_screenUpdateEvent( 0),
|
||||
_isHIViewRef( false),
|
||||
_aglContext( 0),
|
||||
@@ -678,18 +675,15 @@ VideoRenderAGL::~VideoRenderAGL()
|
||||
#endif
|
||||
|
||||
// Signal event to exit thread, then delete it
|
||||
ThreadWrapper* tmpPtr = _screenUpdateThread;
|
||||
_screenUpdateThread = NULL;
|
||||
ThreadWrapper* tmpPtr = _screenUpdateThread.release();
|
||||
|
||||
if (tmpPtr)
|
||||
{
|
||||
_screenUpdateEvent->Set();
|
||||
_screenUpdateEvent->StopTimer();
|
||||
|
||||
if (tmpPtr->Stop())
|
||||
{
|
||||
tmpPtr->Stop();
|
||||
delete tmpPtr;
|
||||
}
|
||||
delete _screenUpdateEvent;
|
||||
_screenUpdateEvent = NULL;
|
||||
}
|
||||
@@ -859,16 +853,15 @@ int VideoRenderAGL::DeleteAGLChannel(int channel)
|
||||
int VideoRenderAGL::StopThread()
|
||||
{
|
||||
CriticalSectionScoped cs(&_renderCritSec);
|
||||
ThreadWrapper* tmpPtr = _screenUpdateThread;
|
||||
//_screenUpdateThread = NULL;
|
||||
ThreadWrapper* tmpPtr = _screenUpdateThread.release();
|
||||
|
||||
if (tmpPtr)
|
||||
{
|
||||
_screenUpdateEvent->Set();
|
||||
if (tmpPtr->Stop())
|
||||
{
|
||||
_renderCritSec.Leave();
|
||||
tmpPtr->Stop();
|
||||
delete tmpPtr;
|
||||
}
|
||||
_renderCritSec.Enter();
|
||||
}
|
||||
|
||||
delete _screenUpdateEvent;
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
#define WEBRTC_MODULES_VIDEO_RENDER_MAIN_SOURCE_MAC_VIDEO_RENDER_AGL_H_
|
||||
|
||||
#include "webrtc/modules/video_render/include/video_render_defines.h"
|
||||
#include "webrtc/system_wrappers/interface/thread_wrapper.h"
|
||||
|
||||
#define NEW_HIVIEW_PARENT_EVENT_HANDLER 1
|
||||
#define NEW_HIVIEW_EVENT_HANDLER 1
|
||||
@@ -34,7 +35,6 @@ class VideoRenderAGL;
|
||||
namespace webrtc {
|
||||
class CriticalSectionWrapper;
|
||||
class EventWrapper;
|
||||
class ThreadWrapper;
|
||||
|
||||
class VideoChannelAGL : public VideoRenderCallback {
|
||||
public:
|
||||
@@ -143,7 +143,7 @@ class VideoRenderAGL {
|
||||
bool _fullScreen;
|
||||
int _id;
|
||||
webrtc::CriticalSectionWrapper& _renderCritSec;
|
||||
webrtc::ThreadWrapper* _screenUpdateThread;
|
||||
rtc::scoped_ptr<webrtc::ThreadWrapper> _screenUpdateThread;
|
||||
webrtc::EventWrapper* _screenUpdateEvent;
|
||||
bool _isHIViewRef;
|
||||
AGLContext _aglContext;
|
||||
|
||||
@@ -169,7 +169,7 @@ private: // variables
|
||||
bool _fullScreen;
|
||||
int _id;
|
||||
CriticalSectionWrapper& _nsglContextCritSec;
|
||||
ThreadWrapper* _screenUpdateThread;
|
||||
rtc::scoped_ptr<ThreadWrapper> _screenUpdateThread;
|
||||
EventWrapper* _screenUpdateEvent;
|
||||
NSOpenGLContext* _nsglContext;
|
||||
NSOpenGLContext* _nsglFullScreenContext;
|
||||
|
||||
@@ -367,7 +367,6 @@ _windowRef( (CocoaRenderView*)windowRef),
|
||||
_fullScreen( fullScreen),
|
||||
_id( iId),
|
||||
_nsglContextCritSec( *CriticalSectionWrapper::CreateCriticalSection()),
|
||||
_screenUpdateThread( 0),
|
||||
_screenUpdateEvent( 0),
|
||||
_nsglContext( 0),
|
||||
_nsglFullScreenContext( 0),
|
||||
@@ -658,8 +657,7 @@ VideoRenderNSOpenGL::~VideoRenderNSOpenGL()
|
||||
}
|
||||
|
||||
// Signal event to exit thread, then delete it
|
||||
ThreadWrapper* tmpPtr = _screenUpdateThread;
|
||||
_screenUpdateThread = NULL;
|
||||
ThreadWrapper* tmpPtr = _screenUpdateThread.release();
|
||||
|
||||
if (tmpPtr)
|
||||
{
|
||||
@@ -865,9 +863,9 @@ int32_t VideoRenderNSOpenGL::GetChannelProperties(const uint16_t streamId,
|
||||
int VideoRenderNSOpenGL::StopThread()
|
||||
{
|
||||
|
||||
ThreadWrapper* tmpPtr = _screenUpdateThread;
|
||||
WEBRTC_TRACE(kTraceInfo, kTraceVideoRenderer, _id, "%s Stopping thread ", __FUNCTION__, _screenUpdateThread);
|
||||
_screenUpdateThread = NULL;
|
||||
ThreadWrapper* tmpPtr = _screenUpdateThread.release();
|
||||
WEBRTC_TRACE(kTraceInfo, kTraceVideoRenderer, _id,
|
||||
"%s Stopping thread ", __FUNCTION__, tmpPtr);
|
||||
|
||||
if (tmpPtr)
|
||||
{
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
#include "webrtc/common_video/libyuv/include/webrtc_libyuv.h"
|
||||
#include "webrtc/system_wrappers/interface/critical_section_wrapper.h"
|
||||
#include "webrtc/system_wrappers/interface/event_wrapper.h"
|
||||
#include "webrtc/system_wrappers/interface/thread_wrapper.h"
|
||||
#include "webrtc/system_wrappers/interface/trace.h"
|
||||
|
||||
namespace webrtc {
|
||||
@@ -287,7 +286,6 @@ VideoRenderDirect3D9::VideoRenderDirect3D9(Trace* trace,
|
||||
_pD3D(NULL),
|
||||
_d3dChannels(),
|
||||
_d3dZorder(),
|
||||
_screenUpdateThread(NULL),
|
||||
_screenUpdateEvent(NULL),
|
||||
_logoLeft(0),
|
||||
_logoTop(0),
|
||||
@@ -308,18 +306,15 @@ VideoRenderDirect3D9::~VideoRenderDirect3D9()
|
||||
//NOTE: we should not enter CriticalSection in here!
|
||||
|
||||
// Signal event to exit thread, then delete it
|
||||
ThreadWrapper* tmpPtr = _screenUpdateThread;
|
||||
_screenUpdateThread = NULL;
|
||||
ThreadWrapper* tmpPtr = _screenUpdateThread.release();
|
||||
if (tmpPtr)
|
||||
{
|
||||
_screenUpdateEvent->Set();
|
||||
_screenUpdateEvent->StopTimer();
|
||||
|
||||
if (tmpPtr->Stop())
|
||||
{
|
||||
tmpPtr->Stop();
|
||||
delete tmpPtr;
|
||||
}
|
||||
}
|
||||
delete _screenUpdateEvent;
|
||||
|
||||
//close d3d device
|
||||
|
||||
@@ -11,7 +11,6 @@
|
||||
#ifndef WEBRTC_MODULES_VIDEO_RENDER_MAIN_SOURCE_WINDOWS_VIDEO_RENDER_DIRECT3D9_H_
|
||||
#define WEBRTC_MODULES_VIDEO_RENDER_MAIN_SOURCE_WINDOWS_VIDEO_RENDER_DIRECT3D9_H_
|
||||
|
||||
// WebRtc includes
|
||||
#include "webrtc/modules/video_render/windows/i_video_render_win.h"
|
||||
|
||||
#include <d3d9.h>
|
||||
@@ -22,6 +21,7 @@
|
||||
|
||||
// Added
|
||||
#include "webrtc/modules/video_render/include/video_render_defines.h"
|
||||
#include "webrtc/system_wrappers/interface/thread_wrapper.h"
|
||||
|
||||
#pragma comment(lib, "d3d9.lib") // located in DirectX SDK
|
||||
|
||||
@@ -29,7 +29,6 @@ namespace webrtc {
|
||||
class CriticalSectionWrapper;
|
||||
class EventWrapper;
|
||||
class Trace;
|
||||
class ThreadWrapper;
|
||||
|
||||
class D3D9Channel: public VideoRenderCallback
|
||||
{
|
||||
@@ -205,7 +204,7 @@ private:
|
||||
|
||||
CriticalSectionWrapper& _refD3DCritsect;
|
||||
Trace* _trace;
|
||||
ThreadWrapper* _screenUpdateThread;
|
||||
rtc::scoped_ptr<ThreadWrapper> _screenUpdateThread;
|
||||
EventWrapper* _screenUpdateEvent;
|
||||
|
||||
HWND _hWnd;
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
#include <vector>
|
||||
|
||||
#include "webrtc/base/scoped_ptr.h"
|
||||
#include "webrtc/system_wrappers/interface/thread_wrapper.h"
|
||||
#include "webrtc/typedefs.h"
|
||||
|
||||
namespace webrtc {
|
||||
@@ -31,7 +32,6 @@ class CriticalSectionWrapper;
|
||||
class EventWrapper;
|
||||
class LogTable;
|
||||
class RWLockWrapper;
|
||||
class ThreadWrapper;
|
||||
|
||||
// All container classes need to implement a ToString-function to be
|
||||
// writable to file. Enforce this via the Container interface.
|
||||
@@ -146,7 +146,7 @@ class DataLogImpl {
|
||||
int counter_;
|
||||
TableMap tables_;
|
||||
EventWrapper* flush_event_;
|
||||
ThreadWrapper* file_writer_thread_;
|
||||
rtc::scoped_ptr<ThreadWrapper> file_writer_thread_;
|
||||
RWLockWrapper* tables_lock_;
|
||||
};
|
||||
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
#ifndef WEBRTC_SYSTEM_WRAPPERS_INTERFACE_THREAD_WRAPPER_H_
|
||||
#define WEBRTC_SYSTEM_WRAPPERS_INTERFACE_THREAD_WRAPPER_H_
|
||||
|
||||
#include "webrtc/base/scoped_ptr.h"
|
||||
#include "webrtc/common_types.h"
|
||||
#include "webrtc/typedefs.h"
|
||||
|
||||
@@ -37,6 +38,8 @@ enum ThreadPriority {
|
||||
// Represents a simple worker thread. The implementation must be assumed
|
||||
// to be single threaded, meaning that all methods of the class, must be
|
||||
// called from the same thread, including instantiation.
|
||||
// TODO(tommi): There's no need for this to be a virtual interface since there's
|
||||
// only ever a single implementation of it.
|
||||
class ThreadWrapper {
|
||||
public:
|
||||
virtual ~ThreadWrapper() {}
|
||||
@@ -51,9 +54,8 @@ class ThreadWrapper {
|
||||
// debugger.
|
||||
// TODO(tommi): Remove the priority argument and provide a setter instead.
|
||||
// TODO(tommi): Make thread_name non-optional (i.e. no default value).
|
||||
static ThreadWrapper* CreateThread(ThreadRunFunction func,
|
||||
void* obj,
|
||||
ThreadPriority prio = kNormalPriority,
|
||||
static rtc::scoped_ptr<ThreadWrapper> CreateThread(ThreadRunFunction func,
|
||||
void* obj, ThreadPriority prio = kNormalPriority,
|
||||
const char* thread_name = 0);
|
||||
|
||||
// Get the current thread's thread ID.
|
||||
|
||||
@@ -158,14 +158,13 @@ class CondVarTest : public ::testing::Test {
|
||||
ASSERT_TRUE(baton_.Pass(kShortWaitMs));
|
||||
ASSERT_TRUE(baton_.Grab(kShortWaitMs));
|
||||
ASSERT_TRUE(thread_->Stop());
|
||||
delete thread_;
|
||||
}
|
||||
|
||||
protected:
|
||||
Baton baton_;
|
||||
|
||||
private:
|
||||
ThreadWrapper* thread_;
|
||||
rtc::scoped_ptr<ThreadWrapper> thread_;
|
||||
};
|
||||
|
||||
// The SetUp and TearDown functions use condition variables.
|
||||
|
||||
@@ -78,7 +78,7 @@ TEST_F(CritSectTest, ThreadWakesOnce) NO_THREAD_SAFETY_ANALYSIS {
|
||||
CriticalSectionWrapper* crit_sect =
|
||||
CriticalSectionWrapper::CreateCriticalSection();
|
||||
ProtectedCount count(crit_sect);
|
||||
ThreadWrapper* thread = ThreadWrapper::CreateThread(
|
||||
rtc::scoped_ptr<ThreadWrapper> thread = ThreadWrapper::CreateThread(
|
||||
&LockUnlockThenStopRunFunction, &count);
|
||||
crit_sect->Enter();
|
||||
ASSERT_TRUE(thread->Start());
|
||||
@@ -91,7 +91,6 @@ TEST_F(CritSectTest, ThreadWakesOnce) NO_THREAD_SAFETY_ANALYSIS {
|
||||
crit_sect->Leave(); // This frees the thread to act.
|
||||
EXPECT_TRUE(WaitForCount(1, &count));
|
||||
EXPECT_TRUE(thread->Stop());
|
||||
delete thread;
|
||||
delete crit_sect;
|
||||
}
|
||||
|
||||
@@ -106,8 +105,8 @@ TEST_F(CritSectTest, ThreadWakesTwice) NO_THREAD_SAFETY_ANALYSIS {
|
||||
CriticalSectionWrapper* crit_sect =
|
||||
CriticalSectionWrapper::CreateCriticalSection();
|
||||
ProtectedCount count(crit_sect);
|
||||
ThreadWrapper* thread = ThreadWrapper::CreateThread(&LockUnlockRunFunction,
|
||||
&count);
|
||||
rtc::scoped_ptr<ThreadWrapper> thread = ThreadWrapper::CreateThread(
|
||||
&LockUnlockRunFunction, &count);
|
||||
crit_sect->Enter(); // Make sure counter stays 0 until we wait for it.
|
||||
ASSERT_TRUE(thread->Start());
|
||||
crit_sect->Leave();
|
||||
@@ -130,7 +129,6 @@ TEST_F(CritSectTest, ThreadWakesTwice) NO_THREAD_SAFETY_ANALYSIS {
|
||||
SwitchProcess();
|
||||
EXPECT_TRUE(WaitForCount(count_before + 1, &count));
|
||||
EXPECT_TRUE(thread->Stop());
|
||||
delete thread;
|
||||
delete crit_sect;
|
||||
}
|
||||
|
||||
|
||||
@@ -19,7 +19,6 @@
|
||||
#include "webrtc/system_wrappers/interface/event_wrapper.h"
|
||||
#include "webrtc/system_wrappers/interface/file_wrapper.h"
|
||||
#include "webrtc/system_wrappers/interface/rw_lock_wrapper.h"
|
||||
#include "webrtc/system_wrappers/interface/thread_wrapper.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
@@ -322,14 +321,12 @@ DataLogImpl::DataLogImpl()
|
||||
: counter_(1),
|
||||
tables_(),
|
||||
flush_event_(EventWrapper::Create()),
|
||||
file_writer_thread_(NULL),
|
||||
tables_lock_(RWLockWrapper::CreateRWLock()) {
|
||||
}
|
||||
|
||||
DataLogImpl::~DataLogImpl() {
|
||||
StopThread();
|
||||
Flush(); // Write any remaining rows
|
||||
delete file_writer_thread_;
|
||||
delete flush_event_;
|
||||
for (TableMap::iterator it = tables_.begin(); it != tables_.end();) {
|
||||
delete static_cast<LogTable*>(it->second);
|
||||
@@ -356,8 +353,6 @@ int DataLogImpl::Init() {
|
||||
instance_,
|
||||
kHighestPriority,
|
||||
"DataLog");
|
||||
if (file_writer_thread_ == NULL)
|
||||
return -1;
|
||||
bool success = file_writer_thread_->Start();
|
||||
if (!success)
|
||||
return -1;
|
||||
@@ -413,7 +408,7 @@ int DataLogImpl::NextRow(const std::string& table_name) {
|
||||
if (tables_.count(table_name) == 0)
|
||||
return -1;
|
||||
tables_[table_name]->NextRow();
|
||||
if (file_writer_thread_ == NULL) {
|
||||
if (!file_writer_thread_) {
|
||||
// Write every row to file as they get complete.
|
||||
tables_[table_name]->Flush();
|
||||
} else {
|
||||
@@ -442,11 +437,9 @@ void DataLogImpl::Process() {
|
||||
}
|
||||
|
||||
void DataLogImpl::StopThread() {
|
||||
if (file_writer_thread_ != NULL) {
|
||||
if (file_writer_thread_) {
|
||||
flush_event_->Set();
|
||||
// Call Stop() repeatedly, waiting for the Flush() call in Process() to
|
||||
// finish.
|
||||
while (!file_writer_thread_->Stop()) continue;
|
||||
file_writer_thread_->Stop();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -218,9 +218,7 @@ bool EventPosix::StopTimer() {
|
||||
if (!timer_thread_->Stop()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
delete timer_thread_;
|
||||
timer_thread_ = 0;
|
||||
timer_thread_.reset();
|
||||
}
|
||||
if (timer_event_) {
|
||||
delete timer_event_;
|
||||
|
||||
@@ -49,7 +49,7 @@ class EventPosix : public EventWrapper {
|
||||
pthread_mutex_t mutex_;
|
||||
bool event_set_;
|
||||
|
||||
ThreadWrapper* timer_thread_;
|
||||
rtc::scoped_ptr<ThreadWrapper> timer_thread_;
|
||||
EventPosix* timer_event_;
|
||||
timespec created_at_;
|
||||
|
||||
|
||||
@@ -18,14 +18,17 @@
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
ThreadWrapper* ThreadWrapper::CreateThread(ThreadRunFunction func,
|
||||
void* obj, ThreadPriority prio,
|
||||
const char* thread_name) {
|
||||
#if defined(_WIN32)
|
||||
return new ThreadWindows(func, obj, prio, thread_name);
|
||||
typedef ThreadWindows ThreadType;
|
||||
#else
|
||||
return new ThreadPosix(func, obj, prio, thread_name);
|
||||
typedef ThreadPosix ThreadType;
|
||||
#endif
|
||||
|
||||
rtc::scoped_ptr<ThreadWrapper> ThreadWrapper::CreateThread(
|
||||
ThreadRunFunction func, void* obj, ThreadPriority prio,
|
||||
const char* thread_name) {
|
||||
return rtc::scoped_ptr<ThreadWrapper>(
|
||||
new ThreadType(func, obj, prio, thread_name)).Pass();
|
||||
}
|
||||
|
||||
} // namespace webrtc
|
||||
|
||||
@@ -23,10 +23,10 @@ bool NullRunFunction(void* obj) {
|
||||
}
|
||||
|
||||
TEST(ThreadTest, StartStop) {
|
||||
ThreadWrapper* thread = ThreadWrapper::CreateThread(&NullRunFunction, NULL);
|
||||
rtc::scoped_ptr<ThreadWrapper> thread = ThreadWrapper::CreateThread(
|
||||
&NullRunFunction, NULL);
|
||||
ASSERT_TRUE(thread->Start());
|
||||
EXPECT_TRUE(thread->Stop());
|
||||
delete thread;
|
||||
}
|
||||
|
||||
// Function that sets a boolean.
|
||||
@@ -39,8 +39,8 @@ bool SetFlagRunFunction(void* obj) {
|
||||
|
||||
TEST(ThreadTest, RunFunctionIsCalled) {
|
||||
bool flag = false;
|
||||
ThreadWrapper* thread = ThreadWrapper::CreateThread(&SetFlagRunFunction,
|
||||
&flag);
|
||||
rtc::scoped_ptr<ThreadWrapper> thread = ThreadWrapper::CreateThread(
|
||||
&SetFlagRunFunction, &flag);
|
||||
ASSERT_TRUE(thread->Start());
|
||||
|
||||
// At this point, the flag may be either true or false.
|
||||
@@ -48,7 +48,6 @@ TEST(ThreadTest, RunFunctionIsCalled) {
|
||||
|
||||
// We expect the thread to have run at least once.
|
||||
EXPECT_TRUE(flag);
|
||||
delete thread;
|
||||
}
|
||||
|
||||
} // namespace webrtc
|
||||
|
||||
@@ -520,7 +520,6 @@ int32_t UdpSocket2WorkerWindows::_numOfWorkers = 0;
|
||||
|
||||
UdpSocket2WorkerWindows::UdpSocket2WorkerWindows(HANDLE ioCompletionHandle)
|
||||
: _ioCompletionHandle(ioCompletionHandle),
|
||||
_pThread(NULL),
|
||||
_init(false)
|
||||
{
|
||||
_workerNumber = _numOfWorkers++;
|
||||
@@ -530,10 +529,6 @@ UdpSocket2WorkerWindows::UdpSocket2WorkerWindows(HANDLE ioCompletionHandle)
|
||||
|
||||
UdpSocket2WorkerWindows::~UdpSocket2WorkerWindows()
|
||||
{
|
||||
if(_pThread)
|
||||
{
|
||||
delete _pThread;
|
||||
}
|
||||
WEBRTC_TRACE(kTraceMemory, kTraceTransport, -1,
|
||||
"UdpSocket2WorkerWindows deleted");
|
||||
}
|
||||
@@ -559,16 +554,6 @@ int32_t UdpSocket2WorkerWindows::Init()
|
||||
const char* threadName = "UdpSocket2ManagerWindows_thread";
|
||||
_pThread = ThreadWrapper::CreateThread(Run, this, kRealtimePriority,
|
||||
threadName);
|
||||
if(_pThread == NULL)
|
||||
{
|
||||
WEBRTC_TRACE(
|
||||
kTraceError,
|
||||
kTraceTransport,
|
||||
-1,
|
||||
"UdpSocket2WorkerWindows(%d)::Init(), error creating thread!",
|
||||
_workerNumber);
|
||||
return -1;
|
||||
}
|
||||
_init = true;
|
||||
}
|
||||
return 0;
|
||||
|
||||
@@ -105,7 +105,7 @@ protected:
|
||||
bool Process();
|
||||
private:
|
||||
HANDLE _ioCompletionHandle;
|
||||
ThreadWrapper*_pThread;
|
||||
rtc::scoped_ptr<ThreadWrapper> _pThread;
|
||||
static int32_t _numOfWorkers;
|
||||
int32_t _workerNumber;
|
||||
volatile bool _stop;
|
||||
|
||||
@@ -198,11 +198,6 @@ UdpSocketManagerPosixImpl::UdpSocketManagerPosixImpl()
|
||||
|
||||
UdpSocketManagerPosixImpl::~UdpSocketManagerPosixImpl()
|
||||
{
|
||||
if(_thread != NULL)
|
||||
{
|
||||
delete _thread;
|
||||
}
|
||||
|
||||
if (_critSectList != NULL)
|
||||
{
|
||||
UpdateSocketMap();
|
||||
@@ -226,7 +221,7 @@ UdpSocketManagerPosixImpl::~UdpSocketManagerPosixImpl()
|
||||
|
||||
bool UdpSocketManagerPosixImpl::Start()
|
||||
{
|
||||
if (_thread == NULL)
|
||||
if (!_thread)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -238,7 +233,7 @@ bool UdpSocketManagerPosixImpl::Start()
|
||||
|
||||
bool UdpSocketManagerPosixImpl::Stop()
|
||||
{
|
||||
if (_thread == NULL)
|
||||
if (!_thread)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -75,7 +75,7 @@ protected:
|
||||
private:
|
||||
typedef std::list<UdpSocketWrapper*> SocketList;
|
||||
typedef std::list<SOCKET> FdList;
|
||||
ThreadWrapper* _thread;
|
||||
rtc::scoped_ptr<ThreadWrapper> _thread;
|
||||
CriticalSectionWrapper* _critSectList;
|
||||
|
||||
fd_set _readFds;
|
||||
|
||||
@@ -55,8 +55,8 @@ int32_t FakeAudioDevice::Init() {
|
||||
|
||||
if (!tick_->StartTimer(true, 10))
|
||||
return -1;
|
||||
thread_.reset(ThreadWrapper::CreateThread(
|
||||
FakeAudioDevice::Run, this, webrtc::kHighPriority, "FakeAudioDevice"));
|
||||
thread_ = ThreadWrapper::CreateThread(
|
||||
FakeAudioDevice::Run, this, webrtc::kHighPriority, "FakeAudioDevice");
|
||||
if (thread_.get() == NULL)
|
||||
return -1;
|
||||
if (!thread_->Start()) {
|
||||
|
||||
@@ -90,10 +90,10 @@ bool FrameGeneratorCapturer::Init() {
|
||||
|
||||
if (!tick_->StartTimer(true, 1000 / target_fps_))
|
||||
return false;
|
||||
thread_.reset(ThreadWrapper::CreateThread(FrameGeneratorCapturer::Run,
|
||||
thread_ = ThreadWrapper::CreateThread(FrameGeneratorCapturer::Run,
|
||||
this,
|
||||
webrtc::kHighPriority,
|
||||
"FrameGeneratorCapturer"));
|
||||
"FrameGeneratorCapturer");
|
||||
if (thread_.get() == NULL)
|
||||
return false;
|
||||
if (!thread_->Start()) {
|
||||
|
||||
@@ -108,10 +108,10 @@ class VideoAnalyzer : public PacketReceiver,
|
||||
}
|
||||
|
||||
for (uint32_t i = 0; i < num_cores; ++i) {
|
||||
ThreadWrapper* thread =
|
||||
rtc::scoped_ptr<ThreadWrapper> thread =
|
||||
ThreadWrapper::CreateThread(&FrameComparisonThread, this);
|
||||
comparison_thread_pool_.push_back(thread);
|
||||
EXPECT_TRUE(thread->Start());
|
||||
comparison_thread_pool_.push_back(thread.release());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
#define WEBRTC_VIDEO_ENGINE_MAIN_TEST_AUTOTEST_INTERFACE_VIE_AUTOTEST_WINDOWS_H_
|
||||
|
||||
#include "webrtc/engine_configurations.h"
|
||||
#include "webrtc/system_wrappers/interface/thread_wrapper.h"
|
||||
#include "webrtc/video_engine/test/auto_test/interface/vie_autotest_window_manager_interface.h"
|
||||
|
||||
#include <windows.h>
|
||||
@@ -19,7 +20,6 @@
|
||||
|
||||
// Forward declaration
|
||||
namespace webrtc {
|
||||
class ThreadWrapper;
|
||||
class CriticalSectionWrapper;
|
||||
}
|
||||
|
||||
@@ -48,7 +48,7 @@ private:
|
||||
void* _window2;
|
||||
|
||||
bool _terminate;
|
||||
webrtc::ThreadWrapper& _eventThread;
|
||||
rtc::scoped_ptr<webrtc::ThreadWrapper> _eventThread;
|
||||
webrtc::CriticalSectionWrapper& _crit;
|
||||
HWND _hwndMain;
|
||||
HWND _hwnd1;
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
|
||||
#include "webrtc/engine_configurations.h"
|
||||
#include "webrtc/system_wrappers/interface/critical_section_wrapper.h"
|
||||
#include "webrtc/system_wrappers/interface/thread_wrapper.h"
|
||||
#include "webrtc/video_engine/test/auto_test/interface/vie_autotest_defines.h"
|
||||
#include "webrtc/video_engine/test/auto_test/interface/vie_autotest_main.h"
|
||||
|
||||
|
||||
@@ -19,7 +19,6 @@
|
||||
|
||||
#include "webrtc/engine_configurations.h"
|
||||
#include "webrtc/system_wrappers/interface/critical_section_wrapper.h"
|
||||
#include "webrtc/system_wrappers/interface/thread_wrapper.h"
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
@@ -47,7 +46,7 @@ ViEAutoTestWindowManager::ViEAutoTestWindowManager()
|
||||
: _window1(NULL),
|
||||
_window2(NULL),
|
||||
_terminate(false),
|
||||
_eventThread(*webrtc::ThreadWrapper::CreateThread(
|
||||
_eventThread(webrtc::ThreadWrapper::CreateThread(
|
||||
EventProcess, this, webrtc::kNormalPriority,
|
||||
"ViEAutotestEventThread")),
|
||||
_crit(*webrtc::CriticalSectionWrapper::CreateCriticalSection()),
|
||||
@@ -86,7 +85,7 @@ int ViEAutoTestWindowManager::CreateWindows(AutoTestRect window1Size,
|
||||
memcpy(_hwnd1Title, window1Title, TITLE_LENGTH);
|
||||
memcpy(_hwnd2Title, window2Title, TITLE_LENGTH);
|
||||
|
||||
_eventThread.Start();
|
||||
_eventThread->Start();
|
||||
|
||||
do {
|
||||
_crit.Enter();
|
||||
@@ -102,11 +101,10 @@ int ViEAutoTestWindowManager::CreateWindows(AutoTestRect window1Size,
|
||||
|
||||
int ViEAutoTestWindowManager::TerminateWindows() {
|
||||
_terminate = true;
|
||||
if (_eventThread.Stop()) {
|
||||
_eventThread->Stop();
|
||||
_crit.Enter();
|
||||
delete &_eventThread;
|
||||
_eventThread.reset();
|
||||
_crit.Leave();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -11,7 +11,6 @@
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
#include "webrtc/system_wrappers/interface/thread_wrapper.h"
|
||||
#include "webrtc/video_engine/include/vie_capture.h"
|
||||
#include "webrtc/video_engine/test/libvietest/include/vie_file_capture_device.h"
|
||||
|
||||
@@ -34,7 +33,6 @@ bool StreamVideoFileRepeatedlyIntoCaptureDevice(void* data) {
|
||||
ViEFakeCamera::ViEFakeCamera(webrtc::ViECapture* capture_interface)
|
||||
: capture_interface_(capture_interface),
|
||||
capture_id_(-1),
|
||||
camera_thread_(NULL),
|
||||
file_capture_device_(NULL) {
|
||||
}
|
||||
|
||||
@@ -77,7 +75,7 @@ bool ViEFakeCamera::StopCamera() {
|
||||
|
||||
int result = capture_interface_->ReleaseCaptureDevice(capture_id_);
|
||||
|
||||
delete camera_thread_;
|
||||
camera_thread_.reset();
|
||||
delete file_capture_device_;
|
||||
camera_thread_ = NULL;
|
||||
file_capture_device_ = NULL;
|
||||
|
||||
@@ -19,12 +19,12 @@
|
||||
#include <map>
|
||||
|
||||
#include "webrtc/common_types.h"
|
||||
#include "webrtc/system_wrappers/interface/thread_wrapper.h"
|
||||
|
||||
namespace webrtc
|
||||
{
|
||||
class CriticalSectionWrapper;
|
||||
class EventWrapper;
|
||||
class ThreadWrapper;
|
||||
class ViENetwork;
|
||||
}
|
||||
|
||||
@@ -147,7 +147,7 @@ private:
|
||||
int sender_channel_;
|
||||
SsrcChannelMap* receive_channels_;
|
||||
webrtc::ViENetwork& _vieNetwork;
|
||||
webrtc::ThreadWrapper& _thread;
|
||||
rtc::scoped_ptr<webrtc::ThreadWrapper> _thread;
|
||||
webrtc::EventWrapper& _event;
|
||||
webrtc::CriticalSectionWrapper& _crit;
|
||||
webrtc::CriticalSectionWrapper& _statCrit;
|
||||
|
||||
@@ -11,10 +11,10 @@
|
||||
#define SRC_VIDEO_ENGINE_MAIN_TEST_AUTOTEST_HELPERS_VIE_FAKE_CAMERA_H_
|
||||
|
||||
#include <string>
|
||||
#include "webrtc/system_wrappers/interface/thread_wrapper.h"
|
||||
|
||||
namespace webrtc {
|
||||
class ViECapture;
|
||||
class ThreadWrapper;
|
||||
}
|
||||
|
||||
class ViEFileCaptureDevice;
|
||||
@@ -43,7 +43,7 @@ class ViEFakeCamera {
|
||||
webrtc::ViECapture* capture_interface_;
|
||||
|
||||
int capture_id_;
|
||||
webrtc::ThreadWrapper* camera_thread_;
|
||||
rtc::scoped_ptr<webrtc::ThreadWrapper> camera_thread_;
|
||||
ViEFileCaptureDevice* file_capture_device_;
|
||||
};
|
||||
|
||||
|
||||
@@ -25,7 +25,6 @@
|
||||
|
||||
#include "webrtc/system_wrappers/interface/critical_section_wrapper.h"
|
||||
#include "webrtc/system_wrappers/interface/event_wrapper.h"
|
||||
#include "webrtc/system_wrappers/interface/thread_wrapper.h"
|
||||
#include "webrtc/system_wrappers/interface/tick_util.h"
|
||||
#include "webrtc/video_engine/include/vie_network.h"
|
||||
|
||||
@@ -41,7 +40,7 @@ TbExternalTransport::TbExternalTransport(
|
||||
sender_channel_(sender_channel),
|
||||
receive_channels_(receive_channels),
|
||||
_vieNetwork(vieNetwork),
|
||||
_thread(*webrtc::ThreadWrapper::CreateThread(
|
||||
_thread(webrtc::ThreadWrapper::CreateThread(
|
||||
ViEExternalTransportRun, this, webrtc::kHighPriority,
|
||||
"AutotestTransport")),
|
||||
_event(*webrtc::EventWrapper::Create()),
|
||||
@@ -77,17 +76,15 @@ TbExternalTransport::TbExternalTransport(
|
||||
{
|
||||
srand((int) webrtc::TickTime::MicrosecondTimestamp());
|
||||
memset(&network_parameters_, 0, sizeof(NetworkParameters));
|
||||
_thread.Start();
|
||||
_thread->Start();
|
||||
}
|
||||
|
||||
TbExternalTransport::~TbExternalTransport()
|
||||
{
|
||||
_event.Set();
|
||||
if (_thread.Stop())
|
||||
{
|
||||
delete &_thread;
|
||||
_thread->Stop();
|
||||
delete &_event;
|
||||
}
|
||||
|
||||
for (std::list<VideoPacket*>::iterator it = _rtpPackets.begin();
|
||||
it != _rtpPackets.end(); ++it) {
|
||||
delete *it;
|
||||
|
||||
@@ -20,7 +20,6 @@
|
||||
#include "webrtc/system_wrappers/interface/critical_section_wrapper.h"
|
||||
#include "webrtc/system_wrappers/interface/event_wrapper.h"
|
||||
#include "webrtc/system_wrappers/interface/logging.h"
|
||||
#include "webrtc/system_wrappers/interface/thread_wrapper.h"
|
||||
#include "webrtc/system_wrappers/interface/tick_util.h"
|
||||
#include "webrtc/system_wrappers/interface/trace_event.h"
|
||||
#include "webrtc/video_engine/include/vie_image_process.h"
|
||||
@@ -69,7 +68,7 @@ ViECapturer::ViECapturer(int capture_id,
|
||||
module_process_thread_(module_process_thread),
|
||||
capture_id_(capture_id),
|
||||
incoming_frame_cs_(CriticalSectionWrapper::CreateCriticalSection()),
|
||||
capture_thread_(*ThreadWrapper::CreateThread(ViECaptureThreadFunction,
|
||||
capture_thread_(ThreadWrapper::CreateThread(ViECaptureThreadFunction,
|
||||
this,
|
||||
kHighPriority,
|
||||
"ViECaptureThread")),
|
||||
@@ -93,7 +92,7 @@ ViECapturer::ViECapturer(int capture_id,
|
||||
overuse_detector_(
|
||||
new OveruseFrameDetector(Clock::GetRealTimeClock(),
|
||||
cpu_overuse_metrics_observer_.get())) {
|
||||
capture_thread_.Start();
|
||||
capture_thread_->Start();
|
||||
module_process_thread_.RegisterModule(overuse_detector_.get());
|
||||
}
|
||||
|
||||
@@ -111,14 +110,10 @@ ViECapturer::~ViECapturer() {
|
||||
capture_module_->Release();
|
||||
capture_module_ = NULL;
|
||||
}
|
||||
if (capture_thread_.Stop()) {
|
||||
// Thread stopped.
|
||||
delete &capture_thread_;
|
||||
|
||||
capture_thread_->Stop();
|
||||
delete &capture_event_;
|
||||
delete &deliver_event_;
|
||||
} else {
|
||||
assert(false);
|
||||
}
|
||||
|
||||
if (image_proc_module_) {
|
||||
VideoProcessingModule::Destroy(image_proc_module_);
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
#include "webrtc/modules/video_coding/main/interface/video_coding.h"
|
||||
#include "webrtc/modules/video_processing/main/interface/video_processing.h"
|
||||
#include "webrtc/system_wrappers/interface/critical_section_wrapper.h"
|
||||
#include "webrtc/system_wrappers/interface/thread_wrapper.h"
|
||||
#include "webrtc/typedefs.h"
|
||||
#include "webrtc/video_engine/include/vie_base.h"
|
||||
#include "webrtc/video_engine/include/vie_capture.h"
|
||||
@@ -37,7 +38,6 @@ class EventWrapper;
|
||||
class CpuOveruseObserver;
|
||||
class OveruseFrameDetector;
|
||||
class ProcessThread;
|
||||
class ThreadWrapper;
|
||||
class ViEEffectFilter;
|
||||
class ViEEncoder;
|
||||
struct ViEPicture;
|
||||
@@ -163,7 +163,7 @@ class ViECapturer
|
||||
I420VideoFrame incoming_frame_;
|
||||
|
||||
// Capture thread.
|
||||
ThreadWrapper& capture_thread_;
|
||||
rtc::scoped_ptr<ThreadWrapper> capture_thread_;
|
||||
EventWrapper& capture_event_;
|
||||
EventWrapper& deliver_event_;
|
||||
|
||||
|
||||
@@ -122,7 +122,6 @@ ViEChannel::ViEChannel(int32_t channel_id,
|
||||
external_transport_(NULL),
|
||||
decoder_reset_(true),
|
||||
wait_for_key_frame_(false),
|
||||
decode_thread_(NULL),
|
||||
effect_filter_(NULL),
|
||||
color_enhancement_(false),
|
||||
mtu_(0),
|
||||
@@ -1854,8 +1853,7 @@ int32_t ViEChannel::StopDecodeThread() {
|
||||
vcm_->TriggerDecoderShutdown();
|
||||
|
||||
decode_thread_->Stop();
|
||||
delete decode_thread_;
|
||||
decode_thread_ = NULL;
|
||||
decode_thread_.reset();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -536,7 +536,7 @@ class ViEChannel
|
||||
// Current receive codec used for codec change callback.
|
||||
VideoCodec receive_codec_;
|
||||
bool wait_for_key_frame_;
|
||||
ThreadWrapper* decode_thread_;
|
||||
rtc::scoped_ptr<ThreadWrapper> decode_thread_;
|
||||
|
||||
ViEEffectFilter* effect_filter_;
|
||||
bool color_enhancement_;
|
||||
|
||||
@@ -177,23 +177,16 @@ private:
|
||||
static bool Run(void* ptr);
|
||||
bool Process();
|
||||
private:
|
||||
ThreadWrapper* _thread;
|
||||
rtc::scoped_ptr<ThreadWrapper> _thread;
|
||||
};
|
||||
|
||||
ThreadTest::~ThreadTest()
|
||||
{
|
||||
if (_thread)
|
||||
{
|
||||
if (_thread->Stop())
|
||||
{
|
||||
delete _thread;
|
||||
_thread = NULL;
|
||||
}
|
||||
}
|
||||
_thread->Stop();
|
||||
}
|
||||
|
||||
ThreadTest::ThreadTest() :
|
||||
_thread(NULL)
|
||||
ThreadTest::ThreadTest()
|
||||
{
|
||||
_thread = ThreadWrapper::CreateThread(Run, this, kNormalPriority,
|
||||
"ThreadTest thread");
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
|
||||
FakeExternalTransport::FakeExternalTransport(webrtc::VoENetwork* ptr)
|
||||
: my_network_(ptr),
|
||||
thread_(NULL),
|
||||
lock_(NULL),
|
||||
event_(NULL),
|
||||
length_(0),
|
||||
@@ -38,15 +37,12 @@ FakeExternalTransport::FakeExternalTransport(webrtc::VoENetwork* ptr)
|
||||
FakeExternalTransport::~FakeExternalTransport() {
|
||||
if (thread_) {
|
||||
event_->Set();
|
||||
if (thread_->Stop()) {
|
||||
delete thread_;
|
||||
thread_ = NULL;
|
||||
thread_->Stop();
|
||||
delete event_;
|
||||
event_ = NULL;
|
||||
delete lock_;
|
||||
lock_ = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool FakeExternalTransport::Run(void* ptr) {
|
||||
|
||||
@@ -32,7 +32,7 @@ class FakeExternalTransport : public webrtc::Transport {
|
||||
static bool Run(void* ptr);
|
||||
bool Process();
|
||||
private:
|
||||
webrtc::ThreadWrapper* thread_;
|
||||
rtc::scoped_ptr<webrtc::ThreadWrapper> thread_;
|
||||
webrtc::CriticalSectionWrapper* lock_;
|
||||
webrtc::EventWrapper* event_;
|
||||
private:
|
||||
|
||||
@@ -26,7 +26,6 @@
|
||||
|
||||
#include "webrtc/base/scoped_ptr.h"
|
||||
#include "webrtc/system_wrappers/interface/sleep.h"
|
||||
#include "webrtc/system_wrappers/interface/thread_wrapper.h"
|
||||
#include "webrtc/test/channel_transport/include/channel_transport.h"
|
||||
#include "webrtc/voice_engine/test/auto_test/voe_standard_test.h"
|
||||
#include "webrtc/voice_engine/test/auto_test/voe_test_defines.h"
|
||||
@@ -368,7 +367,6 @@ int VoEStressTest::MultipleThreadsTest() {
|
||||
|
||||
// Stop extra thread
|
||||
VALIDATE_STRESS(!_ptrExtraApiThread->Stop());
|
||||
delete _ptrExtraApiThread;
|
||||
|
||||
///////////// End test /////////////
|
||||
|
||||
|
||||
@@ -11,9 +11,7 @@
|
||||
#ifndef WEBRTC_VOICE_ENGINE_VOE_STRESS_TEST_H
|
||||
#define WEBRTC_VOICE_ENGINE_VOE_STRESS_TEST_H
|
||||
|
||||
namespace webrtc {
|
||||
class ThreadWrapper;
|
||||
}
|
||||
#include "webrtc/system_wrappers/interface/thread_wrapper.h"
|
||||
|
||||
namespace voetest {
|
||||
// TODO(andrew): using directives are not permitted.
|
||||
@@ -23,8 +21,7 @@ class VoETestManager;
|
||||
|
||||
class VoEStressTest {
|
||||
public:
|
||||
VoEStressTest(VoETestManager& mgr) :
|
||||
_mgr(mgr), _ptrExtraApiThread(NULL) {
|
||||
VoEStressTest(VoETestManager& mgr) : _mgr(mgr) {
|
||||
}
|
||||
~VoEStressTest() {
|
||||
}
|
||||
@@ -41,7 +38,7 @@ class VoEStressTest {
|
||||
|
||||
VoETestManager& _mgr;
|
||||
|
||||
ThreadWrapper* _ptrExtraApiThread;
|
||||
rtc::scoped_ptr<ThreadWrapper> _ptrExtraApiThread;
|
||||
};
|
||||
|
||||
} // namespace voetest
|
||||
|
||||
Reference in New Issue
Block a user