Move ThreadWrapper to ProcessThread in base.

Also removes all virtual methods. Permits using a thread from
rtc_base_approved (namely event tracing).

BUG=webrtc:5158
R=tommi@webrtc.org

Review URL: https://codereview.webrtc.org/1469013002

Cr-Commit-Position: refs/heads/master@{#10760}
This commit is contained in:
pbos 2015-11-23 14:47:56 -08:00 committed by Commit bot
parent 255d6f6fb2
commit 12411ef40e
90 changed files with 555 additions and 788 deletions

View File

@ -124,6 +124,7 @@ static_library("rtc_base_approved") {
"platform_file.h",
"platform_thread.cc",
"platform_thread.h",
"platform_thread_types.h",
"safe_conversions.h",
"safe_conversions_impl.h",
"scoped_ptr.h",

View File

@ -62,6 +62,7 @@
'platform_file.h',
'platform_thread.cc',
'platform_thread.h',
'platform_thread_types.h',
'ratetracker.cc',
'ratetracker.h',
'safe_conversions.h',

View File

@ -80,6 +80,7 @@
'optional_unittest.cc',
'optionsfile_unittest.cc',
'pathutils_unittest.cc',
'platform_thread_unittest.cc',
'profiler_unittest.cc',
'proxy_unittest.cc',
'proxydetect_unittest.cc',

View File

@ -10,8 +10,6 @@
#include "webrtc/base/platform_thread.h"
#include <string.h>
#include "webrtc/base/checks.h"
#if defined(WEBRTC_LINUX)
@ -58,7 +56,6 @@ bool IsThreadRefEqual(const PlatformThreadRef& a, const PlatformThreadRef& b) {
}
void SetCurrentThreadName(const char* name) {
RTC_DCHECK(strlen(name) < 64);
#if defined(WEBRTC_WIN)
struct {
DWORD dwType;
@ -80,3 +77,189 @@ void SetCurrentThreadName(const char* name) {
}
} // namespace rtc
namespace webrtc {
rtc::scoped_ptr<PlatformThread> PlatformThread::CreateThread(
ThreadRunFunction func,
void* obj,
const char* thread_name) {
return rtc::scoped_ptr<PlatformThread>(
new PlatformThread(func, obj, thread_name));
}
namespace {
#if defined(WEBRTC_WIN)
void CALLBACK RaiseFlag(ULONG_PTR param) {
*reinterpret_cast<bool*>(param) = true;
}
#else
struct ThreadAttributes {
ThreadAttributes() { pthread_attr_init(&attr); }
~ThreadAttributes() { pthread_attr_destroy(&attr); }
pthread_attr_t* operator&() { return &attr; }
pthread_attr_t attr;
};
int ConvertToSystemPriority(ThreadPriority priority,
int min_prio,
int max_prio) {
RTC_DCHECK(max_prio - min_prio > 2);
const int top_prio = max_prio - 1;
const int low_prio = min_prio + 1;
switch (priority) {
case kLowPriority:
return low_prio;
case kNormalPriority:
// The -1 ensures that the kHighPriority is always greater or equal to
// kNormalPriority.
return (low_prio + top_prio - 1) / 2;
case kHighPriority:
return std::max(top_prio - 2, low_prio);
case kHighestPriority:
return std::max(top_prio - 1, low_prio);
case kRealtimePriority:
return top_prio;
}
RTC_DCHECK(false);
return low_prio;
}
#endif // defined(WEBRTC_WIN)
}
PlatformThread::PlatformThread(ThreadRunFunction func,
void* obj,
const char* thread_name)
: run_function_(func),
obj_(obj),
name_(thread_name ? thread_name : "webrtc"),
#if defined(WEBRTC_WIN)
stop_(false),
thread_(NULL) {
#else
stop_event_(false, false),
thread_(0) {
#endif // defined(WEBRTC_WIN)
RTC_DCHECK(func);
RTC_DCHECK(name_.length() < 64);
}
PlatformThread::~PlatformThread() {
RTC_DCHECK(thread_checker_.CalledOnValidThread());
#if defined(WEBRTC_WIN)
RTC_DCHECK(!thread_);
#endif // defined(WEBRTC_WIN)
}
#if defined(WEBRTC_WIN)
DWORD WINAPI PlatformThread::StartThread(void* param) {
static_cast<PlatformThread*>(param)->Run();
return 0;
}
#else
void* PlatformThread::StartThread(void* param) {
static_cast<PlatformThread*>(param)->Run();
return 0;
}
#endif // defined(WEBRTC_WIN)
bool PlatformThread::Start() {
RTC_DCHECK(thread_checker_.CalledOnValidThread());
RTC_DCHECK(!thread_) << "Thread already started?";
#if defined(WEBRTC_WIN)
stop_ = false;
// See bug 2902 for background on STACK_SIZE_PARAM_IS_A_RESERVATION.
// Set the reserved stack stack size to 1M, which is the default on Windows
// and Linux.
DWORD thread_id;
thread_ = ::CreateThread(NULL, 1024 * 1024, &StartThread, this,
STACK_SIZE_PARAM_IS_A_RESERVATION, &thread_id);
RTC_CHECK(thread_) << "CreateThread failed";
#else
ThreadAttributes attr;
// Set the stack stack size to 1M.
pthread_attr_setstacksize(&attr, 1024 * 1024);
RTC_CHECK_EQ(0, pthread_create(&thread_, &attr, &StartThread, this));
#endif // defined(WEBRTC_WIN)
return true;
}
bool PlatformThread::Stop() {
RTC_DCHECK(thread_checker_.CalledOnValidThread());
#if defined(WEBRTC_WIN)
if (thread_) {
// Set stop_ to |true| on the worker thread.
QueueUserAPC(&RaiseFlag, thread_, reinterpret_cast<ULONG_PTR>(&stop_));
WaitForSingleObject(thread_, INFINITE);
CloseHandle(thread_);
thread_ = nullptr;
}
#else
if (!thread_)
return true;
stop_event_.Set();
RTC_CHECK_EQ(0, pthread_join(thread_, nullptr));
thread_ = 0;
#endif // defined(WEBRTC_WIN)
return true;
}
void PlatformThread::Run() {
if (!name_.empty())
rtc::SetCurrentThreadName(name_.c_str());
do {
// The interface contract of Start/Stop is that for a successfull call to
// Start, there should be at least one call to the run function. So we
// call the function before checking |stop_|.
if (!run_function_(obj_))
break;
#if defined(WEBRTC_WIN)
// Alertable sleep to permit RaiseFlag to run and update |stop_|.
SleepEx(0, true);
} while (!stop_);
#else
} while (!stop_event_.Wait(0));
#endif // defined(WEBRTC_WIN)
}
bool PlatformThread::SetPriority(ThreadPriority priority) {
RTC_DCHECK(thread_checker_.CalledOnValidThread());
#if defined(WEBRTC_WIN)
return thread_ && SetThreadPriority(thread_, priority);
#else
if (!thread_)
return false;
#if defined(WEBRTC_CHROMIUM_BUILD) && defined(WEBRTC_LINUX)
// TODO(tommi): Switch to the same mechanism as Chromium uses for
// changing thread priorities.
return true;
#else
#ifdef WEBRTC_THREAD_RR
const int policy = SCHED_RR;
#else
const int policy = SCHED_FIFO;
#endif
const int min_prio = sched_get_priority_min(policy);
const int max_prio = sched_get_priority_max(policy);
if (min_prio == -1 || max_prio == -1) {
return false;
}
if (max_prio - min_prio <= 2)
return false;
sched_param param;
param.sched_priority = ConvertToSystemPriority(priority, min_prio, max_prio);
if (pthread_setschedparam(thread_, policy, &param) != 0) {
return false;
}
return true;
#endif // defined(WEBRTC_CHROMIUM_BUILD) && defined(WEBRTC_LINUX)
#endif // defined(WEBRTC_WIN)
}
} // namespace webrtc

View File

@ -11,24 +11,16 @@
#ifndef WEBRTC_BASE_PLATFORM_THREAD_H_
#define WEBRTC_BASE_PLATFORM_THREAD_H_
#if defined(WEBRTC_WIN)
#include <winsock2.h>
#include <windows.h>
#elif defined(WEBRTC_POSIX)
#include <pthread.h>
#include <unistd.h>
#endif
#include <string>
#include "webrtc/base/constructormagic.h"
#include "webrtc/base/event.h"
#include "webrtc/base/platform_thread_types.h"
#include "webrtc/base/scoped_ptr.h"
#include "webrtc/base/thread_checker.h"
namespace rtc {
#if defined(WEBRTC_WIN)
typedef DWORD PlatformThreadId;
typedef DWORD PlatformThreadRef;
#elif defined(WEBRTC_POSIX)
typedef pid_t PlatformThreadId;
typedef pthread_t PlatformThreadRef;
#endif
PlatformThreadId CurrentThreadId();
PlatformThreadRef CurrentThreadRef();
@ -40,4 +32,96 @@ void SetCurrentThreadName(const char* name);
} // namespace rtc
// TODO(pbos): Merge with namespace rtc.
namespace webrtc {
// Callback function that the spawned thread will enter once spawned.
// A return value of false is interpreted as that the function has no
// more work to do and that the thread can be released.
typedef bool (*ThreadRunFunction)(void*);
enum ThreadPriority {
#ifdef WEBRTC_WIN
kLowPriority = THREAD_PRIORITY_BELOW_NORMAL,
kNormalPriority = THREAD_PRIORITY_NORMAL,
kHighPriority = THREAD_PRIORITY_ABOVE_NORMAL,
kHighestPriority = THREAD_PRIORITY_HIGHEST,
kRealtimePriority = THREAD_PRIORITY_TIME_CRITICAL
#else
kLowPriority = 1,
kNormalPriority = 2,
kHighPriority = 3,
kHighestPriority = 4,
kRealtimePriority = 5
#endif
};
// 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 PlatformThread {
public:
PlatformThread(ThreadRunFunction func, void* obj, const char* thread_name);
virtual ~PlatformThread();
// Factory method. Constructor disabled.
//
// func Pointer to a, by user, specified callback function.
// obj Object associated with the thread. Passed in the callback
// function.
// prio Thread priority. May require root/admin rights.
// thread_name NULL terminated thread name, will be visable in the Windows
// debugger.
// TODO(pbos): Move users onto explicit initialization/member ownership
// instead of additional heap allocation due to CreateThread.
static rtc::scoped_ptr<PlatformThread> CreateThread(ThreadRunFunction func,
void* obj,
const char* thread_name);
// Tries to spawns a thread and returns true if that was successful.
// Additionally, it tries to set thread priority according to the priority
// from when CreateThread was called. However, failure to set priority will
// not result in a false return value.
// TODO(pbos): Make void not war.
bool Start();
// Stops the spawned thread and waits for it to be reclaimed with a timeout
// of two seconds. Will return false if the thread was not reclaimed.
// Multiple tries to Stop are allowed (e.g. to wait longer than 2 seconds).
// It's ok to call Stop() even if the spawned thread has been reclaimed.
// TODO(pbos): Make void not war.
bool Stop();
// Set the priority of the worker thread. Must be called when thread
// is running.
bool SetPriority(ThreadPriority priority);
private:
void Run();
ThreadRunFunction const run_function_;
void* const obj_;
// TODO(pbos): Make sure call sites use string literals and update to a const
// char* instead of a std::string.
const std::string name_;
rtc::ThreadChecker thread_checker_;
#if defined(WEBRTC_WIN)
static DWORD WINAPI StartThread(void* param);
bool stop_;
HANDLE thread_;
#else
static void* StartThread(void* param);
rtc::Event stop_event_;
pthread_t thread_;
#endif // defined(WEBRTC_WIN)
RTC_DISALLOW_COPY_AND_ASSIGN(PlatformThread);
};
} // namespace webrtc
#endif // WEBRTC_BASE_PLATFORM_THREAD_H_

View File

@ -0,0 +1,32 @@
/*
* Copyright (c) 2015 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
#ifndef WEBRTC_BASE_PLATFORM_THREAD_TYPES_H_
#define WEBRTC_BASE_PLATFORM_THREAD_TYPES_H_
#if defined(WEBRTC_WIN)
#include <winsock2.h>
#include <windows.h>
#elif defined(WEBRTC_POSIX)
#include <pthread.h>
#include <unistd.h>
#endif
namespace rtc {
#if defined(WEBRTC_WIN)
typedef DWORD PlatformThreadId;
typedef DWORD PlatformThreadRef;
#elif defined(WEBRTC_POSIX)
typedef pid_t PlatformThreadId;
typedef pthread_t PlatformThreadRef;
#endif
} // namespace rtc
#endif // WEBRTC_BASE_PLATFORM_THREAD_TYPES_H_

View File

@ -8,7 +8,7 @@
* be found in the AUTHORS file in the root of the source tree.
*/
#include "webrtc/system_wrappers/include/thread_wrapper.h"
#include "webrtc/base/platform_thread.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "webrtc/base/scoped_ptr.h"
@ -22,9 +22,9 @@ bool NullRunFunction(void* obj) {
return true;
}
TEST(ThreadTest, StartStop) {
rtc::scoped_ptr<ThreadWrapper> thread = ThreadWrapper::CreateThread(
&NullRunFunction, nullptr, "ThreadTest");
TEST(PlatformThreadTest, StartStop) {
rtc::scoped_ptr<PlatformThread> thread = PlatformThread::CreateThread(
&NullRunFunction, nullptr, "PlatformThreadTest");
ASSERT_TRUE(thread->Start());
EXPECT_TRUE(thread->Stop());
}
@ -37,9 +37,9 @@ bool SetFlagRunFunction(void* obj) {
return true;
}
TEST(ThreadTest, RunFunctionIsCalled) {
TEST(PlatformThreadTest, RunFunctionIsCalled) {
bool flag = false;
rtc::scoped_ptr<ThreadWrapper> thread = ThreadWrapper::CreateThread(
rtc::scoped_ptr<PlatformThread> thread = PlatformThread::CreateThread(
&SetFlagRunFunction, &flag, "RunFunctionIsCalled");
ASSERT_TRUE(thread->Start());

View File

@ -12,6 +12,8 @@
#include "webrtc/base/thread_checker_impl.h"
#include "webrtc/base/platform_thread.h"
namespace rtc {
ThreadCheckerImpl::ThreadCheckerImpl() : valid_thread_(CurrentThreadRef()) {

View File

@ -14,7 +14,7 @@
#define WEBRTC_BASE_THREAD_CHECKER_IMPL_H_
#include "webrtc/base/criticalsection.h"
#include "webrtc/base/platform_thread.h"
#include "webrtc/base/platform_thread_types.h"
namespace rtc {

View File

@ -18,7 +18,7 @@
namespace webrtc {
class CriticalSectionWrapper;
class EventTimerWrapper;
class ThreadWrapper;
class PlatformThread;
class VideoRenderCallback {
public:
@ -77,7 +77,7 @@ class IncomingVideoStream : public VideoRenderCallback {
const rtc::scoped_ptr<CriticalSectionWrapper> stream_critsect_;
const rtc::scoped_ptr<CriticalSectionWrapper> thread_critsect_;
const rtc::scoped_ptr<CriticalSectionWrapper> buffer_critsect_;
rtc::scoped_ptr<ThreadWrapper> incoming_render_thread_
rtc::scoped_ptr<PlatformThread> incoming_render_thread_
GUARDED_BY(thread_critsect_);
rtc::scoped_ptr<EventTimerWrapper> deliver_buffer_event_;

View File

@ -21,11 +21,11 @@
#include <sys/time.h>
#endif
#include "webrtc/base/platform_thread.h"
#include "webrtc/common_video/libyuv/include/webrtc_libyuv.h"
#include "webrtc/common_video/video_render_frames.h"
#include "webrtc/system_wrappers/include/critical_section_wrapper.h"
#include "webrtc/system_wrappers/include/event_wrapper.h"
#include "webrtc/system_wrappers/include/thread_wrapper.h"
#include "webrtc/system_wrappers/include/tick_util.h"
#include "webrtc/system_wrappers/include/trace.h"
@ -131,7 +131,7 @@ int32_t IncomingVideoStream::Start() {
CriticalSectionScoped csT(thread_critsect_.get());
assert(incoming_render_thread_ == NULL);
incoming_render_thread_ = ThreadWrapper::CreateThread(
incoming_render_thread_ = PlatformThread::CreateThread(
IncomingVideoStreamThreadFun, this, "IncomingVideoStreamThread");
if (!incoming_render_thread_) {
return -1;
@ -155,7 +155,7 @@ int32_t IncomingVideoStream::Stop() {
return 0;
}
ThreadWrapper* thread = NULL;
PlatformThread* thread = NULL;
{
CriticalSectionScoped cs_thread(thread_critsect_.get());
if (incoming_render_thread_) {

View File

@ -20,7 +20,7 @@
namespace webrtc {
class CriticalSectionWrapper;
class EventTimerWrapper;
class ThreadWrapper;
class PlatformThread;
class VideoRenderCallback {
public:
@ -79,7 +79,7 @@ class IncomingVideoStream : public VideoRenderCallback {
const rtc::scoped_ptr<CriticalSectionWrapper> stream_critsect_;
const rtc::scoped_ptr<CriticalSectionWrapper> thread_critsect_;
const rtc::scoped_ptr<CriticalSectionWrapper> buffer_critsect_;
rtc::scoped_ptr<ThreadWrapper> incoming_render_thread_
rtc::scoped_ptr<PlatformThread> incoming_render_thread_
GUARDED_BY(thread_critsect_);
rtc::scoped_ptr<EventTimerWrapper> deliver_buffer_event_;

View File

@ -13,6 +13,7 @@
#include "testing/gtest/include/gtest/gtest.h"
#include "webrtc/base/md5digest.h"
#include "webrtc/base/platform_thread.h"
#include "webrtc/base/scoped_ptr.h"
#include "webrtc/base/thread_annotations.h"
#include "webrtc/modules/audio_coding/codecs/audio_encoder.h"
@ -38,7 +39,6 @@
#include "webrtc/system_wrappers/include/critical_section_wrapper.h"
#include "webrtc/system_wrappers/include/event_wrapper.h"
#include "webrtc/system_wrappers/include/sleep.h"
#include "webrtc/system_wrappers/include/thread_wrapper.h"
#include "webrtc/test/testsupport/fileutils.h"
#include "webrtc/test/testsupport/gtest_disable.h"
@ -457,11 +457,13 @@ class AudioCodingModuleMtTestOldApi : public AudioCodingModuleTestOldApi {
AudioCodingModuleMtTestOldApi()
: AudioCodingModuleTestOldApi(),
send_thread_(ThreadWrapper::CreateThread(CbSendThread, this, "send")),
insert_packet_thread_(ThreadWrapper::CreateThread(
CbInsertPacketThread, this, "insert_packet")),
pull_audio_thread_(ThreadWrapper::CreateThread(
CbPullAudioThread, this, "pull_audio")),
send_thread_(PlatformThread::CreateThread(CbSendThread, this, "send")),
insert_packet_thread_(PlatformThread::CreateThread(CbInsertPacketThread,
this,
"insert_packet")),
pull_audio_thread_(PlatformThread::CreateThread(CbPullAudioThread,
this,
"pull_audio")),
test_complete_(EventWrapper::Create()),
send_count_(0),
insert_packet_count_(0),
@ -571,9 +573,9 @@ class AudioCodingModuleMtTestOldApi : public AudioCodingModuleTestOldApi {
return true;
}
rtc::scoped_ptr<ThreadWrapper> send_thread_;
rtc::scoped_ptr<ThreadWrapper> insert_packet_thread_;
rtc::scoped_ptr<ThreadWrapper> pull_audio_thread_;
rtc::scoped_ptr<PlatformThread> send_thread_;
rtc::scoped_ptr<PlatformThread> insert_packet_thread_;
rtc::scoped_ptr<PlatformThread> pull_audio_thread_;
const rtc::scoped_ptr<EventWrapper> test_complete_;
int send_count_;
int insert_packet_count_;
@ -701,11 +703,11 @@ class AcmReRegisterIsacMtTestOldApi : public AudioCodingModuleTestOldApi {
AcmReRegisterIsacMtTestOldApi()
: AudioCodingModuleTestOldApi(),
receive_thread_(
ThreadWrapper::CreateThread(CbReceiveThread, this, "receive")),
PlatformThread::CreateThread(CbReceiveThread, this, "receive")),
codec_registration_thread_(
ThreadWrapper::CreateThread(CbCodecRegistrationThread,
this,
"codec_registration")),
PlatformThread::CreateThread(CbCodecRegistrationThread,
this,
"codec_registration")),
test_complete_(EventWrapper::Create()),
crit_sect_(CriticalSectionWrapper::CreateCriticalSection()),
codec_registered_(false),
@ -829,8 +831,8 @@ class AcmReRegisterIsacMtTestOldApi : public AudioCodingModuleTestOldApi {
return true;
}
rtc::scoped_ptr<ThreadWrapper> receive_thread_;
rtc::scoped_ptr<ThreadWrapper> codec_registration_thread_;
rtc::scoped_ptr<PlatformThread> receive_thread_;
rtc::scoped_ptr<PlatformThread> codec_registration_thread_;
const rtc::scoped_ptr<EventWrapper> test_complete_;
const rtc::scoped_ptr<CriticalSectionWrapper> crit_sect_;
bool codec_registered_ GUARDED_BY(crit_sect_);

View File

@ -20,13 +20,13 @@
#include <string>
#include "testing/gtest/include/gtest/gtest.h"
#include "webrtc/base/platform_thread.h"
#include "webrtc/common.h"
#include "webrtc/common_types.h"
#include "webrtc/engine_configurations.h"
#include "webrtc/modules/audio_coding/main/acm2/acm_common_defs.h"
#include "webrtc/modules/audio_coding/main/test/utility.h"
#include "webrtc/system_wrappers/include/event_wrapper.h"
#include "webrtc/system_wrappers/include/thread_wrapper.h"
#include "webrtc/system_wrappers/include/tick_util.h"
#include "webrtc/system_wrappers/include/trace.h"
#include "webrtc/test/testsupport/fileutils.h"
@ -522,37 +522,37 @@ void APITest::Perform() {
//--- THREADS
// A
// PUSH
rtc::scoped_ptr<ThreadWrapper> myPushAudioThreadA =
ThreadWrapper::CreateThread(PushAudioThreadA, this, "PushAudioThreadA");
rtc::scoped_ptr<PlatformThread> myPushAudioThreadA =
PlatformThread::CreateThread(PushAudioThreadA, this, "PushAudioThreadA");
CHECK_THREAD_NULLITY(myPushAudioThreadA, "Unable to start A::PUSH thread");
// PULL
rtc::scoped_ptr<ThreadWrapper> myPullAudioThreadA =
ThreadWrapper::CreateThread(PullAudioThreadA, this, "PullAudioThreadA");
rtc::scoped_ptr<PlatformThread> myPullAudioThreadA =
PlatformThread::CreateThread(PullAudioThreadA, this, "PullAudioThreadA");
CHECK_THREAD_NULLITY(myPullAudioThreadA, "Unable to start A::PULL thread");
// Process
rtc::scoped_ptr<ThreadWrapper> myProcessThreadA = ThreadWrapper::CreateThread(
ProcessThreadA, this, "ProcessThreadA");
rtc::scoped_ptr<PlatformThread> myProcessThreadA =
PlatformThread::CreateThread(ProcessThreadA, this, "ProcessThreadA");
CHECK_THREAD_NULLITY(myProcessThreadA, "Unable to start A::Process thread");
// API
rtc::scoped_ptr<ThreadWrapper> myAPIThreadA = ThreadWrapper::CreateThread(
APIThreadA, this, "APIThreadA");
rtc::scoped_ptr<PlatformThread> myAPIThreadA =
PlatformThread::CreateThread(APIThreadA, this, "APIThreadA");
CHECK_THREAD_NULLITY(myAPIThreadA, "Unable to start A::API thread");
// B
// PUSH
rtc::scoped_ptr<ThreadWrapper> myPushAudioThreadB =
ThreadWrapper::CreateThread(PushAudioThreadB, this, "PushAudioThreadB");
rtc::scoped_ptr<PlatformThread> myPushAudioThreadB =
PlatformThread::CreateThread(PushAudioThreadB, this, "PushAudioThreadB");
CHECK_THREAD_NULLITY(myPushAudioThreadB, "Unable to start B::PUSH thread");
// PULL
rtc::scoped_ptr<ThreadWrapper> myPullAudioThreadB =
ThreadWrapper::CreateThread(PullAudioThreadB, this, "PullAudioThreadB");
rtc::scoped_ptr<PlatformThread> myPullAudioThreadB =
PlatformThread::CreateThread(PullAudioThreadB, this, "PullAudioThreadB");
CHECK_THREAD_NULLITY(myPullAudioThreadB, "Unable to start B::PULL thread");
// Process
rtc::scoped_ptr<ThreadWrapper> myProcessThreadB = ThreadWrapper::CreateThread(
ProcessThreadB, this, "ProcessThreadB");
rtc::scoped_ptr<PlatformThread> myProcessThreadB =
PlatformThread::CreateThread(ProcessThreadB, this, "ProcessThreadB");
CHECK_THREAD_NULLITY(myProcessThreadB, "Unable to start B::Process thread");
// API
rtc::scoped_ptr<ThreadWrapper> myAPIThreadB = ThreadWrapper::CreateThread(
APIThreadB, this, "APIThreadB");
rtc::scoped_ptr<PlatformThread> myAPIThreadB =
PlatformThread::CreateThread(APIThreadB, this, "APIThreadB");
CHECK_THREAD_NULLITY(myAPIThreadB, "Unable to start B::API thread");
//_apiEventA->StartTimer(true, 5000);

View File

@ -7,9 +7,9 @@
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
#include "webrtc/base/platform_thread.h"
#include "webrtc/modules/audio_device/dummy/file_audio_device.h"
#include "webrtc/system_wrappers/include/sleep.h"
#include "webrtc/system_wrappers/include/thread_wrapper.h"
namespace webrtc {
@ -214,8 +214,8 @@ int32_t FileAudioDevice::StartPlayout() {
}
const char* threadName = "webrtc_audio_module_play_thread";
_ptrThreadPlay = ThreadWrapper::CreateThread(PlayThreadFunc, this,
threadName);
_ptrThreadPlay =
PlatformThread::CreateThread(PlayThreadFunc, this, threadName);
if (!_ptrThreadPlay->Start()) {
_ptrThreadPlay.reset();
_playing = false;
@ -277,7 +277,7 @@ int32_t FileAudioDevice::StartRecording() {
}
const char* threadName = "webrtc_audio_module_capture_thread";
_ptrThreadRec = ThreadWrapper::CreateThread(RecThreadFunc, this, threadName);
_ptrThreadRec = PlatformThread::CreateThread(RecThreadFunc, this, threadName);
if (!_ptrThreadRec->Start()) {
_ptrThreadRec.reset();

View File

@ -22,7 +22,7 @@
namespace webrtc {
class EventWrapper;
class ThreadWrapper;
class PlatformThread;
// This is a fake audio device which plays audio from a file as its microphone
// and plays out into a file.
@ -178,8 +178,8 @@ class FileAudioDevice : public AudioDeviceGeneric {
size_t _recordingFramesIn10MS;
size_t _playoutFramesIn10MS;
rtc::scoped_ptr<ThreadWrapper> _ptrThreadRec;
rtc::scoped_ptr<ThreadWrapper> _ptrThreadPlay;
rtc::scoped_ptr<PlatformThread> _ptrThreadRec;
rtc::scoped_ptr<PlatformThread> _ptrThreadPlay;
bool _playing;
bool _recording;

View File

@ -207,7 +207,7 @@ int32_t AudioDeviceLinuxALSA::Terminate()
// RECORDING
if (_ptrThreadRec)
{
ThreadWrapper* tmpThread = _ptrThreadRec.release();
PlatformThread* tmpThread = _ptrThreadRec.release();
_critSect.Leave();
tmpThread->Stop();
@ -219,7 +219,7 @@ int32_t AudioDeviceLinuxALSA::Terminate()
// PLAYOUT
if (_ptrThreadPlay)
{
ThreadWrapper* tmpThread = _ptrThreadPlay.release();
PlatformThread* tmpThread = _ptrThreadPlay.release();
_critSect.Leave();
tmpThread->Stop();
@ -1364,8 +1364,8 @@ int32_t AudioDeviceLinuxALSA::StartRecording()
}
// RECORDING
const char* threadName = "webrtc_audio_module_capture_thread";
_ptrThreadRec = ThreadWrapper::CreateThread(
RecThreadFunc, this, threadName);
_ptrThreadRec =
PlatformThread::CreateThread(RecThreadFunc, this, threadName);
if (!_ptrThreadRec->Start())
{
@ -1518,8 +1518,8 @@ int32_t AudioDeviceLinuxALSA::StartPlayout()
// PLAYOUT
const char* threadName = "webrtc_audio_module_play_thread";
_ptrThreadPlay = ThreadWrapper::CreateThread(PlayThreadFunc, this,
threadName);
_ptrThreadPlay =
PlatformThread::CreateThread(PlayThreadFunc, this, threadName);
if (!_ptrThreadPlay->Start())
{
WEBRTC_TRACE(kTraceCritical, kTraceAudioDevice, _id,

View File

@ -11,10 +11,10 @@
#ifndef WEBRTC_AUDIO_DEVICE_AUDIO_DEVICE_ALSA_LINUX_H
#define WEBRTC_AUDIO_DEVICE_AUDIO_DEVICE_ALSA_LINUX_H
#include "webrtc/base/platform_thread.h"
#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/include/critical_section_wrapper.h"
#include "webrtc/system_wrappers/include/thread_wrapper.h"
#if defined(USE_X11)
#include <X11/Xlib.h>
@ -185,8 +185,8 @@ private:
CriticalSectionWrapper& _critSect;
rtc::scoped_ptr<ThreadWrapper> _ptrThreadRec;
rtc::scoped_ptr<ThreadWrapper> _ptrThreadPlay;
rtc::scoped_ptr<PlatformThread> _ptrThreadRec;
rtc::scoped_ptr<PlatformThread> _ptrThreadPlay;
int32_t _id;

View File

@ -201,8 +201,8 @@ int32_t AudioDeviceLinuxPulse::Init()
// RECORDING
const char* threadName = "webrtc_audio_module_rec_thread";
_ptrThreadRec = ThreadWrapper::CreateThread(RecThreadFunc, this,
threadName);
_ptrThreadRec =
PlatformThread::CreateThread(RecThreadFunc, this, threadName);
if (!_ptrThreadRec->Start())
{
WEBRTC_TRACE(kTraceCritical, kTraceAudioDevice, _id,
@ -216,8 +216,8 @@ int32_t AudioDeviceLinuxPulse::Init()
// PLAYOUT
threadName = "webrtc_audio_module_play_thread";
_ptrThreadPlay = ThreadWrapper::CreateThread(PlayThreadFunc, this,
threadName);
_ptrThreadPlay =
PlatformThread::CreateThread(PlayThreadFunc, this, threadName);
if (!_ptrThreadPlay->Start())
{
WEBRTC_TRACE(kTraceCritical, kTraceAudioDevice, _id,
@ -246,7 +246,7 @@ int32_t AudioDeviceLinuxPulse::Terminate()
// RECORDING
if (_ptrThreadRec)
{
ThreadWrapper* tmpThread = _ptrThreadRec.release();
PlatformThread* tmpThread = _ptrThreadRec.release();
_timeEventRec.Set();
tmpThread->Stop();
@ -256,7 +256,7 @@ int32_t AudioDeviceLinuxPulse::Terminate()
// PLAYOUT
if (_ptrThreadPlay)
{
ThreadWrapper* tmpThread = _ptrThreadPlay.release();
PlatformThread* tmpThread = _ptrThreadPlay.release();
_timeEventPlay.Set();
tmpThread->Stop();

View File

@ -11,11 +11,11 @@
#ifndef WEBRTC_AUDIO_DEVICE_AUDIO_DEVICE_PULSE_LINUX_H
#define WEBRTC_AUDIO_DEVICE_AUDIO_DEVICE_PULSE_LINUX_H
#include "webrtc/base/platform_thread.h"
#include "webrtc/base/thread_checker.h"
#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/include/critical_section_wrapper.h"
#include "webrtc/system_wrappers/include/thread_wrapper.h"
#include "webrtc/base/thread_checker.h"
#include <X11/Xlib.h>
#include <pulse/pulseaudio.h>
@ -284,8 +284,8 @@ private:
EventWrapper& _recStartEvent;
EventWrapper& _playStartEvent;
rtc::scoped_ptr<ThreadWrapper> _ptrThreadPlay;
rtc::scoped_ptr<ThreadWrapper> _ptrThreadRec;
rtc::scoped_ptr<PlatformThread> _ptrThreadPlay;
rtc::scoped_ptr<PlatformThread> _ptrThreadRec;
int32_t _id;
AudioMixerManagerLinuxPulse _mixerManager;

View File

@ -10,11 +10,11 @@
#include "webrtc/base/arraysize.h"
#include "webrtc/base/checks.h"
#include "webrtc/base/platform_thread.h"
#include "webrtc/modules/audio_device/audio_device_config.h"
#include "webrtc/modules/audio_device/mac/audio_device_mac.h"
#include "webrtc/modules/audio_device/mac/portaudio/pa_ringbuffer.h"
#include "webrtc/system_wrappers/include/event_wrapper.h"
#include "webrtc/system_wrappers/include/thread_wrapper.h"
#include "webrtc/system_wrappers/include/trace.h"
#include <ApplicationServices/ApplicationServices.h>
@ -1666,7 +1666,7 @@ int32_t AudioDeviceMac::StartRecording()
RTC_DCHECK(!capture_worker_thread_.get());
capture_worker_thread_ =
ThreadWrapper::CreateThread(RunCapture, this, "CaptureWorkerThread");
PlatformThread::CreateThread(RunCapture, this, "CaptureWorkerThread");
RTC_DCHECK(capture_worker_thread_.get());
capture_worker_thread_->Start();
capture_worker_thread_->SetPriority(kRealtimePriority);
@ -1821,7 +1821,7 @@ int32_t AudioDeviceMac::StartPlayout()
RTC_DCHECK(!render_worker_thread_.get());
render_worker_thread_ =
ThreadWrapper::CreateThread(RunRender, this, "RenderWorkerThread");
PlatformThread::CreateThread(RunRender, this, "RenderWorkerThread");
render_worker_thread_->Start();
render_worker_thread_->SetPriority(kRealtimePriority);

View File

@ -26,7 +26,7 @@ struct PaUtilRingBuffer;
namespace webrtc
{
class EventWrapper;
class ThreadWrapper;
class PlatformThread;
const uint32_t N_REC_SAMPLES_PER_SEC = 48000;
const uint32_t N_PLAY_SAMPLES_PER_SEC = 48000;
@ -283,10 +283,10 @@ private:
EventWrapper& _stopEvent;
// Only valid/running between calls to StartRecording and StopRecording.
rtc::scoped_ptr<ThreadWrapper> capture_worker_thread_;
rtc::scoped_ptr<PlatformThread> capture_worker_thread_;
// Only valid/running between calls to StartPlayout and StopPlayout.
rtc::scoped_ptr<ThreadWrapper> render_worker_thread_;
rtc::scoped_ptr<PlatformThread> render_worker_thread_;
int32_t _id;

View File

@ -686,7 +686,7 @@ int32_t FuncTestManager::Close()
_audioDevice = NULL;
}
// return the ThreadWrapper (singleton)
// return the PlatformThread (singleton)
Trace::ReturnTrace();
// PRINT_TEST_RESULTS;

View File

@ -228,7 +228,7 @@ int32_t AudioDeviceWindowsWave::Init()
}
const char* threadName = "webrtc_audio_module_thread";
_ptrThread = ThreadWrapper::CreateThread(ThreadFunc, this, threadName);
_ptrThread = PlatformThread::CreateThread(ThreadFunc, this, threadName);
if (!_ptrThread->Start())
{
WEBRTC_TRACE(kTraceCritical, kTraceAudioDevice, _id,
@ -250,12 +250,8 @@ int32_t AudioDeviceWindowsWave::Init()
WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id,
"periodic timer (dT=%d) is now active", TIMER_PERIOD_MS);
_hGetCaptureVolumeThread = CreateThread(NULL,
0,
GetCaptureVolumeThread,
this,
0,
NULL);
_hGetCaptureVolumeThread =
CreateThread(NULL, 0, GetCaptureVolumeThread, this, 0, NULL);
if (_hGetCaptureVolumeThread == NULL)
{
WEBRTC_TRACE(kTraceError, kTraceAudioDevice, _id,
@ -265,12 +261,8 @@ int32_t AudioDeviceWindowsWave::Init()
SetThreadPriority(_hGetCaptureVolumeThread, THREAD_PRIORITY_NORMAL);
_hSetCaptureVolumeThread = CreateThread(NULL,
0,
SetCaptureVolumeThread,
this,
0,
NULL);
_hSetCaptureVolumeThread =
CreateThread(NULL, 0, SetCaptureVolumeThread, this, 0, NULL);
if (_hSetCaptureVolumeThread == NULL)
{
WEBRTC_TRACE(kTraceError, kTraceAudioDevice, _id,
@ -303,7 +295,7 @@ int32_t AudioDeviceWindowsWave::Terminate()
if (_ptrThread)
{
ThreadWrapper* tmpThread = _ptrThread.release();
PlatformThread* tmpThread = _ptrThread.release();
_critSect.Leave();
_timeEvent.Set();

View File

@ -11,9 +11,9 @@
#ifndef WEBRTC_AUDIO_DEVICE_AUDIO_DEVICE_WAVE_WIN_H
#define WEBRTC_AUDIO_DEVICE_AUDIO_DEVICE_WAVE_WIN_H
#include "webrtc/base/platform_thread.h"
#include "webrtc/modules/audio_device/audio_device_generic.h"
#include "webrtc/modules/audio_device/win/audio_mixer_manager_win.h"
#include "webrtc/system_wrappers/include/thread_wrapper.h"
#pragma comment( lib, "winmm.lib" )
@ -222,7 +222,7 @@ private:
HANDLE _hShutdownSetVolumeEvent;
HANDLE _hSetCaptureVolumeEvent;
rtc::scoped_ptr<ThreadWrapper> _ptrThread;
rtc::scoped_ptr<PlatformThread> _ptrThread;
CriticalSectionWrapper& _critSectCb;

View File

@ -16,12 +16,12 @@
#include "testing/gtest/include/gtest/gtest.h"
#include "webrtc/base/array_view.h"
#include "webrtc/base/criticalsection.h"
#include "webrtc/base/platform_thread.h"
#include "webrtc/config.h"
#include "webrtc/modules/audio_processing/test/test_utils.h"
#include "webrtc/modules/include/module_common_types.h"
#include "webrtc/system_wrappers/include/event_wrapper.h"
#include "webrtc/system_wrappers/include/sleep.h"
#include "webrtc/system_wrappers/include/thread_wrapper.h"
#include "webrtc/test/random.h"
namespace webrtc {
@ -456,9 +456,9 @@ class AudioProcessingImplLockTest
const rtc::scoped_ptr<EventWrapper> test_complete_;
// Thread related variables.
rtc::scoped_ptr<ThreadWrapper> render_thread_;
rtc::scoped_ptr<ThreadWrapper> capture_thread_;
rtc::scoped_ptr<ThreadWrapper> stats_thread_;
rtc::scoped_ptr<PlatformThread> render_thread_;
rtc::scoped_ptr<PlatformThread> capture_thread_;
rtc::scoped_ptr<PlatformThread> stats_thread_;
mutable test::Random rand_gen_;
rtc::scoped_ptr<AudioProcessing> apm_;
@ -472,14 +472,15 @@ class AudioProcessingImplLockTest
AudioProcessingImplLockTest::AudioProcessingImplLockTest()
: test_complete_(EventWrapper::Create()),
render_thread_(ThreadWrapper::CreateThread(RenderProcessorThreadFunc,
this,
"render")),
capture_thread_(ThreadWrapper::CreateThread(CaptureProcessorThreadFunc,
render_thread_(PlatformThread::CreateThread(RenderProcessorThreadFunc,
this,
"capture")),
stats_thread_(
ThreadWrapper::CreateThread(StatsProcessorThreadFunc, this, "stats")),
"render")),
capture_thread_(PlatformThread::CreateThread(CaptureProcessorThreadFunc,
this,
"capture")),
stats_thread_(PlatformThread::CreateThread(StatsProcessorThreadFunc,
this,
"stats")),
rand_gen_(42U),
apm_(AudioProcessingImpl::Create()),
render_thread_state_(kMaxFrameSize,

View File

@ -895,8 +895,8 @@ _numPlots(0)
{
_eventPtr = EventWrapper::Create();
_plotThread = ThreadWrapper::CreateThread(MatlabEngine::PlotThread, this,
kLowPriority, "MatlabPlot");
_plotThread = PlatformThread::CreateThread(MatlabEngine::PlotThread, this,
kLowPriority, "MatlabPlot");
_running = true;
_plotThread->Start();
}

View File

@ -15,8 +15,8 @@
#include <string>
#include <vector>
#include "webrtc/base/platform_thread.h"
#include "webrtc/typedefs.h"
#include "webrtc/system_wrappers/include/thread_wrapper.h"
namespace webrtc {
class CriticalSectionWrapper;
@ -160,7 +160,7 @@ private:
std::vector<MatlabPlot *> _plots;
webrtc::CriticalSectionWrapper *_critSect;
webrtc::EventWrapper *_eventPtr;
rtc::scoped_ptr<webrtc::ThreadWrapper> _plotThread;
rtc::scoped_ptr<webrtc::PlatformThread> _plotThread;
bool _running;
int _numPlots;
};

View File

@ -76,8 +76,8 @@ int32_t TestLoadGenerator::Start (const char *threadName)
_eventPtr = EventWrapper::Create();
_genThread = ThreadWrapper::CreateThread(SenderThreadFunction, this,
threadName);
_genThread =
PlatformThread::CreateThread(SenderThreadFunction, this, threadName);
_running = true;
_genThread->Start();

View File

@ -13,8 +13,8 @@
#include <stdlib.h>
#include "webrtc/base/platform_thread.h"
#include "webrtc/modules/include/module_common_types.h"
#include "webrtc/system_wrappers/include/thread_wrapper.h"
#include "webrtc/typedefs.h"
class TestSenderReceiver;
@ -44,7 +44,7 @@ protected:
webrtc::CriticalSectionWrapper* _critSect;
webrtc::EventWrapper *_eventPtr;
rtc::scoped_ptr<webrtc::ThreadWrapper> _genThread;
rtc::scoped_ptr<webrtc::PlatformThread> _genThread;
int32_t _bitrateKbps;
TestSenderReceiver *_sender;
bool _running;

View File

@ -162,8 +162,8 @@ int32_t TestSenderReceiver::Start()
exit(1);
}
_procThread = ThreadWrapper::CreateThread(ProcThreadFunction, this,
"TestSenderReceiver");
_procThread = PlatformThread::CreateThread(ProcThreadFunction, this,
"TestSenderReceiver");
_running = true;

View File

@ -11,9 +11,9 @@
#ifndef WEBRTC_MODULES_RTP_RTCP_TEST_BWESTANDALONE_TESTSENDERRECEIVER_H_
#define WEBRTC_MODULES_RTP_RTCP_TEST_BWESTANDALONE_TESTSENDERRECEIVER_H_
#include "webrtc/base/platform_thread.h"
#include "webrtc/modules/rtp_rtcp/include/rtp_rtcp.h"
#include "webrtc/modules/rtp_rtcp/include/rtp_rtcp_defines.h"
#include "webrtc/system_wrappers/include/thread_wrapper.h"
#include "webrtc/test/channel_transport/udp_transport.h"
#include "webrtc/typedefs.h"
@ -138,7 +138,7 @@ private:
UdpTransport* _transport;
webrtc::CriticalSectionWrapper* _critSect;
webrtc::EventWrapper *_eventPtr;
rtc::scoped_ptr<webrtc::ThreadWrapper> _procThread;
rtc::scoped_ptr<webrtc::PlatformThread> _procThread;
bool _running;
int8_t _payloadType;
TestLoadGenerator* _loadGenerator;

View File

@ -17,6 +17,7 @@
#include <list>
#include "webrtc/base/platform_thread.h"
#include "webrtc/common_audio/resampler/include/resampler.h"
#include "webrtc/common_types.h"
#include "webrtc/engine_configurations.h"
@ -26,7 +27,6 @@
#include "webrtc/modules/utility/include/file_recorder.h"
#include "webrtc/modules/utility/source/coder.h"
#include "webrtc/system_wrappers/include/event_wrapper.h"
#include "webrtc/system_wrappers/include/thread_wrapper.h"
#include "webrtc/system_wrappers/include/tick_util.h"
#include "webrtc/typedefs.h"

View File

@ -76,8 +76,8 @@ void ProcessThreadImpl::Start() {
m.module->ProcessThreadAttached(this);
}
thread_ = ThreadWrapper::CreateThread(&ProcessThreadImpl::Run, this,
thread_name_);
thread_ =
PlatformThread::CreateThread(&ProcessThreadImpl::Run, this, thread_name_);
RTC_CHECK(thread_->Start());
}

View File

@ -15,10 +15,10 @@
#include <queue>
#include "webrtc/base/criticalsection.h"
#include "webrtc/base/platform_thread.h"
#include "webrtc/base/thread_checker.h"
#include "webrtc/modules/utility/include/process_thread.h"
#include "webrtc/system_wrappers/include/event_wrapper.h"
#include "webrtc/system_wrappers/include/thread_wrapper.h"
#include "webrtc/typedefs.h"
namespace webrtc {
@ -70,7 +70,7 @@ class ProcessThreadImpl : public ProcessThread {
rtc::ThreadChecker thread_checker_;
const rtc::scoped_ptr<EventWrapper> wake_up_;
rtc::scoped_ptr<ThreadWrapper> thread_;
rtc::scoped_ptr<PlatformThread> thread_;
ModuleList modules_;
// TODO(tommi): Support delayed tasks.

View File

@ -280,7 +280,7 @@ int32_t VideoCaptureModuleV4L2::StartCapture(
//start capture thread;
if (!_captureThread)
{
_captureThread = ThreadWrapper::CreateThread(
_captureThread = PlatformThread::CreateThread(
VideoCaptureModuleV4L2::CaptureThread, this, "CaptureThread");
_captureThread->Start();
_captureThread->SetPriority(kHighPriority);

View File

@ -11,9 +11,9 @@
#ifndef WEBRTC_MODULES_VIDEO_CAPTURE_MAIN_SOURCE_LINUX_VIDEO_CAPTURE_LINUX_H_
#define WEBRTC_MODULES_VIDEO_CAPTURE_MAIN_SOURCE_LINUX_VIDEO_CAPTURE_LINUX_H_
#include "webrtc/base/platform_thread.h"
#include "webrtc/common_types.h"
#include "webrtc/modules/video_capture/video_capture_impl.h"
#include "webrtc/system_wrappers/include/thread_wrapper.h"
namespace webrtc
{
@ -39,7 +39,7 @@ private:
bool AllocateVideoBuffers();
bool DeAllocateVideoBuffers();
rtc::scoped_ptr<ThreadWrapper> _captureThread;
rtc::scoped_ptr<PlatformThread> _captureThread;
CriticalSectionWrapper* _captureCritSect;
int32_t _deviceId;

View File

@ -141,8 +141,8 @@ int32_t VideoRenderAndroid::StartRender() {
return 0;
}
_javaRenderThread = ThreadWrapper::CreateThread(JavaRenderThreadFun, this,
"AndroidRenderThread");
_javaRenderThread = PlatformThread::CreateThread(JavaRenderThreadFun, this,
"AndroidRenderThread");
if (_javaRenderThread->Start())
WEBRTC_TRACE(kTraceInfo, kTraceVideoRenderer, _id,

View File

@ -15,8 +15,8 @@
#include <map>
#include "webrtc/base/platform_thread.h"
#include "webrtc/modules/video_render/i_video_render.h"
#include "webrtc/system_wrappers/include/thread_wrapper.h"
namespace webrtc {
@ -144,7 +144,7 @@ class VideoRenderAndroid: IVideoRender {
EventWrapper& _javaRenderEvent;
int64_t _lastJavaRenderEvent;
JNIEnv* _javaRenderJniEnv; // JNIEnv for the java render thread.
rtc::scoped_ptr<ThreadWrapper> _javaRenderThread;
rtc::scoped_ptr<PlatformThread> _javaRenderThread;
};
} // namespace webrtc

View File

@ -14,10 +14,10 @@
#include <list>
#include <map>
#include "webrtc/base/platform_thread.h"
#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/include/thread_wrapper.h"
namespace webrtc {
@ -64,7 +64,7 @@ class VideoRenderIosGles20 {
private:
rtc::scoped_ptr<CriticalSectionWrapper> gles_crit_sec_;
EventTimerWrapper* screen_update_event_;
rtc::scoped_ptr<ThreadWrapper> screen_update_thread_;
rtc::scoped_ptr<PlatformThread> screen_update_thread_;
VideoRenderIosView* view_;
Rect window_rect_;

View File

@ -32,7 +32,7 @@ VideoRenderIosGles20::VideoRenderIosGles20(VideoRenderIosView* view,
z_order_to_channel_(),
gles_context_([view context]),
is_rendering_(true) {
screen_update_thread_ = ThreadWrapper::CreateThread(
screen_update_thread_ = PlatformThread::CreateThread(
ScreenUpdateThreadProc, this, "ScreenUpdateGles20");
screen_update_event_ = EventTimerWrapper::Create();
GetWindowRect(window_rect_);
@ -40,7 +40,7 @@ VideoRenderIosGles20::VideoRenderIosGles20(VideoRenderIosView* view,
VideoRenderIosGles20::~VideoRenderIosGles20() {
// Signal event to exit thread, then delete it
ThreadWrapper* thread_wrapper = screen_update_thread_.release();
PlatformThread* thread_wrapper = screen_update_thread_.release();
if (thread_wrapper) {
screen_update_event_->Set();

View File

@ -395,8 +395,8 @@ _renderingIsPaused( false),
{
//WEBRTC_TRACE(kTraceInfo, kTraceVideoRenderer, _id, "%s");
_screenUpdateThread = ThreadWrapper::CreateThread(
ScreenUpdateThreadProc, this, "ScreenUpdate");
_screenUpdateThread = PlatformThread::CreateThread(ScreenUpdateThreadProc,
this, "ScreenUpdate");
_screenUpdateEvent = EventWrapper::Create();
if(!IsValidWindowPtr(_windowRef))
@ -512,7 +512,7 @@ _renderingIsPaused( false),
//WEBRTC_TRACE(kTraceDebug, "%s:%d Constructor", __FUNCTION__, __LINE__);
// _renderCritSec = CriticalSectionWrapper::CreateCriticalSection();
_screenUpdateThread = ThreadWrapper::CreateThread(
_screenUpdateThread = PlatformThread::CreateThread(
ScreenUpdateThreadProc, this, "ScreenUpdateThread");
_screenUpdateEvent = EventWrapper::Create();
@ -677,7 +677,7 @@ VideoRenderAGL::~VideoRenderAGL()
#endif
// Signal event to exit thread, then delete it
ThreadWrapper* tmpPtr = _screenUpdateThread.release();
PlatformThread* tmpPtr = _screenUpdateThread.release();
if (tmpPtr)
{
@ -856,7 +856,7 @@ int VideoRenderAGL::DeleteAGLChannel(int channel)
int VideoRenderAGL::StopThread()
{
CriticalSectionScoped cs(&_renderCritSec);
ThreadWrapper* tmpPtr = _screenUpdateThread.release();
PlatformThread* tmpPtr = _screenUpdateThread.release();
if (tmpPtr)
{
@ -1891,8 +1891,8 @@ int32_t VideoRenderAGL::StartRender()
return 0;
}
_screenUpdateThread = ThreadWrapper::CreateThread(ScreenUpdateThreadProc,
this, "ScreenUpdate");
_screenUpdateThread = PlatformThread::CreateThread(ScreenUpdateThreadProc,
this, "ScreenUpdate");
_screenUpdateEvent = EventWrapper::Create();
if (!_screenUpdateThread)

View File

@ -15,8 +15,8 @@
#ifndef WEBRTC_MODULES_VIDEO_RENDER_MAIN_SOURCE_MAC_VIDEO_RENDER_AGL_H_
#define WEBRTC_MODULES_VIDEO_RENDER_MAIN_SOURCE_MAC_VIDEO_RENDER_AGL_H_
#include "webrtc/base/platform_thread.h"
#include "webrtc/modules/video_render/video_render_defines.h"
#include "webrtc/system_wrappers/include/thread_wrapper.h"
#define NEW_HIVIEW_PARENT_EVENT_HANDLER 1
#define NEW_HIVIEW_EVENT_HANDLER 1
@ -142,7 +142,7 @@ class VideoRenderAGL {
bool _fullScreen;
int _id;
webrtc::CriticalSectionWrapper& _renderCritSec;
rtc::scoped_ptr<webrtc::ThreadWrapper> _screenUpdateThread;
rtc::scoped_ptr<webrtc::PlatformThread> _screenUpdateThread;
webrtc::EventWrapper* _screenUpdateEvent;
bool _isHIViewRef;
AGLContext _aglContext;

View File

@ -32,7 +32,7 @@ class Trace;
namespace webrtc {
class EventTimerWrapper;
class ThreadWrapper;
class PlatformThread;
class VideoRenderNSOpenGL;
class CriticalSectionWrapper;
@ -166,7 +166,7 @@ private: // variables
bool _fullScreen;
int _id;
CriticalSectionWrapper& _nsglContextCritSec;
rtc::scoped_ptr<ThreadWrapper> _screenUpdateThread;
rtc::scoped_ptr<PlatformThread> _screenUpdateThread;
EventTimerWrapper* _screenUpdateEvent;
NSOpenGLContext* _nsglContext;
NSOpenGLContext* _nsglFullScreenContext;

View File

@ -11,11 +11,11 @@
#include "webrtc/engine_configurations.h"
#if defined(COCOA_RENDERING)
#include "webrtc/base/platform_thread.h"
#include "webrtc/common_video/libyuv/include/webrtc_libyuv.h"
#include "webrtc/modules/video_render/mac/video_render_nsopengl.h"
#include "webrtc/system_wrappers/include/critical_section_wrapper.h"
#include "webrtc/system_wrappers/include/event_wrapper.h"
#include "webrtc/system_wrappers/include/thread_wrapper.h"
#include "webrtc/system_wrappers/include/trace.h"
namespace webrtc {
@ -378,8 +378,8 @@ _renderingIsPaused (FALSE),
_windowRefSuperView(NULL),
_windowRefSuperViewFrame(NSMakeRect(0,0,0,0))
{
_screenUpdateThread = ThreadWrapper::CreateThread(ScreenUpdateThreadProc,
this, "ScreenUpdateNSOpenGL");
_screenUpdateThread = PlatformThread::CreateThread(
ScreenUpdateThreadProc, this, "ScreenUpdateNSOpenGL");
}
int VideoRenderNSOpenGL::ChangeWindow(CocoaRenderView* newWindowRef)
@ -657,7 +657,7 @@ VideoRenderNSOpenGL::~VideoRenderNSOpenGL()
}
// Signal event to exit thread, then delete it
ThreadWrapper* tmpPtr = _screenUpdateThread.release();
PlatformThread* tmpPtr = _screenUpdateThread.release();
if (tmpPtr)
{
@ -864,7 +864,7 @@ int32_t VideoRenderNSOpenGL::GetChannelProperties(const uint16_t streamId,
int VideoRenderNSOpenGL::StopThread()
{
ThreadWrapper* tmpPtr = _screenUpdateThread.release();
PlatformThread* tmpPtr = _screenUpdateThread.release();
WEBRTC_TRACE(kTraceInfo, kTraceVideoRenderer, _id,
"%s Stopping thread ", __FUNCTION__, tmpPtr);

View File

@ -294,7 +294,7 @@ VideoRenderDirect3D9::VideoRenderDirect3D9(Trace* trace,
_totalMemory(0),
_availableMemory(0)
{
_screenUpdateThread = ThreadWrapper::CreateThread(
_screenUpdateThread = PlatformThread::CreateThread(
ScreenUpdateThreadProc, this, "ScreenUpdateThread");
_screenUpdateEvent = EventTimerWrapper::Create();
SetRect(&_originalHwndRect, 0, 0, 0, 0);
@ -305,7 +305,7 @@ VideoRenderDirect3D9::~VideoRenderDirect3D9()
//NOTE: we should not enter CriticalSection in here!
// Signal event to exit thread, then delete it
ThreadWrapper* tmpPtr = _screenUpdateThread.release();
PlatformThread* tmpPtr = _screenUpdateThread.release();
if (tmpPtr)
{
_screenUpdateEvent->Set();

View File

@ -19,8 +19,8 @@
#include <Map>
// Added
#include "webrtc/base/platform_thread.h"
#include "webrtc/modules/video_render/video_render_defines.h"
#include "webrtc/system_wrappers/include/thread_wrapper.h"
#pragma comment(lib, "d3d9.lib") // located in DirectX SDK
@ -203,7 +203,7 @@ private:
CriticalSectionWrapper& _refD3DCritsect;
Trace* _trace;
rtc::scoped_ptr<ThreadWrapper> _screenUpdateThread;
rtc::scoped_ptr<PlatformThread> _screenUpdateThread;
EventTimerWrapper* _screenUpdateEvent;
HWND _hWnd;

View File

@ -37,7 +37,6 @@ static_library("system_wrappers") {
"include/static_instance.h",
"include/stl_util.h",
"include/stringize_macros.h",
"include/thread_wrapper.h",
"include/tick_util.h",
"include/timestamp_extrapolator.h",
"include/trace.h",
@ -79,11 +78,6 @@ static_library("system_wrappers") {
"source/rw_lock_win.h",
"source/sleep.cc",
"source/sort.cc",
"source/thread.cc",
"source/thread_posix.cc",
"source/thread_posix.h",
"source/thread_win.cc",
"source/thread_win.h",
"source/tick_util.cc",
"source/timestamp_extrapolator.cc",
"source/trace_impl.cc",
@ -193,9 +187,9 @@ source_set("system_wrappers_default") {
public_configs = [ "..:common_inherited_config" ]
deps = [
":system_wrappers",
":field_trial_default",
":metrics_default",
":system_wrappers",
]
}

View File

@ -22,8 +22,8 @@
#include <string>
#include <vector>
#include "webrtc/base/platform_thread.h"
#include "webrtc/base/scoped_ptr.h"
#include "webrtc/system_wrappers/include/thread_wrapper.h"
#include "webrtc/typedefs.h"
namespace webrtc {
@ -146,7 +146,7 @@ class DataLogImpl {
int counter_;
TableMap tables_;
EventWrapper* flush_event_;
rtc::scoped_ptr<ThreadWrapper> file_writer_thread_;
rtc::scoped_ptr<PlatformThread> file_writer_thread_;
RWLockWrapper* tables_lock_;
};

View File

@ -1,89 +0,0 @@
/*
* Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
// System independant wrapper for spawning threads
// Note: the spawned thread will loop over the callback function until stopped.
// Note: The callback function is expected to return every 2 seconds or more
// often.
#ifndef WEBRTC_SYSTEM_WRAPPERS_INCLUDE_THREAD_WRAPPER_H_
#define WEBRTC_SYSTEM_WRAPPERS_INCLUDE_THREAD_WRAPPER_H_
#if defined(WEBRTC_WIN)
#include <windows.h>
#endif
#include "webrtc/base/scoped_ptr.h"
#include "webrtc/common_types.h"
#include "webrtc/typedefs.h"
namespace webrtc {
// Callback function that the spawned thread will enter once spawned.
// A return value of false is interpreted as that the function has no
// more work to do and that the thread can be released.
typedef bool(*ThreadRunFunction)(void*);
enum ThreadPriority {
#ifdef WEBRTC_WIN
kLowPriority = THREAD_PRIORITY_BELOW_NORMAL,
kNormalPriority = THREAD_PRIORITY_NORMAL,
kHighPriority = THREAD_PRIORITY_ABOVE_NORMAL,
kHighestPriority = THREAD_PRIORITY_HIGHEST,
kRealtimePriority = THREAD_PRIORITY_TIME_CRITICAL
#else
kLowPriority = 1,
kNormalPriority = 2,
kHighPriority = 3,
kHighestPriority = 4,
kRealtimePriority = 5
#endif
};
// 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() {}
// Factory method. Constructor disabled.
//
// func Pointer to a, by user, specified callback function.
// obj Object associated with the thread. Passed in the callback
// function.
// prio Thread priority. May require root/admin rights.
// thread_name NULL terminated thread name, will be visable in the Windows
// debugger.
static rtc::scoped_ptr<ThreadWrapper> CreateThread(ThreadRunFunction func,
void* obj, const char* thread_name);
// Tries to spawns a thread and returns true if that was successful.
// Additionally, it tries to set thread priority according to the priority
// from when CreateThread was called. However, failure to set priority will
// not result in a false return value.
virtual bool Start() = 0;
// Stops the spawned thread and waits for it to be reclaimed with a timeout
// of two seconds. Will return false if the thread was not reclaimed.
// Multiple tries to Stop are allowed (e.g. to wait longer than 2 seconds).
// It's ok to call Stop() even if the spawned thread has been reclaimed.
virtual bool Stop() = 0;
// Set the priority of the worker thread. Must be called when thread
// is running.
virtual bool SetPriority(ThreadPriority priority) = 0;
};
} // namespace webrtc
#endif // WEBRTC_SYSTEM_WRAPPERS_INCLUDE_THREAD_WRAPPER_H_

View File

@ -11,9 +11,9 @@
#include "webrtc/system_wrappers/include/condition_variable_wrapper.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "webrtc/base/platform_thread.h"
#include "webrtc/base/scoped_ptr.h"
#include "webrtc/system_wrappers/include/critical_section_wrapper.h"
#include "webrtc/system_wrappers/include/thread_wrapper.h"
#include "webrtc/system_wrappers/include/tick_util.h"
#include "webrtc/system_wrappers/include/trace.h"
@ -147,8 +147,8 @@ class CondVarTest : public ::testing::Test {
CondVarTest() {}
virtual void SetUp() {
thread_ = ThreadWrapper::CreateThread(&WaitingRunFunction,
&baton_, "CondVarTest");
thread_ = PlatformThread::CreateThread(&WaitingRunFunction, &baton_,
"CondVarTest");
ASSERT_TRUE(thread_->Start());
}
@ -167,7 +167,7 @@ class CondVarTest : public ::testing::Test {
Baton baton_;
private:
rtc::scoped_ptr<ThreadWrapper> thread_;
rtc::scoped_ptr<PlatformThread> thread_;
};
// The SetUp and TearDown functions use condition variables.

View File

@ -12,7 +12,7 @@
#include "testing/gtest/include/gtest/gtest.h"
#include "webrtc/system_wrappers/include/sleep.h"
#include "webrtc/system_wrappers/include/thread_wrapper.h"
#include "webrtc/base/platform_thread.h"
#include "webrtc/system_wrappers/include/trace.h"
namespace webrtc {
@ -78,7 +78,7 @@ TEST_F(CritSectTest, ThreadWakesOnce) NO_THREAD_SAFETY_ANALYSIS {
CriticalSectionWrapper* crit_sect =
CriticalSectionWrapper::CreateCriticalSection();
ProtectedCount count(crit_sect);
rtc::scoped_ptr<ThreadWrapper> thread = ThreadWrapper::CreateThread(
rtc::scoped_ptr<PlatformThread> thread = PlatformThread::CreateThread(
&LockUnlockThenStopRunFunction, &count, "ThreadWakesOnce");
crit_sect->Enter();
ASSERT_TRUE(thread->Start());
@ -105,7 +105,7 @@ TEST_F(CritSectTest, ThreadWakesTwice) NO_THREAD_SAFETY_ANALYSIS {
CriticalSectionWrapper* crit_sect =
CriticalSectionWrapper::CreateCriticalSection();
ProtectedCount count(crit_sect);
rtc::scoped_ptr<ThreadWrapper> thread = ThreadWrapper::CreateThread(
rtc::scoped_ptr<PlatformThread> thread = PlatformThread::CreateThread(
&LockUnlockRunFunction, &count, "ThreadWakesTwice");
crit_sect->Enter(); // Make sure counter stays 0 until we wait for it.
ASSERT_TRUE(thread->Start());

View File

@ -348,8 +348,8 @@ int DataLogImpl::CreateLog() {
}
int DataLogImpl::Init() {
file_writer_thread_ = ThreadWrapper::CreateThread(
DataLogImpl::Run, instance_, "DataLog");
file_writer_thread_ =
PlatformThread::CreateThread(DataLogImpl::Run, instance_, "DataLog");
bool success = file_writer_thread_->Start();
if (!success)
return -1;

View File

@ -154,7 +154,7 @@ bool EventTimerPosix::StartTimer(bool periodic, unsigned long time) {
// Start the timer thread
timer_event_.reset(new EventTimerPosix());
const char* thread_name = "WebRtc_event_timer_thread";
timer_thread_ = ThreadWrapper::CreateThread(Run, this, thread_name);
timer_thread_ = PlatformThread::CreateThread(Run, this, thread_name);
periodic_ = periodic;
time_ = time;
bool started = timer_thread_->Start();

View File

@ -16,7 +16,7 @@
#include <pthread.h>
#include <time.h>
#include "webrtc/system_wrappers/include/thread_wrapper.h"
#include "webrtc/base/platform_thread.h"
namespace webrtc {
@ -46,7 +46,7 @@ class EventTimerPosix : public EventTimerWrapper {
pthread_mutex_t mutex_;
bool event_set_;
rtc::scoped_ptr<ThreadWrapper> timer_thread_;
rtc::scoped_ptr<PlatformThread> timer_thread_;
rtc::scoped_ptr<EventTimerPosix> timer_event_;
timespec created_at_;

View File

@ -1,33 +0,0 @@
/*
* Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
#include "webrtc/system_wrappers/include/thread_wrapper.h"
#if defined(_WIN32)
#include "webrtc/system_wrappers/source/thread_win.h"
#else
#include "webrtc/system_wrappers/source/thread_posix.h"
#endif
namespace webrtc {
#if defined(_WIN32)
typedef ThreadWindows ThreadType;
#else
typedef ThreadPosix ThreadType;
#endif
rtc::scoped_ptr<ThreadWrapper> ThreadWrapper::CreateThread(
ThreadRunFunction func, void* obj, const char* thread_name) {
return rtc::scoped_ptr<ThreadWrapper>(
new ThreadType(func, obj, thread_name)).Pass();
}
} // namespace webrtc

View File

@ -1,161 +0,0 @@
/*
* Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
#include "webrtc/system_wrappers/source/thread_posix.h"
#include <algorithm>
#include <errno.h>
#include <unistd.h>
#ifdef WEBRTC_LINUX
#include <linux/unistd.h>
#include <sched.h>
#include <sys/types.h>
#endif
#include "webrtc/base/checks.h"
#include "webrtc/system_wrappers/include/critical_section_wrapper.h"
#include "webrtc/system_wrappers/include/event_wrapper.h"
#include "webrtc/system_wrappers/include/sleep.h"
#include "webrtc/system_wrappers/include/trace.h"
namespace webrtc {
namespace {
struct ThreadAttributes {
ThreadAttributes() { pthread_attr_init(&attr); }
~ThreadAttributes() { pthread_attr_destroy(&attr); }
pthread_attr_t* operator&() { return &attr; }
pthread_attr_t attr;
};
} // namespace
int ConvertToSystemPriority(ThreadPriority priority, int min_prio,
int max_prio) {
RTC_DCHECK(max_prio - min_prio > 2);
const int top_prio = max_prio - 1;
const int low_prio = min_prio + 1;
switch (priority) {
case kLowPriority:
return low_prio;
case kNormalPriority:
// The -1 ensures that the kHighPriority is always greater or equal to
// kNormalPriority.
return (low_prio + top_prio - 1) / 2;
case kHighPriority:
return std::max(top_prio - 2, low_prio);
case kHighestPriority:
return std::max(top_prio - 1, low_prio);
case kRealtimePriority:
return top_prio;
}
RTC_DCHECK(false);
return low_prio;
}
// static
void* ThreadPosix::StartThread(void* param) {
static_cast<ThreadPosix*>(param)->Run();
return 0;
}
ThreadPosix::ThreadPosix(ThreadRunFunction func, void* obj,
const char* thread_name)
: run_function_(func),
obj_(obj),
stop_event_(false, false),
name_(thread_name ? thread_name : "webrtc"),
thread_(0) {
RTC_DCHECK(name_.length() < 64);
}
ThreadPosix::~ThreadPosix() {
RTC_DCHECK(thread_checker_.CalledOnValidThread());
}
// TODO(pbos): Make Start void, calling code really doesn't support failures
// here.
bool ThreadPosix::Start() {
RTC_DCHECK(thread_checker_.CalledOnValidThread());
RTC_DCHECK(!thread_) << "Thread already started?";
ThreadAttributes attr;
// Set the stack stack size to 1M.
pthread_attr_setstacksize(&attr, 1024 * 1024);
RTC_CHECK_EQ(0, pthread_create(&thread_, &attr, &StartThread, this));
return true;
}
bool ThreadPosix::Stop() {
RTC_DCHECK(thread_checker_.CalledOnValidThread());
if (!thread_)
return true;
stop_event_.Set();
RTC_CHECK_EQ(0, pthread_join(thread_, nullptr));
thread_ = 0;
return true;
}
bool ThreadPosix::SetPriority(ThreadPriority priority) {
RTC_DCHECK(thread_checker_.CalledOnValidThread());
if (!thread_)
return false;
#if defined(WEBRTC_CHROMIUM_BUILD) && defined(WEBRTC_LINUX)
// TODO(tommi): Switch to the same mechanism as Chromium uses for
// changing thread priorities.
return true;
#else
#ifdef WEBRTC_THREAD_RR
const int policy = SCHED_RR;
#else
const int policy = SCHED_FIFO;
#endif
const int min_prio = sched_get_priority_min(policy);
const int max_prio = sched_get_priority_max(policy);
if (min_prio == -1 || max_prio == -1) {
WEBRTC_TRACE(kTraceError, kTraceUtility, -1,
"unable to retreive min or max priority for threads");
return false;
}
if (max_prio - min_prio <= 2)
return false;
sched_param param;
param.sched_priority = ConvertToSystemPriority(priority, min_prio, max_prio);
if (pthread_setschedparam(thread_, policy, &param) != 0) {
WEBRTC_TRACE(
kTraceError, kTraceUtility, -1, "unable to set thread priority");
return false;
}
return true;
#endif // defined(WEBRTC_CHROMIUM_BUILD) && defined(WEBRTC_LINUX)
}
void ThreadPosix::Run() {
if (!name_.empty()) {
// Setting the thread name may fail (harmlessly) if running inside a
// sandbox. Ignore failures if they happen.
rtc::SetCurrentThreadName(name_.substr(0, 63).c_str());
}
// It's a requirement that for successful thread creation that the run
// function be called at least once (see RunFunctionIsCalled unit test),
// so to fullfill that requirement, we use a |do| loop and not |while|.
do {
if (!run_function_(obj_))
break;
} while (!stop_event_.Wait(0));
}
} // namespace webrtc

View File

@ -1,53 +0,0 @@
/*
* Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
#ifndef WEBRTC_SYSTEM_WRAPPERS_SOURCE_THREAD_POSIX_H_
#define WEBRTC_SYSTEM_WRAPPERS_SOURCE_THREAD_POSIX_H_
#include "webrtc/base/event.h"
#include "webrtc/base/scoped_ptr.h"
#include "webrtc/base/thread_checker.h"
#include "webrtc/system_wrappers/include/thread_wrapper.h"
#include <pthread.h>
namespace webrtc {
int ConvertToSystemPriority(ThreadPriority priority, int min_prio,
int max_prio);
class ThreadPosix : public ThreadWrapper {
public:
ThreadPosix(ThreadRunFunction func, void* obj, const char* thread_name);
~ThreadPosix() override;
// From ThreadWrapper.
bool Start() override;
bool Stop() override;
bool SetPriority(ThreadPriority priority) override;
private:
static void* StartThread(void* param);
void Run();
rtc::ThreadChecker thread_checker_;
ThreadRunFunction const run_function_;
void* const obj_;
rtc::Event stop_event_;
const std::string name_;
pthread_t thread_;
};
} // namespace webrtc
#endif // WEBRTC_SYSTEM_WRAPPERS_SOURCE_THREAD_POSIX_H_

View File

@ -1,30 +0,0 @@
/*
* Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
#include "webrtc/system_wrappers/source/thread_posix.h"
#include "testing/gtest/include/gtest/gtest.h"
TEST(ThreadTestPosix, PrioritySettings) {
// API assumes that max_prio - min_prio > 2. Test the extreme case.
const int kMinPrio = -1;
const int kMaxPrio = 2;
int last_priority = kMinPrio;
for (int priority = webrtc::kLowPriority;
priority <= webrtc::kRealtimePriority; ++priority) {
int system_priority = webrtc::ConvertToSystemPriority(
static_cast<webrtc::ThreadPriority>(priority), kMinPrio, kMaxPrio);
EXPECT_GT(system_priority, kMinPrio);
EXPECT_LT(system_priority, kMaxPrio);
EXPECT_GE(system_priority, last_priority);
last_priority = system_priority;
}
}

View File

@ -1,101 +0,0 @@
/*
* Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
#include "webrtc/system_wrappers/source/thread_win.h"
#include <process.h>
#include <stdio.h>
#include <windows.h>
#include "webrtc/base/checks.h"
#include "webrtc/system_wrappers/include/trace.h"
namespace webrtc {
namespace {
void CALLBACK RaiseFlag(ULONG_PTR param) {
*reinterpret_cast<bool*>(param) = true;
}
}
ThreadWindows::ThreadWindows(ThreadRunFunction func, void* obj,
const char* thread_name)
: run_function_(func),
obj_(obj),
stop_(false),
thread_(NULL),
name_(thread_name ? thread_name : "webrtc") {
RTC_DCHECK(func);
}
ThreadWindows::~ThreadWindows() {
RTC_DCHECK(main_thread_.CalledOnValidThread());
RTC_DCHECK(!thread_);
}
// static
DWORD WINAPI ThreadWindows::StartThread(void* param) {
static_cast<ThreadWindows*>(param)->Run();
return 0;
}
bool ThreadWindows::Start() {
RTC_DCHECK(main_thread_.CalledOnValidThread());
RTC_DCHECK(!thread_);
stop_ = false;
// See bug 2902 for background on STACK_SIZE_PARAM_IS_A_RESERVATION.
// Set the reserved stack stack size to 1M, which is the default on Windows
// and Linux.
DWORD thread_id;
thread_ = ::CreateThread(NULL, 1024 * 1024, &StartThread, this,
STACK_SIZE_PARAM_IS_A_RESERVATION, &thread_id);
if (!thread_ ) {
RTC_DCHECK(false) << "CreateThread failed";
return false;
}
return true;
}
bool ThreadWindows::Stop() {
RTC_DCHECK(main_thread_.CalledOnValidThread());
if (thread_) {
// Set stop_ to |true| on the worker thread.
QueueUserAPC(&RaiseFlag, thread_, reinterpret_cast<ULONG_PTR>(&stop_));
WaitForSingleObject(thread_, INFINITE);
CloseHandle(thread_);
thread_ = nullptr;
}
return true;
}
bool ThreadWindows::SetPriority(ThreadPriority priority) {
RTC_DCHECK(main_thread_.CalledOnValidThread());
return thread_ && SetThreadPriority(thread_, priority);
}
void ThreadWindows::Run() {
if (!name_.empty())
rtc::SetCurrentThreadName(name_.c_str());
do {
// The interface contract of Start/Stop is that for a successfull call to
// Start, there should be at least one call to the run function. So we
// call the function before checking |stop_|.
if (!run_function_(obj_))
break;
// Alertable sleep to permit RaiseFlag to run and update |stop_|.
SleepEx(0, true);
} while (!stop_);
}
} // namespace webrtc

View File

@ -1,48 +0,0 @@
/*
* Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
#ifndef WEBRTC_SYSTEM_WRAPPERS_SOURCE_THREAD_WIN_H_
#define WEBRTC_SYSTEM_WRAPPERS_SOURCE_THREAD_WIN_H_
#include "webrtc/system_wrappers/include/thread_wrapper.h"
#include <windows.h>
#include "webrtc/base/thread_checker.h"
namespace webrtc {
class ThreadWindows : public ThreadWrapper {
public:
ThreadWindows(ThreadRunFunction func, void* obj, const char* thread_name);
~ThreadWindows() override;
bool Start() override;
bool Stop() override;
bool SetPriority(ThreadPriority priority) override;
protected:
void Run();
private:
static DWORD WINAPI StartThread(void* param);
ThreadRunFunction const run_function_;
void* const obj_;
bool stop_;
HANDLE thread_;
const std::string name_;
rtc::ThreadChecker main_thread_;
};
} // namespace webrtc
#endif // WEBRTC_SYSTEM_WRAPPERS_SOURCE_THREAD_WIN_H_

View File

@ -16,7 +16,7 @@
#include "webrtc/system_wrappers/include/event_wrapper.h"
#include "webrtc/system_wrappers/include/file_wrapper.h"
#include "webrtc/system_wrappers/include/static_instance.h"
#include "webrtc/system_wrappers/include/thread_wrapper.h"
#include "webrtc/base/platform_thread.h"
#include "webrtc/system_wrappers/include/trace.h"
namespace webrtc {

View File

@ -44,7 +44,6 @@
'include/static_instance.h',
'include/stl_util.h',
'include/stringize_macros.h',
'include/thread_wrapper.h',
'include/tick_util.h',
'include/timestamp_extrapolator.h',
'include/trace.h',
@ -91,11 +90,6 @@
'source/sleep.cc',
'source/sort.cc',
'source/tick_util.cc',
'source/thread.cc',
'source/thread_posix.cc',
'source/thread_posix.h',
'source/thread_win.cc',
'source/thread_win.h',
'source/timestamp_extrapolator.cc',
'source/trace_impl.cc',
'source/trace_impl.h',

View File

@ -33,8 +33,6 @@
'source/scoped_vector_unittest.cc',
'source/stringize_macros_unittest.cc',
'source/stl_util_unittest.cc',
'source/thread_unittest.cc',
'source/thread_posix_unittest.cc',
],
'conditions': [
['enable_data_logging==1', {
@ -42,9 +40,6 @@
}, {
'sources!': [ 'source/data_log_unittest.cc', ],
}],
['os_posix==0', {
'sources!': [ 'source/thread_posix_unittest.cc', ],
}],
['OS=="android"', {
'dependencies': [
'<(DEPTH)/testing/android/native_test.gyp:native_test_native_code',

View File

@ -556,7 +556,7 @@ int32_t UdpSocket2WorkerWindows::Init()
if(!_init)
{
const char* threadName = "UdpSocket2ManagerWindows_thread";
_pThread = ThreadWrapper::CreateThread(Run, this, threadName);
_pThread = PlatformThread::CreateThread(Run, this, threadName);
_init = true;
}
return 0;

View File

@ -17,7 +17,7 @@
#include "webrtc/system_wrappers/include/atomic32.h"
#include "webrtc/system_wrappers/include/critical_section_wrapper.h"
#include "webrtc/system_wrappers/include/event_wrapper.h"
#include "webrtc/system_wrappers/include/thread_wrapper.h"
#include "webrtc/base/platform_thread.h"
#include "webrtc/test/channel_transport/udp_socket2_win.h"
#include "webrtc/test/channel_transport/udp_socket_manager_wrapper.h"
#include "webrtc/test/channel_transport/udp_transport.h"
@ -47,7 +47,7 @@ struct PerIoContext {
int fromLen;
// Should be set to true if the I/O context was passed to the system by
// a thread not controlled by the socket implementation.
bool ioInitiatedByThreadWrapper;
bool ioInitiatedByPlatformThread;
// TODO (hellner): Not used. Delete it.
PerIoContext* pNextFree;
};
@ -105,7 +105,7 @@ protected:
bool Process();
private:
HANDLE _ioCompletionHandle;
rtc::scoped_ptr<ThreadWrapper> _pThread;
rtc::scoped_ptr<PlatformThread> _pThread;
static int32_t _numOfWorkers;
int32_t _workerNumber;
volatile bool _stop;

View File

@ -432,13 +432,13 @@ void UdpSocket2Windows::IOCompleted(PerIoContext* pIOContext,
if(pIOContext == NULL || error == ERROR_OPERATION_ABORTED)
{
if ((pIOContext != NULL) &&
!pIOContext->ioInitiatedByThreadWrapper &&
!pIOContext->ioInitiatedByPlatformThread &&
(error == ERROR_OPERATION_ABORTED) &&
(pIOContext->ioOperation == OP_READ) &&
_outstandingCallsDisabled)
{
// !pIOContext->initiatedIOByThreadWrapper indicate that the I/O
// was not initiated by a ThreadWrapper thread.
// !pIOContext->initiatedIOByPlatformThread indicate that the I/O
// was not initiated by a PlatformThread thread.
// This may happen if the thread that initiated receiving (e.g.
// by calling StartListen())) is deleted before any packets have
// been received.
@ -519,7 +519,7 @@ void UdpSocket2Windows::IOCompleted(PerIoContext* pIOContext,
{
// The PerIoContext was posted by a thread controlled by the socket
// implementation.
pIOContext->ioInitiatedByThreadWrapper = true;
pIOContext->ioInitiatedByPlatformThread = true;
}
OutstandingCallCompleted();
return;
@ -546,7 +546,7 @@ int32_t UdpSocket2Windows::PostRecv()
}
// This function may have been called by thread not controlled by the socket
// implementation.
pIoContext->ioInitiatedByThreadWrapper = false;
pIoContext->ioInitiatedByPlatformThread = false;
return PostRecv(pIoContext);
}

View File

@ -188,8 +188,8 @@ bool UdpSocketManagerPosix::RemoveSocket(UdpSocketWrapper* s)
UdpSocketManagerPosixImpl::UdpSocketManagerPosixImpl()
{
_critSectList = CriticalSectionWrapper::CreateCriticalSection();
_thread = ThreadWrapper::CreateThread(UdpSocketManagerPosixImpl::Run, this,
"UdpSocketManagerPosixImplThread");
_thread = PlatformThread::CreateThread(UdpSocketManagerPosixImpl::Run, this,
"UdpSocketManagerPosixImplThread");
FD_ZERO(&_readFds);
WEBRTC_TRACE(kTraceMemory, kTraceTransport, -1,
"UdpSocketManagerPosix created");

View File

@ -17,8 +17,8 @@
#include <list>
#include <map>
#include "webrtc/base/platform_thread.h"
#include "webrtc/system_wrappers/include/critical_section_wrapper.h"
#include "webrtc/system_wrappers/include/thread_wrapper.h"
#include "webrtc/test/channel_transport/udp_socket_manager_wrapper.h"
#include "webrtc/test/channel_transport/udp_socket_wrapper.h"
@ -75,7 +75,7 @@ protected:
private:
typedef std::list<UdpSocketWrapper*> SocketList;
typedef std::list<SOCKET> FdList;
rtc::scoped_ptr<ThreadWrapper> _thread;
rtc::scoped_ptr<PlatformThread> _thread;
CriticalSectionWrapper* _critSectList;
fd_set _readFds;

View File

@ -21,7 +21,7 @@ DirectTransport::DirectTransport(Call* send_call)
: send_call_(send_call),
packet_event_(EventWrapper::Create()),
thread_(
ThreadWrapper::CreateThread(NetworkProcess, this, "NetworkProcess")),
PlatformThread::CreateThread(NetworkProcess, this, "NetworkProcess")),
clock_(Clock::GetRealTimeClock()),
shutting_down_(false),
fake_network_(FakeNetworkPipe::Config()) {
@ -33,7 +33,7 @@ DirectTransport::DirectTransport(const FakeNetworkPipe::Config& config,
: send_call_(send_call),
packet_event_(EventWrapper::Create()),
thread_(
ThreadWrapper::CreateThread(NetworkProcess, this, "NetworkProcess")),
PlatformThread::CreateThread(NetworkProcess, this, "NetworkProcess")),
clock_(Clock::GetRealTimeClock()),
shutting_down_(false),
fake_network_(config) {

View File

@ -15,9 +15,9 @@
#include <deque>
#include "webrtc/base/criticalsection.h"
#include "webrtc/base/platform_thread.h"
#include "webrtc/base/scoped_ptr.h"
#include "webrtc/system_wrappers/include/event_wrapper.h"
#include "webrtc/system_wrappers/include/thread_wrapper.h"
#include "webrtc/test/fake_network_pipe.h"
#include "webrtc/transport.h"
@ -53,7 +53,7 @@ class DirectTransport : public Transport {
rtc::CriticalSection lock_;
Call* const send_call_;
rtc::scoped_ptr<EventWrapper> packet_event_;
rtc::scoped_ptr<ThreadWrapper> thread_;
rtc::scoped_ptr<PlatformThread> thread_;
Clock* const clock_;
bool shutting_down_;

View File

@ -13,11 +13,11 @@
#include <algorithm>
#include "testing/gtest/include/gtest/gtest.h"
#include "webrtc/base/platform_thread.h"
#include "webrtc/modules/media_file/media_file_utility.h"
#include "webrtc/system_wrappers/include/clock.h"
#include "webrtc/system_wrappers/include/event_wrapper.h"
#include "webrtc/system_wrappers/include/file_wrapper.h"
#include "webrtc/system_wrappers/include/thread_wrapper.h"
namespace webrtc {
namespace test {
@ -53,8 +53,8 @@ int32_t FakeAudioDevice::Init() {
if (!tick_->StartTimer(true, 10))
return -1;
thread_ = ThreadWrapper::CreateThread(FakeAudioDevice::Run, this,
"FakeAudioDevice");
thread_ = PlatformThread::CreateThread(FakeAudioDevice::Run, this,
"FakeAudioDevice");
if (thread_.get() == NULL)
return -1;
if (!thread_->Start()) {

View File

@ -23,7 +23,7 @@ class Clock;
class EventTimerWrapper;
class FileWrapper;
class ModuleFileUtility;
class ThreadWrapper;
class PlatformThread;
namespace test {
@ -59,7 +59,7 @@ class FakeAudioDevice : public FakeAudioDeviceModule {
Clock* clock_;
rtc::scoped_ptr<EventTimerWrapper> tick_;
mutable rtc::CriticalSection lock_;
rtc::scoped_ptr<ThreadWrapper> thread_;
rtc::scoped_ptr<PlatformThread> thread_;
rtc::scoped_ptr<ModuleFileUtility> file_utility_;
rtc::scoped_ptr<FileWrapper> input_stream_;
};

View File

@ -11,11 +11,11 @@
#include "webrtc/test/frame_generator_capturer.h"
#include "webrtc/base/criticalsection.h"
#include "webrtc/test/frame_generator.h"
#include "webrtc/base/platform_thread.h"
#include "webrtc/system_wrappers/include/clock.h"
#include "webrtc/system_wrappers/include/event_wrapper.h"
#include "webrtc/system_wrappers/include/sleep.h"
#include "webrtc/system_wrappers/include/thread_wrapper.h"
#include "webrtc/test/frame_generator.h"
#include "webrtc/video_send_stream.h"
namespace webrtc {
@ -88,8 +88,8 @@ bool FrameGeneratorCapturer::Init() {
if (!tick_->StartTimer(true, 1000 / target_fps_))
return false;
thread_ = ThreadWrapper::CreateThread(FrameGeneratorCapturer::Run, this,
"FrameGeneratorCapturer");
thread_ = PlatformThread::CreateThread(FrameGeneratorCapturer::Run, this,
"FrameGeneratorCapturer");
if (thread_.get() == NULL)
return false;
if (!thread_->Start()) {

View File

@ -21,7 +21,7 @@ namespace webrtc {
class CriticalSectionWrapper;
class EventTimerWrapper;
class ThreadWrapper;
class PlatformThread;
namespace test {
@ -64,7 +64,7 @@ class FrameGeneratorCapturer : public VideoCapturer {
rtc::scoped_ptr<EventTimerWrapper> tick_;
rtc::CriticalSection lock_;
rtc::scoped_ptr<ThreadWrapper> thread_;
rtc::scoped_ptr<PlatformThread> thread_;
rtc::scoped_ptr<FrameGenerator> frame_generator_;
int target_fps_;

View File

@ -12,6 +12,7 @@
#include "webrtc/base/checks.h"
#include "webrtc/base/common.h"
#include "webrtc/base/event.h"
#include "webrtc/base/platform_thread.h"
#include "webrtc/modules/pacing/packet_router.h"
#include "webrtc/modules/remote_bitrate_estimator/remote_bitrate_estimator_abs_send_time.h"
#include "webrtc/modules/remote_bitrate_estimator/remote_bitrate_estimator_single_stream.h"
@ -22,7 +23,6 @@
#include "webrtc/modules/rtp_rtcp/include/rtp_rtcp.h"
#include "webrtc/modules/rtp_rtcp/source/rtcp_utility.h"
#include "webrtc/system_wrappers/include/critical_section_wrapper.h"
#include "webrtc/system_wrappers/include/thread_wrapper.h"
#include "webrtc/test/testsupport/perf_test.h"
#include "webrtc/video/rampup_tests.h"
@ -60,9 +60,9 @@ RampUpTester::RampUpTester(size_t num_streams,
extension_type_(extension_type),
ssrcs_(GenerateSsrcs(num_streams, 100)),
rtx_ssrcs_(GenerateSsrcs(num_streams, 200)),
poller_thread_(ThreadWrapper::CreateThread(&BitrateStatsPollingThread,
this,
"BitrateStatsPollingThread")),
poller_thread_(PlatformThread::CreateThread(&BitrateStatsPollingThread,
this,
"BitrateStatsPollingThread")),
sender_call_(nullptr) {
if (rtx_) {
for (size_t i = 0; i < ssrcs_.size(); ++i)

View File

@ -98,7 +98,7 @@ class RampUpTester : public test::EndToEndTest {
std::vector<uint32_t> rtx_ssrcs_;
SsrcMap rtx_ssrc_map_;
rtc::scoped_ptr<ThreadWrapper> poller_thread_;
rtc::scoped_ptr<PlatformThread> poller_thread_;
Call* sender_call_;
};

View File

@ -42,9 +42,9 @@ VideoCaptureInput::VideoCaptureInput(
local_renderer_(local_renderer),
stats_proxy_(stats_proxy),
incoming_frame_cs_(CriticalSectionWrapper::CreateCriticalSection()),
encoder_thread_(ThreadWrapper::CreateThread(EncoderThreadFunction,
this,
"EncoderThread")),
encoder_thread_(PlatformThread::CreateThread(EncoderThreadFunction,
this,
"EncoderThread")),
capture_event_(EventWrapper::Create()),
stop_(0),
last_captured_timestamp_(0),

View File

@ -14,6 +14,7 @@
#include <vector>
#include "webrtc/base/criticalsection.h"
#include "webrtc/base/platform_thread.h"
#include "webrtc/base/scoped_ptr.h"
#include "webrtc/base/thread_annotations.h"
#include "webrtc/common_types.h"
@ -23,7 +24,6 @@
#include "webrtc/modules/video_coding/include/video_coding.h"
#include "webrtc/modules/video_processing/include/video_processing.h"
#include "webrtc/system_wrappers/include/critical_section_wrapper.h"
#include "webrtc/system_wrappers/include/thread_wrapper.h"
#include "webrtc/typedefs.h"
#include "webrtc/video_send_stream.h"
@ -78,7 +78,7 @@ class VideoCaptureInput : public webrtc::VideoCaptureInput {
rtc::scoped_ptr<CriticalSectionWrapper> incoming_frame_cs_;
VideoFrame incoming_frame_;
rtc::scoped_ptr<ThreadWrapper> encoder_thread_;
rtc::scoped_ptr<PlatformThread> encoder_thread_;
rtc::scoped_ptr<EventWrapper> capture_event_;
volatile int stop_;

View File

@ -91,18 +91,18 @@ class VideoAnalyzer : public PacketReceiver,
}
for (uint32_t i = 0; i < num_cores; ++i) {
rtc::scoped_ptr<ThreadWrapper> thread =
ThreadWrapper::CreateThread(&FrameComparisonThread, this, "Analyzer");
rtc::scoped_ptr<PlatformThread> thread = PlatformThread::CreateThread(
&FrameComparisonThread, this, "Analyzer");
EXPECT_TRUE(thread->Start());
comparison_thread_pool_.push_back(thread.release());
}
stats_polling_thread_ =
ThreadWrapper::CreateThread(&PollStatsThread, this, "StatsPoller");
PlatformThread::CreateThread(&PollStatsThread, this, "StatsPoller");
}
~VideoAnalyzer() {
for (ThreadWrapper* thread : comparison_thread_pool_) {
for (PlatformThread* thread : comparison_thread_pool_) {
EXPECT_TRUE(thread->Stop());
delete thread;
}
@ -602,8 +602,8 @@ class VideoAnalyzer : public PacketReceiver,
const double avg_ssim_threshold_;
rtc::CriticalSection comparison_lock_;
std::vector<ThreadWrapper*> comparison_thread_pool_;
rtc::scoped_ptr<ThreadWrapper> stats_polling_thread_;
std::vector<PlatformThread*> comparison_thread_pool_;
rtc::scoped_ptr<PlatformThread> stats_polling_thread_;
const rtc::scoped_ptr<EventWrapper> comparison_available_event_;
std::deque<FrameComparison> comparisons_ GUARDED_BY(comparison_lock_);
const rtc::scoped_ptr<EventWrapper> done_;

View File

@ -16,6 +16,7 @@
#include "webrtc/base/checks.h"
#include "webrtc/base/criticalsection.h"
#include "webrtc/base/logging.h"
#include "webrtc/base/platform_thread.h"
#include "webrtc/base/scoped_ptr.h"
#include "webrtc/call.h"
#include "webrtc/call/transport_adapter.h"
@ -30,7 +31,6 @@
#include "webrtc/system_wrappers/include/event_wrapper.h"
#include "webrtc/system_wrappers/include/ref_count.h"
#include "webrtc/system_wrappers/include/sleep.h"
#include "webrtc/system_wrappers/include/thread_wrapper.h"
#include "webrtc/test/call_test.h"
#include "webrtc/test/configurable_frame_size_encoder.h"
#include "webrtc/test/fake_texture_frame.h"

View File

@ -15,6 +15,7 @@
#include "webrtc/base/checks.h"
#include "webrtc/base/logging.h"
#include "webrtc/base/platform_thread.h"
#include "webrtc/common.h"
#include "webrtc/common_video/include/incoming_video_stream.h"
#include "webrtc/common_video/libyuv/include/webrtc_libyuv.h"
@ -29,7 +30,6 @@
#include "webrtc/modules/video_render/video_render_defines.h"
#include "webrtc/system_wrappers/include/critical_section_wrapper.h"
#include "webrtc/system_wrappers/include/metrics.h"
#include "webrtc/system_wrappers/include/thread_wrapper.h"
#include "webrtc/video/receive_statistics_proxy.h"
#include "webrtc/video_engine/call_stats.h"
#include "webrtc/video_engine/payload_router.h"
@ -1150,8 +1150,8 @@ void ViEChannel::StartDecodeThread() {
// Start the decode thread
if (decode_thread_)
return;
decode_thread_ = ThreadWrapper::CreateThread(ChannelDecodeThreadFunction,
this, "DecodingThread");
decode_thread_ = PlatformThread::CreateThread(ChannelDecodeThreadFunction,
this, "DecodingThread");
decode_thread_->Start();
decode_thread_->SetPriority(kHighestPriority);
}

View File

@ -41,7 +41,7 @@ class ProcessThread;
class ReceiveStatisticsProxy;
class ReportBlockStats;
class RtcpRttStats;
class ThreadWrapper;
class PlatformThread;
class ViEChannelProtectionCallback;
class ViERTPObserver;
class VideoCodingModule;
@ -433,7 +433,7 @@ class ViEChannel : public VCMFrameTypeCallback,
const rtc::scoped_ptr<RtcpBandwidthObserver> bandwidth_observer_;
TransportFeedbackObserver* const transport_feedback_observer_;
rtc::scoped_ptr<ThreadWrapper> decode_thread_;
rtc::scoped_ptr<PlatformThread> decode_thread_;
int nack_history_size_sender_;
int max_nack_reordering_threshold_;

View File

@ -15,7 +15,7 @@
#include "webrtc/voice_engine/test/android/android_test/jni/org_webrtc_voiceengine_test_AndroidTest.h"
#include "webrtc/system_wrappers/include/thread_wrapper.h"
#include "webrtc/base/platform_thread.h"
#include "webrtc/voice_engine/include/voe_audio_processing.h"
#include "webrtc/voice_engine/include/voe_base.h"
@ -177,7 +177,7 @@ private:
static bool Run(void* ptr);
bool Process();
private:
rtc::scoped_ptr<ThreadWrapper> _thread;
rtc::scoped_ptr<PlatformThread> _thread;
};
ThreadTest::~ThreadTest()
@ -188,7 +188,7 @@ ThreadTest::~ThreadTest()
ThreadTest::ThreadTest()
{
_thread = ThreadWrapper::CreateThread(Run, this, "ThreadTest thread");
_thread = PlatformThread::CreateThread(Run, this, "ThreadTest thread");
}
bool ThreadTest::Run(void* ptr)

View File

@ -40,9 +40,9 @@ ConferenceTransport::ConferenceTransport()
: pq_crit_(webrtc::CriticalSectionWrapper::CreateCriticalSection()),
stream_crit_(webrtc::CriticalSectionWrapper::CreateCriticalSection()),
packet_event_(webrtc::EventWrapper::Create()),
thread_(webrtc::ThreadWrapper::CreateThread(Run,
this,
"ConferenceTransport")),
thread_(webrtc::PlatformThread::CreateThread(Run,
this,
"ConferenceTransport")),
rtt_ms_(0),
stream_count_(0),
rtp_header_parser_(webrtc::RtpHeaderParser::Create()) {

View File

@ -17,12 +17,12 @@
#include "testing/gtest/include/gtest/gtest.h"
#include "webrtc/base/basictypes.h"
#include "webrtc/base/platform_thread.h"
#include "webrtc/base/scoped_ptr.h"
#include "webrtc/common_types.h"
#include "webrtc/modules/rtp_rtcp/include/rtp_header_parser.h"
#include "webrtc/system_wrappers/include/critical_section_wrapper.h"
#include "webrtc/system_wrappers/include/event_wrapper.h"
#include "webrtc/system_wrappers/include/thread_wrapper.h"
#include "webrtc/voice_engine/include/voe_base.h"
#include "webrtc/voice_engine/include/voe_codec.h"
#include "webrtc/voice_engine/include/voe_file.h"
@ -131,7 +131,7 @@ class ConferenceTransport: public webrtc::Transport {
const rtc::scoped_ptr<webrtc::CriticalSectionWrapper> pq_crit_;
const rtc::scoped_ptr<webrtc::CriticalSectionWrapper> stream_crit_;
const rtc::scoped_ptr<webrtc::EventWrapper> packet_event_;
const rtc::scoped_ptr<webrtc::ThreadWrapper> thread_;
const rtc::scoped_ptr<webrtc::PlatformThread> thread_;
unsigned int rtt_ms_;
unsigned int stream_count_;

View File

@ -13,6 +13,7 @@
#include <deque>
#include "webrtc/base/platform_thread.h"
#include "webrtc/base/scoped_ptr.h"
#include "webrtc/common_types.h"
#include "webrtc/modules/rtp_rtcp/source/byte_io.h"
@ -20,7 +21,6 @@
#include "webrtc/system_wrappers/include/critical_section_wrapper.h"
#include "webrtc/system_wrappers/include/event_wrapper.h"
#include "webrtc/system_wrappers/include/sleep.h"
#include "webrtc/system_wrappers/include/thread_wrapper.h"
#include "webrtc/voice_engine/test/auto_test/fixtures/before_initialization_fixture.h"
class TestErrorObserver;
@ -30,9 +30,9 @@ class LoopBackTransport : public webrtc::Transport {
LoopBackTransport(webrtc::VoENetwork* voe_network, int channel)
: crit_(webrtc::CriticalSectionWrapper::CreateCriticalSection()),
packet_event_(webrtc::EventWrapper::Create()),
thread_(webrtc::ThreadWrapper::CreateThread(NetworkProcess,
this,
"LoopBackTransport")),
thread_(webrtc::PlatformThread::CreateThread(NetworkProcess,
this,
"LoopBackTransport")),
channel_(channel),
voe_network_(voe_network),
transmitted_packets_(0) {
@ -147,7 +147,7 @@ class LoopBackTransport : public webrtc::Transport {
const rtc::scoped_ptr<webrtc::CriticalSectionWrapper> crit_;
const rtc::scoped_ptr<webrtc::EventWrapper> packet_event_;
const rtc::scoped_ptr<webrtc::ThreadWrapper> thread_;
const rtc::scoped_ptr<webrtc::PlatformThread> thread_;
std::deque<Packet> packet_queue_ GUARDED_BY(crit_.get());
const int channel_;
std::map<uint32_t, int> channels_ GUARDED_BY(crit_.get());

View File

@ -44,7 +44,7 @@
#ifdef WEBRTC_VOICE_ENGINE_NETEQ_STATS_API
namespace webrtc {
class CriticalSectionWrapper;
class ThreadWrapper;
class PlatformThread;
class VoENetEqStats;
}
#endif

View File

@ -334,8 +334,8 @@ int VoEStressTest::MultipleThreadsTest() {
int rnd(0);
// Start extra thread
_ptrExtraApiThread = ThreadWrapper::CreateThread(RunExtraApi, this,
"StressTestExtraApiThread");
_ptrExtraApiThread = PlatformThread::CreateThread(RunExtraApi, this,
"StressTestExtraApiThread");
VALIDATE_STRESS(!_ptrExtraApiThread->Start());
// Some possible extensions include:

View File

@ -11,7 +11,7 @@
#ifndef WEBRTC_VOICE_ENGINE_VOE_STRESS_TEST_H
#define WEBRTC_VOICE_ENGINE_VOE_STRESS_TEST_H
#include "webrtc/system_wrappers/include/thread_wrapper.h"
#include "webrtc/base/platform_thread.h"
namespace voetest {
// TODO(andrew): using directives are not permitted.
@ -38,7 +38,7 @@ class VoEStressTest {
VoETestManager& _mgr;
rtc::scoped_ptr<ThreadWrapper> _ptrExtraApiThread;
rtc::scoped_ptr<PlatformThread> _ptrExtraApiThread;
};
} // namespace voetest