Clean up PlatformThread.
* Move PlatformThread to rtc::.
* Remove ::CreateThread factory method.
* Make non-scoped_ptr from a lot of invocations.
* Make Start/Stop void.
* Remove rtc::Thread priorities, which were unused and would collide.
* Add ::IsRunning() to PlatformThread.
BUG=
R=tommi@webrtc.org
Review URL: https://codereview.webrtc.org/1476453002 .
Cr-Commit-Position: refs/heads/master@{#10812}
diff --git a/webrtc/base/cpumonitor_unittest.cc b/webrtc/base/cpumonitor_unittest.cc
deleted file mode 100644
index 379f62f..0000000
--- a/webrtc/base/cpumonitor_unittest.cc
+++ /dev/null
@@ -1,389 +0,0 @@
-/*
- * Copyright 2010 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 <iomanip>
-#include <iostream>
-#include <vector>
-
-#if defined(WEBRTC_WIN)
-#include "webrtc/base/win32.h"
-#endif
-
-#include "webrtc/base/cpumonitor.h"
-#include "webrtc/base/flags.h"
-#include "webrtc/base/gunit.h"
-#include "webrtc/base/scoped_ptr.h"
-#include "webrtc/base/thread.h"
-#include "webrtc/base/timeutils.h"
-#include "webrtc/base/timing.h"
-#include "webrtc/test/testsupport/gtest_disable.h"
-
-namespace rtc {
-
-static const int kMaxCpus = 1024;
-static const int kSettleTime = 100; // Amount of time to between tests.
-static const int kIdleTime = 500; // Amount of time to be idle in ms.
-static const int kBusyTime = 1000; // Amount of time to be busy in ms.
-static const int kLongInterval = 2000; // Interval longer than busy times
-
-class BusyThread : public rtc::Thread {
- public:
- BusyThread(double load, double duration, double interval) :
- load_(load), duration_(duration), interval_(interval) {
- }
- virtual ~BusyThread() {
- Stop();
- }
- void Run() {
- Timing time;
- double busy_time = interval_ * load_ / 100.0;
- for (;;) {
- time.BusyWait(busy_time);
- time.IdleWait(interval_ - busy_time);
- if (duration_) {
- duration_ -= interval_;
- if (duration_ <= 0) {
- break;
- }
- }
- }
- }
- private:
- double load_;
- double duration_;
- double interval_;
-};
-
-class CpuLoadListener : public sigslot::has_slots<> {
- public:
- CpuLoadListener()
- : current_cpus_(0),
- cpus_(0),
- process_load_(.0f),
- system_load_(.0f),
- count_(0) {
- }
-
- void OnCpuLoad(int current_cpus, int cpus, float proc_load, float sys_load) {
- current_cpus_ = current_cpus;
- cpus_ = cpus;
- process_load_ = proc_load;
- system_load_ = sys_load;
- ++count_;
- }
-
- int current_cpus() const { return current_cpus_; }
- int cpus() const { return cpus_; }
- float process_load() const { return process_load_; }
- float system_load() const { return system_load_; }
- int count() const { return count_; }
-
- private:
- int current_cpus_;
- int cpus_;
- float process_load_;
- float system_load_;
- int count_;
-};
-
-// Set affinity (which cpu to run on), but respecting FLAG_affinity:
-// -1 means no affinity - run on whatever cpu is available.
-// 0 .. N means run on specific cpu. The tool will create N threads and call
-// SetThreadAffinity on 0 to N - 1 as cpu. FLAG_affinity sets the first cpu
-// so the range becomes affinity to affinity + N - 1
-// Note that this function affects Windows scheduling, effectively giving
-// the thread with affinity for a specified CPU more priority on that CPU.
-bool SetThreadAffinity(BusyThread* t, int cpu, int affinity) {
-#if defined(WEBRTC_WIN)
- if (affinity >= 0) {
- return ::SetThreadAffinityMask(t->GetHandle(),
- 1 << (cpu + affinity)) != FALSE;
- }
-#endif
- return true;
-}
-
-bool SetThreadPriority(BusyThread* t, int prio) {
- if (!prio) {
- return true;
- }
- bool ok = t->SetPriority(static_cast<rtc::ThreadPriority>(prio));
- if (!ok) {
- std::cout << "Error setting thread priority." << std::endl;
- }
- return ok;
-}
-
-int CpuLoad(double cpuload, double duration, int numthreads,
- int priority, double interval, int affinity) {
- int ret = 0;
- std::vector<BusyThread*> threads;
- for (int i = 0; i < numthreads; ++i) {
- threads.push_back(new BusyThread(cpuload, duration, interval));
- // NOTE(fbarchard): Priority must be done before Start.
- if (!SetThreadPriority(threads[i], priority) ||
- !threads[i]->Start() ||
- !SetThreadAffinity(threads[i], i, affinity)) {
- ret = 1;
- break;
- }
- }
- // Wait on each thread
- if (ret == 0) {
- for (int i = 0; i < numthreads; ++i) {
- threads[i]->Stop();
- }
- }
-
- for (int i = 0; i < numthreads; ++i) {
- delete threads[i];
- }
- return ret;
-}
-
-// Make 2 CPUs busy
-static void CpuTwoBusyLoop(int busytime) {
- CpuLoad(100.0, busytime / 1000.0, 2, 1, 0.050, -1);
-}
-
-// Make 1 CPUs busy
-static void CpuBusyLoop(int busytime) {
- CpuLoad(100.0, busytime / 1000.0, 1, 1, 0.050, -1);
-}
-
-// Make 1 use half CPU time.
-static void CpuHalfBusyLoop(int busytime) {
- CpuLoad(50.0, busytime / 1000.0, 1, 1, 0.050, -1);
-}
-
-void TestCpuSampler(bool test_proc, bool test_sys, bool force_fallback) {
- CpuSampler sampler;
- sampler.set_force_fallback(force_fallback);
- EXPECT_TRUE(sampler.Init());
- sampler.set_load_interval(100);
- int cpus = sampler.GetMaxCpus();
-
- // Test1: CpuSampler under idle situation.
- Thread::SleepMs(kSettleTime);
- sampler.GetProcessLoad();
- sampler.GetSystemLoad();
-
- Thread::SleepMs(kIdleTime);
-
- float proc_idle = 0.f, sys_idle = 0.f;
- if (test_proc) {
- proc_idle = sampler.GetProcessLoad();
- }
- if (test_sys) {
- sys_idle = sampler.GetSystemLoad();
- }
- if (test_proc) {
- LOG(LS_INFO) << "ProcessLoad Idle: "
- << std::setiosflags(std::ios_base::fixed)
- << std::setprecision(2) << std::setw(6) << proc_idle;
- EXPECT_GE(proc_idle, 0.f);
- EXPECT_LE(proc_idle, static_cast<float>(cpus));
- }
- if (test_sys) {
- LOG(LS_INFO) << "SystemLoad Idle: "
- << std::setiosflags(std::ios_base::fixed)
- << std::setprecision(2) << std::setw(6) << sys_idle;
- EXPECT_GE(sys_idle, 0.f);
- EXPECT_LE(sys_idle, static_cast<float>(cpus));
- }
-
- // Test2: CpuSampler with main process at 50% busy.
- Thread::SleepMs(kSettleTime);
- sampler.GetProcessLoad();
- sampler.GetSystemLoad();
-
- CpuHalfBusyLoop(kBusyTime);
-
- float proc_halfbusy = 0.f, sys_halfbusy = 0.f;
- if (test_proc) {
- proc_halfbusy = sampler.GetProcessLoad();
- }
- if (test_sys) {
- sys_halfbusy = sampler.GetSystemLoad();
- }
- if (test_proc) {
- LOG(LS_INFO) << "ProcessLoad Halfbusy: "
- << std::setiosflags(std::ios_base::fixed)
- << std::setprecision(2) << std::setw(6) << proc_halfbusy;
- EXPECT_GE(proc_halfbusy, 0.f);
- EXPECT_LE(proc_halfbusy, static_cast<float>(cpus));
- }
- if (test_sys) {
- LOG(LS_INFO) << "SystemLoad Halfbusy: "
- << std::setiosflags(std::ios_base::fixed)
- << std::setprecision(2) << std::setw(6) << sys_halfbusy;
- EXPECT_GE(sys_halfbusy, 0.f);
- EXPECT_LE(sys_halfbusy, static_cast<float>(cpus));
- }
-
- // Test3: CpuSampler with main process busy.
- Thread::SleepMs(kSettleTime);
- sampler.GetProcessLoad();
- sampler.GetSystemLoad();
-
- CpuBusyLoop(kBusyTime);
-
- float proc_busy = 0.f, sys_busy = 0.f;
- if (test_proc) {
- proc_busy = sampler.GetProcessLoad();
- }
- if (test_sys) {
- sys_busy = sampler.GetSystemLoad();
- }
- if (test_proc) {
- LOG(LS_INFO) << "ProcessLoad Busy: "
- << std::setiosflags(std::ios_base::fixed)
- << std::setprecision(2) << std::setw(6) << proc_busy;
- EXPECT_GE(proc_busy, 0.f);
- EXPECT_LE(proc_busy, static_cast<float>(cpus));
- }
- if (test_sys) {
- LOG(LS_INFO) << "SystemLoad Busy: "
- << std::setiosflags(std::ios_base::fixed)
- << std::setprecision(2) << std::setw(6) << sys_busy;
- EXPECT_GE(sys_busy, 0.f);
- EXPECT_LE(sys_busy, static_cast<float>(cpus));
- }
-
- // Test4: CpuSampler with 2 cpus process busy.
- if (cpus >= 2) {
- Thread::SleepMs(kSettleTime);
- sampler.GetProcessLoad();
- sampler.GetSystemLoad();
-
- CpuTwoBusyLoop(kBusyTime);
-
- float proc_twobusy = 0.f, sys_twobusy = 0.f;
- if (test_proc) {
- proc_twobusy = sampler.GetProcessLoad();
- }
- if (test_sys) {
- sys_twobusy = sampler.GetSystemLoad();
- }
- if (test_proc) {
- LOG(LS_INFO) << "ProcessLoad 2 CPU Busy:"
- << std::setiosflags(std::ios_base::fixed)
- << std::setprecision(2) << std::setw(6) << proc_twobusy;
- EXPECT_GE(proc_twobusy, 0.f);
- EXPECT_LE(proc_twobusy, static_cast<float>(cpus));
- }
- if (test_sys) {
- LOG(LS_INFO) << "SystemLoad 2 CPU Busy: "
- << std::setiosflags(std::ios_base::fixed)
- << std::setprecision(2) << std::setw(6) << sys_twobusy;
- EXPECT_GE(sys_twobusy, 0.f);
- EXPECT_LE(sys_twobusy, static_cast<float>(cpus));
- }
- }
-
- // Test5: CpuSampler with idle process after being busy.
- Thread::SleepMs(kSettleTime);
- sampler.GetProcessLoad();
- sampler.GetSystemLoad();
-
- Thread::SleepMs(kIdleTime);
-
- if (test_proc) {
- proc_idle = sampler.GetProcessLoad();
- }
- if (test_sys) {
- sys_idle = sampler.GetSystemLoad();
- }
- if (test_proc) {
- LOG(LS_INFO) << "ProcessLoad Idle: "
- << std::setiosflags(std::ios_base::fixed)
- << std::setprecision(2) << std::setw(6) << proc_idle;
- EXPECT_GE(proc_idle, 0.f);
- EXPECT_LE(proc_idle, proc_busy);
- }
- if (test_sys) {
- LOG(LS_INFO) << "SystemLoad Idle: "
- << std::setiosflags(std::ios_base::fixed)
- << std::setprecision(2) << std::setw(6) << sys_idle;
- EXPECT_GE(sys_idle, 0.f);
- EXPECT_LE(sys_idle, static_cast<float>(cpus));
- }
-}
-
-TEST(CpuMonitorTest, TestCpus) {
- CpuSampler sampler;
- EXPECT_TRUE(sampler.Init());
- int current_cpus = sampler.GetCurrentCpus();
- int cpus = sampler.GetMaxCpus();
- LOG(LS_INFO) << "Current Cpus: " << std::setw(9) << current_cpus;
- LOG(LS_INFO) << "Maximum Cpus: " << std::setw(9) << cpus;
- EXPECT_GT(cpus, 0);
- EXPECT_LE(cpus, kMaxCpus);
- EXPECT_GT(current_cpus, 0);
- EXPECT_LE(current_cpus, cpus);
-}
-
-#if defined(WEBRTC_WIN)
-// Tests overall system CpuSampler using legacy OS fallback code if applicable.
-TEST(CpuMonitorTest, TestGetSystemLoadForceFallback) {
- TestCpuSampler(false, true, true);
-}
-#endif
-
-// Tests both process and system functions in use at same time.
-TEST(CpuMonitorTest, TestGetBothLoad) {
- TestCpuSampler(true, true, false);
-}
-
-// Tests a query less than the interval produces the same value.
-TEST(CpuMonitorTest, TestInterval) {
- CpuSampler sampler;
- EXPECT_TRUE(sampler.Init());
-
- // Test1: Set interval to large value so sampler will not update.
- sampler.set_load_interval(kLongInterval);
-
- sampler.GetProcessLoad();
- sampler.GetSystemLoad();
-
- float proc_orig = sampler.GetProcessLoad();
- float sys_orig = sampler.GetSystemLoad();
-
- Thread::SleepMs(kIdleTime);
-
- float proc_halftime = sampler.GetProcessLoad();
- float sys_halftime = sampler.GetSystemLoad();
-
- EXPECT_EQ(proc_orig, proc_halftime);
- EXPECT_EQ(sys_orig, sys_halftime);
-}
-
-TEST(CpuMonitorTest, TestCpuMonitor) {
- CpuMonitor monitor(Thread::Current());
- CpuLoadListener listener;
- monitor.SignalUpdate.connect(&listener, &CpuLoadListener::OnCpuLoad);
- EXPECT_TRUE(monitor.Start(10));
- // We have checked cpu load more than twice.
- EXPECT_TRUE_WAIT(listener.count() > 2, 1000);
- EXPECT_GT(listener.current_cpus(), 0);
- EXPECT_GT(listener.cpus(), 0);
- EXPECT_GE(listener.process_load(), .0f);
- EXPECT_GE(listener.system_load(), .0f);
-
- monitor.Stop();
- // Wait 20 ms to ake sure all signals are delivered.
- Thread::Current()->ProcessMessages(20);
- int old_count = listener.count();
- Thread::Current()->ProcessMessages(20);
- // Verfy no more siganls.
- EXPECT_EQ(old_count, listener.count());
-}
-
-} // namespace rtc
diff --git a/webrtc/base/platform_thread.cc b/webrtc/base/platform_thread.cc
index af90672..05b7a25 100644
--- a/webrtc/base/platform_thread.cc
+++ b/webrtc/base/platform_thread.cc
@@ -76,18 +76,6 @@
#endif
}
-} // 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) {
@@ -139,7 +127,7 @@
}
#endif // defined(WEBRTC_WIN)
-bool PlatformThread::Start() {
+void PlatformThread::Start() {
RTC_DCHECK(thread_checker_.CalledOnValidThread());
RTC_DCHECK(!thread_) << "Thread already started?";
#if defined(WEBRTC_WIN)
@@ -158,28 +146,33 @@
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() {
+bool PlatformThread::IsRunning() const {
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;
- }
+ return thread_ != nullptr;
#else
- if (!thread_)
- return true;
+ return thread_ != 0;
+#endif // defined(WEBRTC_WIN)
+}
+void PlatformThread::Stop() {
+ RTC_DCHECK(thread_checker_.CalledOnValidThread());
+ if (!IsRunning())
+ return;
+
+#if defined(WEBRTC_WIN)
+ // Set stop_ to |true| on the worker thread.
+ QueueUserAPC(&RaiseFlag, thread_, reinterpret_cast<ULONG_PTR>(&stop_));
+ WaitForSingleObject(thread_, INFINITE);
+ CloseHandle(thread_);
+ thread_ = nullptr;
+#else
stop_event_.Set();
RTC_CHECK_EQ(0, pthread_join(thread_, nullptr));
thread_ = 0;
#endif // defined(WEBRTC_WIN)
- return true;
}
void PlatformThread::Run() {
@@ -202,8 +195,9 @@
bool PlatformThread::SetPriority(ThreadPriority priority) {
RTC_DCHECK(thread_checker_.CalledOnValidThread());
+ RTC_DCHECK(IsRunning());
#if defined(WEBRTC_WIN)
- return thread_ && SetThreadPriority(thread_, priority);
+ return SetThreadPriority(thread_, priority) != FALSE;
#elif defined(__native_client__)
// Setting thread priorities is not supported in NaCl.
return true;
@@ -212,8 +206,6 @@
// thread priorities.
return true;
#else
- if (!thread_)
- return false;
#ifdef WEBRTC_THREAD_RR
const int policy = SCHED_RR;
#else
@@ -255,4 +247,4 @@
#endif // defined(WEBRTC_WIN)
}
-} // namespace webrtc
+} // namespace rtc
diff --git a/webrtc/base/platform_thread.h b/webrtc/base/platform_thread.h
index e2d9b33..53465e4 100644
--- a/webrtc/base/platform_thread.h
+++ b/webrtc/base/platform_thread.h
@@ -30,11 +30,6 @@
// Sets the current thread name.
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.
@@ -59,43 +54,21 @@
// 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);
+ // Spawns a thread and tries to set thread priority according to the priority
+ // from when CreateThread was called.
+ void Start();
- // 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();
+ bool IsRunning() const;
- // 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();
+ // Stops (joins) the spawned thread.
+ void Stop();
- // Set the priority of the worker thread. Must be called when thread
- // is running.
+ // Set the priority of the thread. Must be called when thread is running.
bool SetPriority(ThreadPriority priority);
private:
@@ -122,6 +95,6 @@
RTC_DISALLOW_COPY_AND_ASSIGN(PlatformThread);
};
-} // namespace webrtc
+} // namespace rtc
#endif // WEBRTC_BASE_PLATFORM_THREAD_H_
diff --git a/webrtc/base/platform_thread_unittest.cc b/webrtc/base/platform_thread_unittest.cc
index ffb60b5..f9db8e3 100644
--- a/webrtc/base/platform_thread_unittest.cc
+++ b/webrtc/base/platform_thread_unittest.cc
@@ -23,10 +23,9 @@
}
TEST(PlatformThreadTest, StartStop) {
- rtc::scoped_ptr<PlatformThread> thread = PlatformThread::CreateThread(
- &NullRunFunction, nullptr, "PlatformThreadTest");
- ASSERT_TRUE(thread->Start());
- EXPECT_TRUE(thread->Stop());
+ rtc::PlatformThread thread(&NullRunFunction, nullptr, "PlatformThreadTest");
+ thread.Start();
+ thread.Stop();
}
// Function that sets a boolean.
@@ -39,12 +38,11 @@
TEST(PlatformThreadTest, RunFunctionIsCalled) {
bool flag = false;
- rtc::scoped_ptr<PlatformThread> thread = PlatformThread::CreateThread(
- &SetFlagRunFunction, &flag, "RunFunctionIsCalled");
- ASSERT_TRUE(thread->Start());
+ rtc::PlatformThread thread(&SetFlagRunFunction, &flag, "RunFunctionIsCalled");
+ thread.Start();
// At this point, the flag may be either true or false.
- EXPECT_TRUE(thread->Stop());
+ thread.Stop();
// We expect the thread to have run at least once.
EXPECT_TRUE(flag);
diff --git a/webrtc/base/signalthread.cc b/webrtc/base/signalthread.cc
index d03f386..75f7b77 100644
--- a/webrtc/base/signalthread.cc
+++ b/webrtc/base/signalthread.cc
@@ -39,13 +39,6 @@
return worker_.SetName(name, obj);
}
-bool SignalThread::SetPriority(ThreadPriority priority) {
- EnterExit ee(this);
- ASSERT(main_->IsCurrent());
- ASSERT(kInit == state_);
- return worker_.SetPriority(priority);
-}
-
void SignalThread::Start() {
EnterExit ee(this);
ASSERT(main_->IsCurrent());
diff --git a/webrtc/base/signalthread.h b/webrtc/base/signalthread.h
index 4dda889..ec250c6 100644
--- a/webrtc/base/signalthread.h
+++ b/webrtc/base/signalthread.h
@@ -45,9 +45,6 @@
// Context: Main Thread. Call before Start to change the worker's name.
bool SetName(const std::string& name, const void* obj);
- // Context: Main Thread. Call before Start to change the worker's priority.
- bool SetPriority(ThreadPriority priority);
-
// Context: Main Thread. Call to begin the worker thread.
void Start();
diff --git a/webrtc/base/thread.cc b/webrtc/base/thread.cc
index 2a5119b..4197d28 100644
--- a/webrtc/base/thread.cc
+++ b/webrtc/base/thread.cc
@@ -140,7 +140,6 @@
Thread::Thread(SocketServer* ss)
: MessageQueue(ss),
- priority_(PRIORITY_NORMAL),
running_(true, false),
#if defined(WEBRTC_WIN)
thread_(NULL),
@@ -188,34 +187,6 @@
return true;
}
-bool Thread::SetPriority(ThreadPriority priority) {
-#if defined(WEBRTC_WIN)
- if (running()) {
- ASSERT(thread_ != NULL);
- BOOL ret = FALSE;
- if (priority == PRIORITY_NORMAL) {
- ret = ::SetThreadPriority(thread_, THREAD_PRIORITY_NORMAL);
- } else if (priority == PRIORITY_HIGH) {
- ret = ::SetThreadPriority(thread_, THREAD_PRIORITY_HIGHEST);
- } else if (priority == PRIORITY_ABOVE_NORMAL) {
- ret = ::SetThreadPriority(thread_, THREAD_PRIORITY_ABOVE_NORMAL);
- } else if (priority == PRIORITY_IDLE) {
- ret = ::SetThreadPriority(thread_, THREAD_PRIORITY_IDLE);
- }
- if (!ret) {
- return false;
- }
- }
- priority_ = priority;
- return true;
-#else
- // TODO: Implement for Linux/Mac if possible.
- if (running()) return false;
- priority_ = priority;
- return true;
-#endif
-}
-
bool Thread::Start(Runnable* runnable) {
ASSERT(owned_);
if (!owned_) return false;
@@ -232,18 +203,10 @@
init->thread = this;
init->runnable = runnable;
#if defined(WEBRTC_WIN)
- DWORD flags = 0;
- if (priority_ != PRIORITY_NORMAL) {
- flags = CREATE_SUSPENDED;
- }
- thread_ = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)PreRun, init, flags,
+ thread_ = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)PreRun, init, 0,
&thread_id_);
if (thread_) {
running_.Set();
- if (priority_ != PRIORITY_NORMAL) {
- SetPriority(priority_);
- ::ResumeThread(thread_);
- }
} else {
return false;
}
@@ -251,37 +214,6 @@
pthread_attr_t attr;
pthread_attr_init(&attr);
- // Thread priorities are not supported in NaCl.
-#if !defined(__native_client__)
- if (priority_ != PRIORITY_NORMAL) {
- if (priority_ == PRIORITY_IDLE) {
- // There is no POSIX-standard way to set a below-normal priority for an
- // individual thread (only whole process), so let's not support it.
- LOG(LS_WARNING) << "PRIORITY_IDLE not supported";
- } else {
- // Set real-time round-robin policy.
- if (pthread_attr_setschedpolicy(&attr, SCHED_RR) != 0) {
- LOG(LS_ERROR) << "pthread_attr_setschedpolicy";
- }
- struct sched_param param;
- if (pthread_attr_getschedparam(&attr, ¶m) != 0) {
- LOG(LS_ERROR) << "pthread_attr_getschedparam";
- } else {
- // The numbers here are arbitrary.
- if (priority_ == PRIORITY_HIGH) {
- param.sched_priority = 6; // 6 = HIGH
- } else {
- ASSERT(priority_ == PRIORITY_ABOVE_NORMAL);
- param.sched_priority = 4; // 4 = ABOVE_NORMAL
- }
- if (pthread_attr_setschedparam(&attr, ¶m) != 0) {
- LOG(LS_ERROR) << "pthread_attr_setschedparam";
- }
- }
- }
- }
-#endif // !defined(__native_client__)
-
int error_code = pthread_create(&thread_, &attr, PreRun, init);
if (0 != error_code) {
LOG(LS_ERROR) << "Unable to create pthread, error " << error_code;
diff --git a/webrtc/base/thread.h b/webrtc/base/thread.h
index 9cbe8ec..f91aa56 100644
--- a/webrtc/base/thread.h
+++ b/webrtc/base/thread.h
@@ -78,13 +78,6 @@
bool *ready;
};
-enum ThreadPriority {
- PRIORITY_IDLE = -1,
- PRIORITY_NORMAL = 0,
- PRIORITY_ABOVE_NORMAL = 1,
- PRIORITY_HIGH = 2,
-};
-
class Runnable {
public:
virtual ~Runnable() {}
@@ -137,10 +130,6 @@
const std::string& name() const { return name_; }
bool SetName(const std::string& name, const void* obj);
- // Sets the thread's priority. Must be called before Start().
- ThreadPriority priority() const { return priority_; }
- bool SetPriority(ThreadPriority priority);
-
// Starts the execution of the thread.
bool Start(Runnable* runnable = NULL);
@@ -271,7 +260,6 @@
std::list<_SendMessage> sendlist_;
std::string name_;
- ThreadPriority priority_;
Event running_; // Signalled means running.
#if defined(WEBRTC_POSIX)
diff --git a/webrtc/base/thread_unittest.cc b/webrtc/base/thread_unittest.cc
index 3878676..a826298 100644
--- a/webrtc/base/thread_unittest.cc
+++ b/webrtc/base/thread_unittest.cc
@@ -252,33 +252,6 @@
delete thread;
}
-// Test that setting thread priorities doesn't cause a malfunction.
-// There's no easy way to verify the priority was set properly at this time.
-TEST(ThreadTest, Priorities) {
- Thread *thread;
- thread = new Thread();
- EXPECT_TRUE(thread->SetPriority(PRIORITY_HIGH));
- EXPECT_TRUE(thread->Start());
- thread->Stop();
- delete thread;
- thread = new Thread();
- EXPECT_TRUE(thread->SetPriority(PRIORITY_ABOVE_NORMAL));
- EXPECT_TRUE(thread->Start());
- thread->Stop();
- delete thread;
-
- thread = new Thread();
- EXPECT_TRUE(thread->Start());
-#if defined(WEBRTC_WIN)
- EXPECT_TRUE(thread->SetPriority(PRIORITY_ABOVE_NORMAL));
-#else
- EXPECT_FALSE(thread->SetPriority(PRIORITY_ABOVE_NORMAL));
-#endif
- thread->Stop();
- delete thread;
-
-}
-
TEST(ThreadTest, Wrap) {
Thread* current_thread = Thread::Current();
current_thread->UnwrapCurrent();
diff --git a/webrtc/common_video/include/incoming_video_stream.h b/webrtc/common_video/include/incoming_video_stream.h
index 3fa1424..e3147eb 100644
--- a/webrtc/common_video/include/incoming_video_stream.h
+++ b/webrtc/common_video/include/incoming_video_stream.h
@@ -11,6 +11,7 @@
#ifndef WEBRTC_COMMON_VIDEO_INCLUDE_INCOMING_VIDEO_STREAM_H_
#define WEBRTC_COMMON_VIDEO_INCLUDE_INCOMING_VIDEO_STREAM_H_
+#include "webrtc/base/platform_thread.h"
#include "webrtc/base/scoped_ptr.h"
#include "webrtc/base/thread_annotations.h"
#include "webrtc/common_video/video_render_frames.h"
@@ -18,8 +19,6 @@
namespace webrtc {
class CriticalSectionWrapper;
class EventTimerWrapper;
-class PlatformThread;
-class VideoRenderer;
class VideoRenderCallback {
public:
@@ -81,7 +80,9 @@
const rtc::scoped_ptr<CriticalSectionWrapper> stream_critsect_;
const rtc::scoped_ptr<CriticalSectionWrapper> thread_critsect_;
const rtc::scoped_ptr<CriticalSectionWrapper> buffer_critsect_;
- rtc::scoped_ptr<PlatformThread> incoming_render_thread_
+ // TODO(pbos): Make plain member and stop resetting this thread, just
+ // start/stoping it is enough.
+ rtc::scoped_ptr<rtc::PlatformThread> incoming_render_thread_
GUARDED_BY(thread_critsect_);
rtc::scoped_ptr<EventTimerWrapper> deliver_buffer_event_;
diff --git a/webrtc/common_video/incoming_video_stream.cc b/webrtc/common_video/incoming_video_stream.cc
index 010a57e..1272ecc 100644
--- a/webrtc/common_video/incoming_video_stream.cc
+++ b/webrtc/common_video/incoming_video_stream.cc
@@ -138,19 +138,17 @@
CriticalSectionScoped csT(thread_critsect_.get());
assert(incoming_render_thread_ == NULL);
- incoming_render_thread_ = PlatformThread::CreateThread(
- IncomingVideoStreamThreadFun, this, "IncomingVideoStreamThread");
+ incoming_render_thread_.reset(new rtc::PlatformThread(
+ IncomingVideoStreamThreadFun, this, "IncomingVideoStreamThread"));
if (!incoming_render_thread_) {
return -1;
}
- if (incoming_render_thread_->Start()) {
- } else {
- return -1;
- }
- incoming_render_thread_->SetPriority(kRealtimePriority);
+ incoming_render_thread_->Start();
+ incoming_render_thread_->SetPriority(rtc::kRealtimePriority);
deliver_buffer_event_->StartTimer(false, kEventStartupTimeMs);
}
+
running_ = true;
return 0;
}
@@ -162,7 +160,7 @@
return 0;
}
- PlatformThread* thread = NULL;
+ rtc::PlatformThread* thread = NULL;
{
CriticalSectionScoped cs_thread(thread_critsect_.get());
if (incoming_render_thread_) {
@@ -176,11 +174,8 @@
}
}
if (thread) {
- if (thread->Stop()) {
- delete thread;
- } else {
- assert(false);
- }
+ thread->Stop();
+ delete thread;
}
running_ = false;
return 0;
diff --git a/webrtc/modules/audio_coding/acm2/audio_coding_module_unittest_oldapi.cc b/webrtc/modules/audio_coding/acm2/audio_coding_module_unittest_oldapi.cc
index 39c14a8..1045e7e 100644
--- a/webrtc/modules/audio_coding/acm2/audio_coding_module_unittest_oldapi.cc
+++ b/webrtc/modules/audio_coding/acm2/audio_coding_module_unittest_oldapi.cc
@@ -457,13 +457,9 @@
AudioCodingModuleMtTestOldApi()
: AudioCodingModuleTestOldApi(),
- 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")),
+ send_thread_(CbSendThread, this, "send"),
+ insert_packet_thread_(CbInsertPacketThread, this, "insert_packet"),
+ pull_audio_thread_(CbPullAudioThread, this, "pull_audio"),
test_complete_(EventWrapper::Create()),
send_count_(0),
insert_packet_count_(0),
@@ -481,19 +477,19 @@
}
void StartThreads() {
- ASSERT_TRUE(send_thread_->Start());
- send_thread_->SetPriority(kRealtimePriority);
- ASSERT_TRUE(insert_packet_thread_->Start());
- insert_packet_thread_->SetPriority(kRealtimePriority);
- ASSERT_TRUE(pull_audio_thread_->Start());
- pull_audio_thread_->SetPriority(kRealtimePriority);
+ send_thread_.Start();
+ send_thread_.SetPriority(rtc::kRealtimePriority);
+ insert_packet_thread_.Start();
+ insert_packet_thread_.SetPriority(rtc::kRealtimePriority);
+ pull_audio_thread_.Start();
+ pull_audio_thread_.SetPriority(rtc::kRealtimePriority);
}
void TearDown() {
AudioCodingModuleTestOldApi::TearDown();
- pull_audio_thread_->Stop();
- send_thread_->Stop();
- insert_packet_thread_->Stop();
+ pull_audio_thread_.Stop();
+ send_thread_.Stop();
+ insert_packet_thread_.Stop();
}
EventTypeWrapper RunTest() {
@@ -573,9 +569,9 @@
return true;
}
- rtc::scoped_ptr<PlatformThread> send_thread_;
- rtc::scoped_ptr<PlatformThread> insert_packet_thread_;
- rtc::scoped_ptr<PlatformThread> pull_audio_thread_;
+ rtc::PlatformThread send_thread_;
+ rtc::PlatformThread insert_packet_thread_;
+ rtc::PlatformThread pull_audio_thread_;
const rtc::scoped_ptr<EventWrapper> test_complete_;
int send_count_;
int insert_packet_count_;
@@ -702,12 +698,10 @@
AcmReRegisterIsacMtTestOldApi()
: AudioCodingModuleTestOldApi(),
- receive_thread_(
- PlatformThread::CreateThread(CbReceiveThread, this, "receive")),
- codec_registration_thread_(
- PlatformThread::CreateThread(CbCodecRegistrationThread,
- this,
- "codec_registration")),
+ receive_thread_(CbReceiveThread, this, "receive"),
+ codec_registration_thread_(CbCodecRegistrationThread,
+ this,
+ "codec_registration"),
test_complete_(EventWrapper::Create()),
crit_sect_(CriticalSectionWrapper::CreateCriticalSection()),
codec_registered_(false),
@@ -743,16 +737,16 @@
}
void StartThreads() {
- ASSERT_TRUE(receive_thread_->Start());
- receive_thread_->SetPriority(kRealtimePriority);
- ASSERT_TRUE(codec_registration_thread_->Start());
- codec_registration_thread_->SetPriority(kRealtimePriority);
+ receive_thread_.Start();
+ receive_thread_.SetPriority(rtc::kRealtimePriority);
+ codec_registration_thread_.Start();
+ codec_registration_thread_.SetPriority(rtc::kRealtimePriority);
}
void TearDown() {
AudioCodingModuleTestOldApi::TearDown();
- receive_thread_->Stop();
- codec_registration_thread_->Stop();
+ receive_thread_.Stop();
+ codec_registration_thread_.Stop();
}
EventTypeWrapper RunTest() {
@@ -831,8 +825,8 @@
return true;
}
- rtc::scoped_ptr<PlatformThread> receive_thread_;
- rtc::scoped_ptr<PlatformThread> codec_registration_thread_;
+ rtc::PlatformThread receive_thread_;
+ rtc::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_);
diff --git a/webrtc/modules/audio_coding/test/APITest.cc b/webrtc/modules/audio_coding/test/APITest.cc
index 59a5a3a..bf04d7c 100644
--- a/webrtc/modules/audio_coding/test/APITest.cc
+++ b/webrtc/modules/audio_coding/test/APITest.cc
@@ -36,12 +36,6 @@
#define TEST_DURATION_SEC 600
#define NUMBER_OF_SENDER_TESTS 6
#define MAX_FILE_NAME_LENGTH_BYTE 500
-#define CHECK_THREAD_NULLITY(myThread, S) \
- if(myThread != NULL) { \
- (myThread)->Start(); \
- } else { \
- ADD_FAILURE() << S; \
- }
void APITest::Wait(uint32_t waitLengthMs) {
if (_randomTest) {
@@ -522,38 +516,34 @@
//--- THREADS
// A
// PUSH
- rtc::scoped_ptr<PlatformThread> myPushAudioThreadA =
- PlatformThread::CreateThread(PushAudioThreadA, this, "PushAudioThreadA");
- CHECK_THREAD_NULLITY(myPushAudioThreadA, "Unable to start A::PUSH thread");
+ rtc::PlatformThread myPushAudioThreadA(PushAudioThreadA, this,
+ "PushAudioThreadA");
+ myPushAudioThreadA.Start();
// PULL
- rtc::scoped_ptr<PlatformThread> myPullAudioThreadA =
- PlatformThread::CreateThread(PullAudioThreadA, this, "PullAudioThreadA");
- CHECK_THREAD_NULLITY(myPullAudioThreadA, "Unable to start A::PULL thread");
+ rtc::PlatformThread myPullAudioThreadA(PullAudioThreadA, this,
+ "PullAudioThreadA");
+ myPullAudioThreadA.Start();
// Process
- rtc::scoped_ptr<PlatformThread> myProcessThreadA =
- PlatformThread::CreateThread(ProcessThreadA, this, "ProcessThreadA");
- CHECK_THREAD_NULLITY(myProcessThreadA, "Unable to start A::Process thread");
+ rtc::PlatformThread myProcessThreadA(ProcessThreadA, this, "ProcessThreadA");
+ myProcessThreadA.Start();
// API
- rtc::scoped_ptr<PlatformThread> myAPIThreadA =
- PlatformThread::CreateThread(APIThreadA, this, "APIThreadA");
- CHECK_THREAD_NULLITY(myAPIThreadA, "Unable to start A::API thread");
+ rtc::PlatformThread myAPIThreadA(APIThreadA, this, "APIThreadA");
+ myAPIThreadA.Start();
// B
// PUSH
- rtc::scoped_ptr<PlatformThread> myPushAudioThreadB =
- PlatformThread::CreateThread(PushAudioThreadB, this, "PushAudioThreadB");
- CHECK_THREAD_NULLITY(myPushAudioThreadB, "Unable to start B::PUSH thread");
+ rtc::PlatformThread myPushAudioThreadB(PushAudioThreadB, this,
+ "PushAudioThreadB");
+ myPushAudioThreadB.Start();
// PULL
- rtc::scoped_ptr<PlatformThread> myPullAudioThreadB =
- PlatformThread::CreateThread(PullAudioThreadB, this, "PullAudioThreadB");
- CHECK_THREAD_NULLITY(myPullAudioThreadB, "Unable to start B::PULL thread");
+ rtc::PlatformThread myPullAudioThreadB(PullAudioThreadB, this,
+ "PullAudioThreadB");
+ myPullAudioThreadB.Start();
// Process
- rtc::scoped_ptr<PlatformThread> myProcessThreadB =
- PlatformThread::CreateThread(ProcessThreadB, this, "ProcessThreadB");
- CHECK_THREAD_NULLITY(myProcessThreadB, "Unable to start B::Process thread");
+ rtc::PlatformThread myProcessThreadB(ProcessThreadB, this, "ProcessThreadB");
+ myProcessThreadB.Start();
// API
- rtc::scoped_ptr<PlatformThread> myAPIThreadB =
- PlatformThread::CreateThread(APIThreadB, this, "APIThreadB");
- CHECK_THREAD_NULLITY(myAPIThreadB, "Unable to start B::API thread");
+ rtc::PlatformThread myAPIThreadB(APIThreadB, this, "APIThreadB");
+ myAPIThreadB.Start();
//_apiEventA->StartTimer(true, 5000);
//_apiEventB->StartTimer(true, 5000);
@@ -587,15 +577,15 @@
//(unsigned long)((unsigned long)TEST_DURATION_SEC * (unsigned long)1000));
delete completeEvent;
- myPushAudioThreadA->Stop();
- myPullAudioThreadA->Stop();
- myProcessThreadA->Stop();
- myAPIThreadA->Stop();
+ myPushAudioThreadA.Stop();
+ myPullAudioThreadA.Stop();
+ myProcessThreadA.Stop();
+ myAPIThreadA.Stop();
- myPushAudioThreadB->Stop();
- myPullAudioThreadB->Stop();
- myProcessThreadB->Stop();
- myAPIThreadB->Stop();
+ myPushAudioThreadB.Stop();
+ myPullAudioThreadB.Stop();
+ myProcessThreadB.Stop();
+ myAPIThreadB.Stop();
}
void APITest::CheckVADStatus(char side) {
diff --git a/webrtc/modules/audio_device/dummy/file_audio_device.cc b/webrtc/modules/audio_device/dummy/file_audio_device.cc
index d59eae2..3fff40b 100644
--- a/webrtc/modules/audio_device/dummy/file_audio_device.cc
+++ b/webrtc/modules/audio_device/dummy/file_audio_device.cc
@@ -213,17 +213,10 @@
return -1;
}
- const char* threadName = "webrtc_audio_module_play_thread";
- _ptrThreadPlay =
- PlatformThread::CreateThread(PlayThreadFunc, this, threadName);
- if (!_ptrThreadPlay->Start()) {
- _ptrThreadPlay.reset();
- _playing = false;
- delete [] _playoutBuffer;
- _playoutBuffer = NULL;
- return -1;
- }
- _ptrThreadPlay->SetPriority(kRealtimePriority);
+ _ptrThreadPlay.reset(new rtc::PlatformThread(
+ PlayThreadFunc, this, "webrtc_audio_module_play_thread"));
+ _ptrThreadPlay->Start();
+ _ptrThreadPlay->SetPriority(rtc::kRealtimePriority);
return 0;
}
@@ -276,17 +269,11 @@
return -1;
}
- const char* threadName = "webrtc_audio_module_capture_thread";
- _ptrThreadRec = PlatformThread::CreateThread(RecThreadFunc, this, threadName);
+ _ptrThreadRec.reset(new rtc::PlatformThread(
+ RecThreadFunc, this, "webrtc_audio_module_capture_thread"));
- if (!_ptrThreadRec->Start()) {
- _ptrThreadRec.reset();
- _recording = false;
- delete [] _recordingBuffer;
- _recordingBuffer = NULL;
- return -1;
- }
- _ptrThreadRec->SetPriority(kRealtimePriority);
+ _ptrThreadRec->Start();
+ _ptrThreadRec->SetPriority(rtc::kRealtimePriority);
return 0;
}
diff --git a/webrtc/modules/audio_device/dummy/file_audio_device.h b/webrtc/modules/audio_device/dummy/file_audio_device.h
index a8a71ca..7717940 100644
--- a/webrtc/modules/audio_device/dummy/file_audio_device.h
+++ b/webrtc/modules/audio_device/dummy/file_audio_device.h
@@ -20,9 +20,12 @@
#include "webrtc/system_wrappers/include/file_wrapper.h"
#include "webrtc/system_wrappers/include/clock.h"
+namespace rtc {
+class PlatformThread;
+} // namespace rtc
+
namespace webrtc {
class EventWrapper;
-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 +181,9 @@
size_t _recordingFramesIn10MS;
size_t _playoutFramesIn10MS;
- rtc::scoped_ptr<PlatformThread> _ptrThreadRec;
- rtc::scoped_ptr<PlatformThread> _ptrThreadPlay;
+ // TODO(pbos): Make plain members instead of pointers and stop resetting them.
+ rtc::scoped_ptr<rtc::PlatformThread> _ptrThreadRec;
+ rtc::scoped_ptr<rtc::PlatformThread> _ptrThreadPlay;
bool _playing;
bool _recording;
diff --git a/webrtc/modules/audio_device/linux/audio_device_alsa_linux.cc b/webrtc/modules/audio_device/linux/audio_device_alsa_linux.cc
index b8c19a2..bdbccde 100644
--- a/webrtc/modules/audio_device/linux/audio_device_alsa_linux.cc
+++ b/webrtc/modules/audio_device/linux/audio_device_alsa_linux.cc
@@ -207,7 +207,7 @@
// RECORDING
if (_ptrThreadRec)
{
- PlatformThread* tmpThread = _ptrThreadRec.release();
+ rtc::PlatformThread* tmpThread = _ptrThreadRec.release();
_critSect.Leave();
tmpThread->Stop();
@@ -219,7 +219,7 @@
// PLAYOUT
if (_ptrThreadPlay)
{
- PlatformThread* tmpThread = _ptrThreadPlay.release();
+ rtc::PlatformThread* tmpThread = _ptrThreadPlay.release();
_critSect.Leave();
tmpThread->Stop();
@@ -1363,21 +1363,11 @@
return -1;
}
// RECORDING
- const char* threadName = "webrtc_audio_module_capture_thread";
- _ptrThreadRec =
- PlatformThread::CreateThread(RecThreadFunc, this, threadName);
+ _ptrThreadRec.reset(new rtc::PlatformThread(
+ RecThreadFunc, this, "webrtc_audio_module_capture_thread"));
- if (!_ptrThreadRec->Start())
- {
- WEBRTC_TRACE(kTraceCritical, kTraceAudioDevice, _id,
- " failed to start the rec audio thread");
- _recording = false;
- _ptrThreadRec.reset();
- delete [] _recordingBuffer;
- _recordingBuffer = NULL;
- return -1;
- }
- _ptrThreadRec->SetPriority(kRealtimePriority);
+ _ptrThreadRec->Start();
+ _ptrThreadRec->SetPriority(rtc::kRealtimePriority);
errVal = LATE(snd_pcm_prepare)(_handleRecord);
if (errVal < 0)
@@ -1517,20 +1507,10 @@
}
// PLAYOUT
- const char* threadName = "webrtc_audio_module_play_thread";
- _ptrThreadPlay =
- PlatformThread::CreateThread(PlayThreadFunc, this, threadName);
- if (!_ptrThreadPlay->Start())
- {
- WEBRTC_TRACE(kTraceCritical, kTraceAudioDevice, _id,
- " failed to start the play audio thread");
- _playing = false;
- _ptrThreadPlay.reset();
- delete [] _playoutBuffer;
- _playoutBuffer = NULL;
- return -1;
- }
- _ptrThreadPlay->SetPriority(kRealtimePriority);
+ _ptrThreadPlay.reset(new rtc::PlatformThread(
+ PlayThreadFunc, this, "webrtc_audio_module_play_thread"));
+ _ptrThreadPlay->Start();
+ _ptrThreadPlay->SetPriority(rtc::kRealtimePriority);
int errVal = LATE(snd_pcm_prepare)(_handlePlayout);
if (errVal < 0)
diff --git a/webrtc/modules/audio_device/linux/audio_device_alsa_linux.h b/webrtc/modules/audio_device/linux/audio_device_alsa_linux.h
index c61dc86..4a1a519 100644
--- a/webrtc/modules/audio_device/linux/audio_device_alsa_linux.h
+++ b/webrtc/modules/audio_device/linux/audio_device_alsa_linux.h
@@ -185,8 +185,10 @@
CriticalSectionWrapper& _critSect;
- rtc::scoped_ptr<PlatformThread> _ptrThreadRec;
- rtc::scoped_ptr<PlatformThread> _ptrThreadPlay;
+ // TODO(pbos): Make plain members and start/stop instead of resetting these
+ // pointers. A thread can be reused.
+ rtc::scoped_ptr<rtc::PlatformThread> _ptrThreadRec;
+ rtc::scoped_ptr<rtc::PlatformThread> _ptrThreadPlay;
int32_t _id;
diff --git a/webrtc/modules/audio_device/linux/audio_device_pulse_linux.cc b/webrtc/modules/audio_device/linux/audio_device_pulse_linux.cc
index 7970ef7..42c3ea8 100644
--- a/webrtc/modules/audio_device/linux/audio_device_pulse_linux.cc
+++ b/webrtc/modules/audio_device/linux/audio_device_pulse_linux.cc
@@ -200,33 +200,17 @@
}
// RECORDING
- const char* threadName = "webrtc_audio_module_rec_thread";
- _ptrThreadRec =
- PlatformThread::CreateThread(RecThreadFunc, this, threadName);
- if (!_ptrThreadRec->Start())
- {
- WEBRTC_TRACE(kTraceCritical, kTraceAudioDevice, _id,
- " failed to start the rec audio thread");
+ _ptrThreadRec.reset(new rtc::PlatformThread(
+ RecThreadFunc, this, "webrtc_audio_module_rec_thread"));
- _ptrThreadRec.reset();
- return -1;
- }
-
- _ptrThreadRec->SetPriority(kRealtimePriority);
+ _ptrThreadRec->Start();
+ _ptrThreadRec->SetPriority(rtc::kRealtimePriority);
// PLAYOUT
- threadName = "webrtc_audio_module_play_thread";
- _ptrThreadPlay =
- PlatformThread::CreateThread(PlayThreadFunc, this, threadName);
- if (!_ptrThreadPlay->Start())
- {
- WEBRTC_TRACE(kTraceCritical, kTraceAudioDevice, _id,
- " failed to start the play audio thread");
-
- _ptrThreadPlay.reset();
- return -1;
- }
- _ptrThreadPlay->SetPriority(kRealtimePriority);
+ _ptrThreadPlay.reset(new rtc::PlatformThread(
+ PlayThreadFunc, this, "webrtc_audio_module_play_thread"));
+ _ptrThreadPlay->Start();
+ _ptrThreadPlay->SetPriority(rtc::kRealtimePriority);
_initialized = true;
@@ -246,7 +230,7 @@
// RECORDING
if (_ptrThreadRec)
{
- PlatformThread* tmpThread = _ptrThreadRec.release();
+ rtc::PlatformThread* tmpThread = _ptrThreadRec.release();
_timeEventRec.Set();
tmpThread->Stop();
@@ -256,7 +240,7 @@
// PLAYOUT
if (_ptrThreadPlay)
{
- PlatformThread* tmpThread = _ptrThreadPlay.release();
+ rtc::PlatformThread* tmpThread = _ptrThreadPlay.release();
_timeEventPlay.Set();
tmpThread->Stop();
diff --git a/webrtc/modules/audio_device/linux/audio_device_pulse_linux.h b/webrtc/modules/audio_device/linux/audio_device_pulse_linux.h
index 263d42d..de8df0b 100644
--- a/webrtc/modules/audio_device/linux/audio_device_pulse_linux.h
+++ b/webrtc/modules/audio_device/linux/audio_device_pulse_linux.h
@@ -284,8 +284,9 @@
EventWrapper& _recStartEvent;
EventWrapper& _playStartEvent;
- rtc::scoped_ptr<PlatformThread> _ptrThreadPlay;
- rtc::scoped_ptr<PlatformThread> _ptrThreadRec;
+ // TODO(pbos): Remove scoped_ptr and use directly without resetting.
+ rtc::scoped_ptr<rtc::PlatformThread> _ptrThreadPlay;
+ rtc::scoped_ptr<rtc::PlatformThread> _ptrThreadRec;
int32_t _id;
AudioMixerManagerLinuxPulse _mixerManager;
diff --git a/webrtc/modules/audio_device/mac/audio_device_mac.cc b/webrtc/modules/audio_device/mac/audio_device_mac.cc
index 14e6bbd..3449188 100644
--- a/webrtc/modules/audio_device/mac/audio_device_mac.cc
+++ b/webrtc/modules/audio_device/mac/audio_device_mac.cc
@@ -1665,11 +1665,11 @@
}
RTC_DCHECK(!capture_worker_thread_.get());
- capture_worker_thread_ =
- PlatformThread::CreateThread(RunCapture, this, "CaptureWorkerThread");
+ capture_worker_thread_.reset(
+ new rtc::PlatformThread(RunCapture, this, "CaptureWorkerThread"));
RTC_DCHECK(capture_worker_thread_.get());
capture_worker_thread_->Start();
- capture_worker_thread_->SetPriority(kRealtimePriority);
+ capture_worker_thread_->SetPriority(rtc::kRealtimePriority);
OSStatus err = noErr;
if (_twoDevices)
@@ -1820,10 +1820,10 @@
}
RTC_DCHECK(!render_worker_thread_.get());
- render_worker_thread_ =
- PlatformThread::CreateThread(RunRender, this, "RenderWorkerThread");
+ render_worker_thread_.reset(
+ new rtc::PlatformThread(RunRender, this, "RenderWorkerThread"));
render_worker_thread_->Start();
- render_worker_thread_->SetPriority(kRealtimePriority);
+ render_worker_thread_->SetPriority(rtc::kRealtimePriority);
if (_twoDevices || !_recording)
{
diff --git a/webrtc/modules/audio_device/mac/audio_device_mac.h b/webrtc/modules/audio_device/mac/audio_device_mac.h
index d908fc5..bb900e0 100644
--- a/webrtc/modules/audio_device/mac/audio_device_mac.h
+++ b/webrtc/modules/audio_device/mac/audio_device_mac.h
@@ -23,10 +23,13 @@
struct PaUtilRingBuffer;
+namespace rtc {
+class PlatformThread;
+} // namespace rtc
+
namespace webrtc
{
class EventWrapper;
-class PlatformThread;
const uint32_t N_REC_SAMPLES_PER_SEC = 48000;
const uint32_t N_PLAY_SAMPLES_PER_SEC = 48000;
@@ -282,11 +285,13 @@
EventWrapper& _stopEventRec;
EventWrapper& _stopEvent;
+ // TODO(pbos): Replace with direct members, just start/stop, no need to
+ // recreate the thread.
// Only valid/running between calls to StartRecording and StopRecording.
- rtc::scoped_ptr<PlatformThread> capture_worker_thread_;
+ rtc::scoped_ptr<rtc::PlatformThread> capture_worker_thread_;
// Only valid/running between calls to StartPlayout and StopPlayout.
- rtc::scoped_ptr<PlatformThread> render_worker_thread_;
+ rtc::scoped_ptr<rtc::PlatformThread> render_worker_thread_;
int32_t _id;
diff --git a/webrtc/modules/audio_device/win/audio_device_wave_win.cc b/webrtc/modules/audio_device/win/audio_device_wave_win.cc
index dec5401..6f4d7df 100644
--- a/webrtc/modules/audio_device/win/audio_device_wave_win.cc
+++ b/webrtc/modules/audio_device/win/audio_device_wave_win.cc
@@ -228,15 +228,9 @@
}
const char* threadName = "webrtc_audio_module_thread";
- _ptrThread = PlatformThread::CreateThread(ThreadFunc, this, threadName);
- if (!_ptrThread->Start())
- {
- WEBRTC_TRACE(kTraceCritical, kTraceAudioDevice, _id,
- "failed to start the audio thread");
- _ptrThread.reset();
- return -1;
- }
- _ptrThread->SetPriority(kRealtimePriority);
+ _ptrThread.reset(new rtc::PlatformThread(ThreadFunc, this, threadName));
+ _ptrThread->Start();
+ _ptrThread->SetPriority(rtc::kRealtimePriority);
const bool periodic(true);
if (!_timeEvent.StartTimer(periodic, TIMER_PERIOD_MS))
@@ -295,7 +289,7 @@
if (_ptrThread)
{
- PlatformThread* tmpThread = _ptrThread.release();
+ rtc::PlatformThread* tmpThread = _ptrThread.release();
_critSect.Leave();
_timeEvent.Set();
diff --git a/webrtc/modules/audio_device/win/audio_device_wave_win.h b/webrtc/modules/audio_device/win/audio_device_wave_win.h
index 6e29014..a1cfc6a 100644
--- a/webrtc/modules/audio_device/win/audio_device_wave_win.h
+++ b/webrtc/modules/audio_device/win/audio_device_wave_win.h
@@ -222,7 +222,8 @@
HANDLE _hShutdownSetVolumeEvent;
HANDLE _hSetCaptureVolumeEvent;
- rtc::scoped_ptr<PlatformThread> _ptrThread;
+ // TODO(pbos): Remove scoped_ptr usage and use PlatformThread directly
+ rtc::scoped_ptr<rtc::PlatformThread> _ptrThread;
CriticalSectionWrapper& _critSectCb;
diff --git a/webrtc/modules/audio_processing/audio_processing_impl_locking_unittest.cc b/webrtc/modules/audio_processing/audio_processing_impl_locking_unittest.cc
index a440a76..dcbaa28 100644
--- a/webrtc/modules/audio_processing/audio_processing_impl_locking_unittest.cc
+++ b/webrtc/modules/audio_processing/audio_processing_impl_locking_unittest.cc
@@ -444,21 +444,21 @@
// Start the threads used in the test.
void StartThreads() {
- ASSERT_TRUE(render_thread_->Start());
- render_thread_->SetPriority(kRealtimePriority);
- ASSERT_TRUE(capture_thread_->Start());
- capture_thread_->SetPriority(kRealtimePriority);
- ASSERT_TRUE(stats_thread_->Start());
- stats_thread_->SetPriority(kNormalPriority);
+ render_thread_.Start();
+ render_thread_.SetPriority(rtc::kRealtimePriority);
+ capture_thread_.Start();
+ capture_thread_.SetPriority(rtc::kRealtimePriority);
+ stats_thread_.Start();
+ stats_thread_.SetPriority(rtc::kNormalPriority);
}
// Event handler for the test.
const rtc::scoped_ptr<EventWrapper> test_complete_;
// Thread related variables.
- rtc::scoped_ptr<PlatformThread> render_thread_;
- rtc::scoped_ptr<PlatformThread> capture_thread_;
- rtc::scoped_ptr<PlatformThread> stats_thread_;
+ rtc::PlatformThread render_thread_;
+ rtc::PlatformThread capture_thread_;
+ rtc::PlatformThread stats_thread_;
mutable test::Random rand_gen_;
rtc::scoped_ptr<AudioProcessing> apm_;
@@ -472,15 +472,9 @@
AudioProcessingImplLockTest::AudioProcessingImplLockTest()
: test_complete_(EventWrapper::Create()),
- render_thread_(PlatformThread::CreateThread(RenderProcessorThreadFunc,
- this,
- "render")),
- capture_thread_(PlatformThread::CreateThread(CaptureProcessorThreadFunc,
- this,
- "capture")),
- stats_thread_(PlatformThread::CreateThread(StatsProcessorThreadFunc,
- this,
- "stats")),
+ render_thread_(RenderProcessorThreadFunc, this, "render"),
+ capture_thread_(CaptureProcessorThreadFunc, this, "capture"),
+ stats_thread_(StatsProcessorThreadFunc, this, "stats"),
rand_gen_(42U),
apm_(AudioProcessingImpl::Create()),
render_thread_state_(kMaxFrameSize,
@@ -553,9 +547,9 @@
}
void AudioProcessingImplLockTest::TearDown() {
- render_thread_->Stop();
- capture_thread_->Stop();
- stats_thread_->Stop();
+ render_thread_.Stop();
+ capture_thread_.Stop();
+ stats_thread_.Stop();
}
StatsProcessor::StatsProcessor(test::Random* rand_gen,
diff --git a/webrtc/modules/rtp_rtcp/test/BWEStandAlone/MatlabPlot.cc b/webrtc/modules/rtp_rtcp/test/BWEStandAlone/MatlabPlot.cc
index 72f75f3..6847285 100644
--- a/webrtc/modules/rtp_rtcp/test/BWEStandAlone/MatlabPlot.cc
+++ b/webrtc/modules/rtp_rtcp/test/BWEStandAlone/MatlabPlot.cc
@@ -895,7 +895,7 @@
{
_eventPtr = EventWrapper::Create();
- _plotThread = PlatformThread::CreateThread(MatlabEngine::PlotThread, this,
+ _plotThread(MatlabEngine::PlotThread, this,
kLowPriority, "MatlabPlot");
_running = true;
_plotThread->Start();
diff --git a/webrtc/modules/rtp_rtcp/test/BWEStandAlone/MatlabPlot.h b/webrtc/modules/rtp_rtcp/test/BWEStandAlone/MatlabPlot.h
index 549e5cc..7ded42d 100644
--- a/webrtc/modules/rtp_rtcp/test/BWEStandAlone/MatlabPlot.h
+++ b/webrtc/modules/rtp_rtcp/test/BWEStandAlone/MatlabPlot.h
@@ -160,7 +160,7 @@
std::vector<MatlabPlot *> _plots;
webrtc::CriticalSectionWrapper *_critSect;
webrtc::EventWrapper *_eventPtr;
- rtc::scoped_ptr<webrtc::PlatformThread> _plotThread;
+ rtc::scoped_ptr<rtc::PlatformThread> _plotThread;
bool _running;
int _numPlots;
};
diff --git a/webrtc/modules/rtp_rtcp/test/BWEStandAlone/TestLoadGenerator.cc b/webrtc/modules/rtp_rtcp/test/BWEStandAlone/TestLoadGenerator.cc
index 236ceae..a48ad2e 100644
--- a/webrtc/modules/rtp_rtcp/test/BWEStandAlone/TestLoadGenerator.cc
+++ b/webrtc/modules/rtp_rtcp/test/BWEStandAlone/TestLoadGenerator.cc
@@ -76,12 +76,12 @@
_eventPtr = EventWrapper::Create();
- _genThread =
- PlatformThread::CreateThread(SenderThreadFunction, this, threadName);
+ _genThread.reset(
+ new rtc::PlatformThread(SenderThreadFunction, this, threadName));
_running = true;
_genThread->Start();
- _genThread->SetPriority(kRealtimePriority);
+ _genThread->SetPriority(rtc::kRealtimePriority);
return 0;
}
diff --git a/webrtc/modules/rtp_rtcp/test/BWEStandAlone/TestLoadGenerator.h b/webrtc/modules/rtp_rtcp/test/BWEStandAlone/TestLoadGenerator.h
index 23f61b2..de92b96 100644
--- a/webrtc/modules/rtp_rtcp/test/BWEStandAlone/TestLoadGenerator.h
+++ b/webrtc/modules/rtp_rtcp/test/BWEStandAlone/TestLoadGenerator.h
@@ -44,7 +44,8 @@
webrtc::CriticalSectionWrapper* _critSect;
webrtc::EventWrapper *_eventPtr;
- rtc::scoped_ptr<webrtc::PlatformThread> _genThread;
+ // TODO(pbos): Replace without pointer usage.
+ rtc::scoped_ptr<rtc::PlatformThread> _genThread;
int32_t _bitrateKbps;
TestSenderReceiver *_sender;
bool _running;
diff --git a/webrtc/modules/rtp_rtcp/test/BWEStandAlone/TestSenderReceiver.cc b/webrtc/modules/rtp_rtcp/test/BWEStandAlone/TestSenderReceiver.cc
index 99a41ee..34dcfc4 100644
--- a/webrtc/modules/rtp_rtcp/test/BWEStandAlone/TestSenderReceiver.cc
+++ b/webrtc/modules/rtp_rtcp/test/BWEStandAlone/TestSenderReceiver.cc
@@ -39,6 +39,7 @@
:
_critSect(CriticalSectionWrapper::CreateCriticalSection()),
_eventPtr(NULL),
+_procThread(ProcThreadFunction, this, "TestSenderReceiver"),
_running(false),
_payloadType(0),
_loadGenerator(NULL),
@@ -162,9 +163,6 @@
exit(1);
}
- _procThread = PlatformThread::CreateThread(ProcThreadFunction, this,
- "TestSenderReceiver");
-
_running = true;
if (_isReceiver)
@@ -176,8 +174,8 @@
}
}
- _procThread->Start();
- _procThread->SetPriority(kRealtimePriority);
+ _procThread.Start();
+ _procThread.SetPriority(rtc::kRealtimePriority);
return 0;
@@ -190,13 +188,12 @@
_transport->StopReceiving();
- if (_procThread)
+ if (_running)
{
_running = false;
_eventPtr->Set();
- _procThread->Stop();
- _procThread.reset();
+ _procThread.Stop();
delete _eventPtr;
}
diff --git a/webrtc/modules/rtp_rtcp/test/BWEStandAlone/TestSenderReceiver.h b/webrtc/modules/rtp_rtcp/test/BWEStandAlone/TestSenderReceiver.h
index 77b02d0..5a4813f 100644
--- a/webrtc/modules/rtp_rtcp/test/BWEStandAlone/TestSenderReceiver.h
+++ b/webrtc/modules/rtp_rtcp/test/BWEStandAlone/TestSenderReceiver.h
@@ -138,7 +138,7 @@
UdpTransport* _transport;
webrtc::CriticalSectionWrapper* _critSect;
webrtc::EventWrapper *_eventPtr;
- rtc::scoped_ptr<webrtc::PlatformThread> _procThread;
+ rtc::PlatformThread _procThread;
bool _running;
int8_t _payloadType;
TestLoadGenerator* _loadGenerator;
diff --git a/webrtc/modules/utility/source/process_thread_impl.cc b/webrtc/modules/utility/source/process_thread_impl.cc
index 63e77d9..1da4225 100644
--- a/webrtc/modules/utility/source/process_thread_impl.cc
+++ b/webrtc/modules/utility/source/process_thread_impl.cc
@@ -76,9 +76,9 @@
m.module->ProcessThreadAttached(this);
}
- thread_ =
- PlatformThread::CreateThread(&ProcessThreadImpl::Run, this, thread_name_);
- RTC_CHECK(thread_->Start());
+ thread_.reset(
+ new rtc::PlatformThread(&ProcessThreadImpl::Run, this, thread_name_));
+ thread_->Start();
}
void ProcessThreadImpl::Stop() {
@@ -93,7 +93,7 @@
wake_up_->Set();
- RTC_CHECK(thread_->Stop());
+ thread_->Stop();
stop_ = false;
// TODO(tommi): Since DeRegisterModule is currently being called from
diff --git a/webrtc/modules/utility/source/process_thread_impl.h b/webrtc/modules/utility/source/process_thread_impl.h
index 8f58932..1c0a0cd 100644
--- a/webrtc/modules/utility/source/process_thread_impl.h
+++ b/webrtc/modules/utility/source/process_thread_impl.h
@@ -70,7 +70,8 @@
rtc::ThreadChecker thread_checker_;
const rtc::scoped_ptr<EventWrapper> wake_up_;
- rtc::scoped_ptr<PlatformThread> thread_;
+ // TODO(pbos): Remove scoped_ptr and stop recreating the thread.
+ rtc::scoped_ptr<rtc::PlatformThread> thread_;
ModuleList modules_;
// TODO(tommi): Support delayed tasks.
diff --git a/webrtc/modules/video_capture/linux/video_capture_linux.cc b/webrtc/modules/video_capture/linux/video_capture_linux.cc
index b8e3f62..401a69d 100644
--- a/webrtc/modules/video_capture/linux/video_capture_linux.cc
+++ b/webrtc/modules/video_capture/linux/video_capture_linux.cc
@@ -280,10 +280,10 @@
//start capture thread;
if (!_captureThread)
{
- _captureThread = PlatformThread::CreateThread(
- VideoCaptureModuleV4L2::CaptureThread, this, "CaptureThread");
+ _captureThread.reset(new rtc::PlatformThread(
+ VideoCaptureModuleV4L2::CaptureThread, this, "CaptureThread"));
_captureThread->Start();
- _captureThread->SetPriority(kHighPriority);
+ _captureThread->SetPriority(rtc::kHighPriority);
}
// Needed to start UVC camera - from the uvcview application
diff --git a/webrtc/modules/video_capture/linux/video_capture_linux.h b/webrtc/modules/video_capture/linux/video_capture_linux.h
index f791607..8172eb8 100644
--- a/webrtc/modules/video_capture/linux/video_capture_linux.h
+++ b/webrtc/modules/video_capture/linux/video_capture_linux.h
@@ -39,7 +39,8 @@
bool AllocateVideoBuffers();
bool DeAllocateVideoBuffers();
- rtc::scoped_ptr<PlatformThread> _captureThread;
+ // TODO(pbos): Stop using scoped_ptr and resetting the thread.
+ rtc::scoped_ptr<rtc::PlatformThread> _captureThread;
CriticalSectionWrapper* _captureCritSect;
int32_t _deviceId;
diff --git a/webrtc/modules/video_render/android/video_render_android_impl.cc b/webrtc/modules/video_render/android/video_render_android_impl.cc
index 63386e0..9affb23 100644
--- a/webrtc/modules/video_render/android/video_render_android_impl.cc
+++ b/webrtc/modules/video_render/android/video_render_android_impl.cc
@@ -141,18 +141,13 @@
return 0;
}
- _javaRenderThread = PlatformThread::CreateThread(JavaRenderThreadFun, this,
- "AndroidRenderThread");
+ _javaRenderThread.reset(new rtc::PlatformThread(JavaRenderThreadFun, this,
+ "AndroidRenderThread"));
- if (_javaRenderThread->Start())
- WEBRTC_TRACE(kTraceInfo, kTraceVideoRenderer, _id,
- "%s: thread started", __FUNCTION__);
- else {
- WEBRTC_TRACE(kTraceError, kTraceVideoRenderer, _id,
- "%s: Could not start send thread", __FUNCTION__);
- return -1;
- }
- _javaRenderThread->SetPriority(kRealtimePriority);
+ _javaRenderThread->Start();
+ WEBRTC_TRACE(kTraceInfo, kTraceVideoRenderer, _id, "%s: thread started",
+ __FUNCTION__);
+ _javaRenderThread->SetPriority(rtc::kRealtimePriority);
return 0;
}
diff --git a/webrtc/modules/video_render/android/video_render_android_impl.h b/webrtc/modules/video_render/android/video_render_android_impl.h
index c038980..e5b7de4 100644
--- a/webrtc/modules/video_render/android/video_render_android_impl.h
+++ b/webrtc/modules/video_render/android/video_render_android_impl.h
@@ -144,7 +144,8 @@
EventWrapper& _javaRenderEvent;
int64_t _lastJavaRenderEvent;
JNIEnv* _javaRenderJniEnv; // JNIEnv for the java render thread.
- rtc::scoped_ptr<PlatformThread> _javaRenderThread;
+ // TODO(pbos): Remove scoped_ptr and use the member directly.
+ rtc::scoped_ptr<rtc::PlatformThread> _javaRenderThread;
};
} // namespace webrtc
diff --git a/webrtc/modules/video_render/ios/video_render_ios_gles20.h b/webrtc/modules/video_render/ios/video_render_ios_gles20.h
index 51a0137..d703630 100644
--- a/webrtc/modules/video_render/ios/video_render_ios_gles20.h
+++ b/webrtc/modules/video_render/ios/video_render_ios_gles20.h
@@ -64,7 +64,8 @@
private:
rtc::scoped_ptr<CriticalSectionWrapper> gles_crit_sec_;
EventTimerWrapper* screen_update_event_;
- rtc::scoped_ptr<PlatformThread> screen_update_thread_;
+ // TODO(pbos): Remove scoped_ptr and use member directly.
+ rtc::scoped_ptr<rtc::PlatformThread> screen_update_thread_;
VideoRenderIosView* view_;
Rect window_rect_;
diff --git a/webrtc/modules/video_render/ios/video_render_ios_gles20.mm b/webrtc/modules/video_render/ios/video_render_ios_gles20.mm
index 0b4cac1..6ad5db8 100644
--- a/webrtc/modules/video_render/ios/video_render_ios_gles20.mm
+++ b/webrtc/modules/video_render/ios/video_render_ios_gles20.mm
@@ -32,15 +32,15 @@
z_order_to_channel_(),
gles_context_([view context]),
is_rendering_(true) {
- screen_update_thread_ = PlatformThread::CreateThread(
- ScreenUpdateThreadProc, this, "ScreenUpdateGles20");
+ screen_update_thread_.reset(new rtc::PlatformThread(
+ ScreenUpdateThreadProc, this, "ScreenUpdateGles20"));
screen_update_event_ = EventTimerWrapper::Create();
GetWindowRect(window_rect_);
}
VideoRenderIosGles20::~VideoRenderIosGles20() {
// Signal event to exit thread, then delete it
- PlatformThread* thread_wrapper = screen_update_thread_.release();
+ rtc::PlatformThread* thread_wrapper = screen_update_thread_.release();
if (thread_wrapper) {
screen_update_event_->Set();
@@ -83,7 +83,7 @@
}
screen_update_thread_->Start();
- screen_update_thread_->SetPriority(kRealtimePriority);
+ screen_update_thread_->SetPriority(rtc::kRealtimePriority);
// Start the event triggering the render process
unsigned int monitor_freq = 60;
diff --git a/webrtc/modules/video_render/mac/video_render_agl.cc b/webrtc/modules/video_render/mac/video_render_agl.cc
index 32fa607..3243563 100644
--- a/webrtc/modules/video_render/mac/video_render_agl.cc
+++ b/webrtc/modules/video_render/mac/video_render_agl.cc
@@ -395,8 +395,8 @@
{
//WEBRTC_TRACE(kTraceInfo, kTraceVideoRenderer, _id, "%s");
- _screenUpdateThread = PlatformThread::CreateThread(ScreenUpdateThreadProc,
- this, "ScreenUpdate");
+ _screenUpdateThread.reset(
+ new rtc::PlatformThread(ScreenUpdateThreadProc, this, "ScreenUpdate"));
_screenUpdateEvent = EventWrapper::Create();
if(!IsValidWindowPtr(_windowRef))
@@ -512,8 +512,8 @@
//WEBRTC_TRACE(kTraceDebug, "%s:%d Constructor", __FUNCTION__, __LINE__);
// _renderCritSec = CriticalSectionWrapper::CreateCriticalSection();
- _screenUpdateThread = PlatformThread::CreateThread(
- ScreenUpdateThreadProc, this, "ScreenUpdateThread");
+ _screenUpdateThread.reset(new rtc::PlatformThread(
+ ScreenUpdateThreadProc, this, "ScreenUpdateThread"));
_screenUpdateEvent = EventWrapper::Create();
GetWindowRect(_windowRect);
@@ -677,7 +677,7 @@
#endif
// Signal event to exit thread, then delete it
- PlatformThread* tmpPtr = _screenUpdateThread.release();
+ rtc::PlatformThread* tmpPtr = _screenUpdateThread.release();
if (tmpPtr)
{
@@ -739,7 +739,7 @@
return -1;
}
_screenUpdateThread->Start();
- _screenUpdateThread->SetPriority(kRealtimePriority);
+ _screenUpdateThread->SetPriority(rtc::kRealtimePriority);
// Start the event triggering the render process
unsigned int monitorFreq = 60;
@@ -856,7 +856,7 @@
int VideoRenderAGL::StopThread()
{
CriticalSectionScoped cs(&_renderCritSec);
- PlatformThread* tmpPtr = _screenUpdateThread.release();
+ rtc::PlatformThread* tmpPtr = _screenUpdateThread.release();
if (tmpPtr)
{
@@ -1880,7 +1880,7 @@
UnlockAGLCntx();
return -1;
}
- _screenUpdateThread->SetPriority(kRealtimePriority);
+ _screenUpdateThread->SetPriority(rtc::kRealtimePriority);
if(FALSE == _screenUpdateEvent->StartTimer(true, 1000/MONITOR_FREQ))
{
//WEBRTC_TRACE(kTraceError, kTraceVideoRenderer, _id, "%s:%d Failed to start screenUpdateEvent", __FUNCTION__, __LINE__);
@@ -1891,8 +1891,8 @@
return 0;
}
- _screenUpdateThread = PlatformThread::CreateThread(ScreenUpdateThreadProc,
- this, "ScreenUpdate");
+ _screenUpdateThread.reset(
+ new rtc::PlatformThread(ScreenUpdateThreadProc, this, "ScreenUpdate"));
_screenUpdateEvent = EventWrapper::Create();
if (!_screenUpdateThread)
@@ -1903,14 +1903,13 @@
}
_screenUpdateThread->Start();
- _screenUpdateThread->SetPriority(kRealtimePriority);
+ _screenUpdateThread->SetPriority(rtc::kRealtimePriority);
_screenUpdateEvent->StartTimer(true, 1000/MONITOR_FREQ);
//WEBRTC_TRACE(kTraceInfo, kTraceVideoRenderer, _id, "%s:%d Started screenUpdateThread", __FUNCTION__, __LINE__);
UnlockAGLCntx();
return 0;
-
}
int32_t VideoRenderAGL::StopRender()
diff --git a/webrtc/modules/video_render/mac/video_render_agl.h b/webrtc/modules/video_render/mac/video_render_agl.h
index 0508a3f..e1da8fa 100644
--- a/webrtc/modules/video_render/mac/video_render_agl.h
+++ b/webrtc/modules/video_render/mac/video_render_agl.h
@@ -142,7 +142,8 @@
bool _fullScreen;
int _id;
webrtc::CriticalSectionWrapper& _renderCritSec;
- rtc::scoped_ptr<webrtc::PlatformThread> _screenUpdateThread;
+ // TODO(pbos): Remove scoped_ptr and use PlatformThread directly.
+ rtc::scoped_ptr<rtc::PlatformThread> _screenUpdateThread;
webrtc::EventWrapper* _screenUpdateEvent;
bool _isHIViewRef;
AGLContext _aglContext;
diff --git a/webrtc/modules/video_render/mac/video_render_nsopengl.h b/webrtc/modules/video_render/mac/video_render_nsopengl.h
index 5993c08..a888b68 100644
--- a/webrtc/modules/video_render/mac/video_render_nsopengl.h
+++ b/webrtc/modules/video_render/mac/video_render_nsopengl.h
@@ -30,9 +30,12 @@
class Trace;
+namespace rtc {
+class PlatformThread;
+} // namespace rtc
+
namespace webrtc {
class EventTimerWrapper;
-class PlatformThread;
class VideoRenderNSOpenGL;
class CriticalSectionWrapper;
@@ -166,7 +169,8 @@
bool _fullScreen;
int _id;
CriticalSectionWrapper& _nsglContextCritSec;
- rtc::scoped_ptr<PlatformThread> _screenUpdateThread;
+ // TODO(pbos): Remove scoped_ptr and use PlatformThread directly.
+ rtc::scoped_ptr<rtc::PlatformThread> _screenUpdateThread;
EventTimerWrapper* _screenUpdateEvent;
NSOpenGLContext* _nsglContext;
NSOpenGLContext* _nsglFullScreenContext;
diff --git a/webrtc/modules/video_render/mac/video_render_nsopengl.mm b/webrtc/modules/video_render/mac/video_render_nsopengl.mm
index 7457095..b7683a9 100644
--- a/webrtc/modules/video_render/mac/video_render_nsopengl.mm
+++ b/webrtc/modules/video_render/mac/video_render_nsopengl.mm
@@ -378,8 +378,8 @@
_windowRefSuperView(NULL),
_windowRefSuperViewFrame(NSMakeRect(0,0,0,0))
{
- _screenUpdateThread = PlatformThread::CreateThread(
- ScreenUpdateThreadProc, this, "ScreenUpdateNSOpenGL");
+ _screenUpdateThread.reset(new rtc::PlatformThread(
+ ScreenUpdateThreadProc, this, "ScreenUpdateNSOpenGL"));
}
int VideoRenderNSOpenGL::ChangeWindow(CocoaRenderView* newWindowRef)
@@ -427,15 +427,15 @@
WEBRTC_TRACE(kTraceDebug, kTraceVideoRenderer, _id, "Restarting screenUpdateThread");
// we already have the thread. Most likely StopRender() was called and they were paused
- if(FALSE == _screenUpdateThread->Start() ||
- FALSE == _screenUpdateEvent->StartTimer(true, 1000/MONITOR_FREQ))
- {
+ _screenUpdateThread->Start();
+ if (FALSE ==
+ _screenUpdateEvent->StartTimer(true, 1000 / MONITOR_FREQ)) {
WEBRTC_TRACE(kTraceError, kTraceVideoRenderer, _id, "Failed to restart screenUpdateThread or screenUpdateEvent");
UnlockAGLCntx();
return -1;
}
- _screenUpdateThread->SetPriority(kRealtimePriority);
+ _screenUpdateThread->SetPriority(rtc::kRealtimePriority);
UnlockAGLCntx();
return 0;
@@ -471,8 +471,8 @@
return 0;
}
- if(FALSE == _screenUpdateThread->Stop() || FALSE == _screenUpdateEvent->StopTimer())
- {
+ _screenUpdateThread->Stop();
+ if (FALSE == _screenUpdateEvent->StopTimer()) {
_renderingIsPaused = FALSE;
UnlockAGLCntx();
@@ -657,17 +657,15 @@
}
// Signal event to exit thread, then delete it
- PlatformThread* tmpPtr = _screenUpdateThread.release();
+ rtc::PlatformThread* tmpPtr = _screenUpdateThread.release();
if (tmpPtr)
{
_screenUpdateEvent->Set();
_screenUpdateEvent->StopTimer();
- if (tmpPtr->Stop())
- {
- delete tmpPtr;
- }
+ tmpPtr->Stop();
+ delete tmpPtr;
delete _screenUpdateEvent;
_screenUpdateEvent = NULL;
}
@@ -716,7 +714,7 @@
}
_screenUpdateThread->Start();
- _screenUpdateThread->SetPriority(kRealtimePriority);
+ _screenUpdateThread->SetPriority(rtc::kRealtimePriority);
// Start the event triggering the render process
unsigned int monitorFreq = 60;
@@ -864,17 +862,15 @@
int VideoRenderNSOpenGL::StopThread()
{
- PlatformThread* tmpPtr = _screenUpdateThread.release();
+ rtc::PlatformThread* tmpPtr = _screenUpdateThread.release();
WEBRTC_TRACE(kTraceInfo, kTraceVideoRenderer, _id,
"%s Stopping thread ", __FUNCTION__, tmpPtr);
if (tmpPtr)
{
_screenUpdateEvent->Set();
- if (tmpPtr->Stop())
- {
- delete tmpPtr;
- }
+ tmpPtr->Stop();
+ delete tmpPtr;
}
delete _screenUpdateEvent;
diff --git a/webrtc/modules/video_render/windows/video_render_direct3d9.cc b/webrtc/modules/video_render/windows/video_render_direct3d9.cc
index 5458c28..83835ae 100644
--- a/webrtc/modules/video_render/windows/video_render_direct3d9.cc
+++ b/webrtc/modules/video_render/windows/video_render_direct3d9.cc
@@ -294,8 +294,8 @@
_totalMemory(0),
_availableMemory(0)
{
- _screenUpdateThread = PlatformThread::CreateThread(
- ScreenUpdateThreadProc, this, "ScreenUpdateThread");
+ _screenUpdateThread.reset(new rtc::PlatformThread(
+ ScreenUpdateThreadProc, this, "ScreenUpdateThread"));
_screenUpdateEvent = EventTimerWrapper::Create();
SetRect(&_originalHwndRect, 0, 0, 0, 0);
}
@@ -305,7 +305,7 @@
//NOTE: we should not enter CriticalSection in here!
// Signal event to exit thread, then delete it
- PlatformThread* tmpPtr = _screenUpdateThread.release();
+ rtc::PlatformThread* tmpPtr = _screenUpdateThread.release();
if (tmpPtr)
{
_screenUpdateEvent->Set();
@@ -546,7 +546,7 @@
return -1;
}
_screenUpdateThread->Start();
- _screenUpdateThread->SetPriority(kRealtimePriority);
+ _screenUpdateThread->SetPriority(rtc::kRealtimePriority);
// Start the event triggering the render process
unsigned int monitorFreq = 60;
diff --git a/webrtc/modules/video_render/windows/video_render_direct3d9.h b/webrtc/modules/video_render/windows/video_render_direct3d9.h
index c98f08f..5a1f207 100644
--- a/webrtc/modules/video_render/windows/video_render_direct3d9.h
+++ b/webrtc/modules/video_render/windows/video_render_direct3d9.h
@@ -203,7 +203,8 @@
CriticalSectionWrapper& _refD3DCritsect;
Trace* _trace;
- rtc::scoped_ptr<PlatformThread> _screenUpdateThread;
+ // TODO(pbos): Remove scoped_ptr and use PlatformThread directly.
+ rtc::scoped_ptr<rtc::PlatformThread> _screenUpdateThread;
EventTimerWrapper* _screenUpdateEvent;
HWND _hWnd;
diff --git a/webrtc/system_wrappers/include/data_log_impl.h b/webrtc/system_wrappers/include/data_log_impl.h
index 723cca3..3551960 100644
--- a/webrtc/system_wrappers/include/data_log_impl.h
+++ b/webrtc/system_wrappers/include/data_log_impl.h
@@ -146,7 +146,9 @@
int counter_;
TableMap tables_;
EventWrapper* flush_event_;
- rtc::scoped_ptr<PlatformThread> file_writer_thread_;
+ // This is a scoped_ptr so that we don't have to create threads in the no-op
+ // impl.
+ rtc::scoped_ptr<rtc::PlatformThread> file_writer_thread_;
RWLockWrapper* tables_lock_;
};
diff --git a/webrtc/system_wrappers/source/condition_variable_unittest.cc b/webrtc/system_wrappers/source/condition_variable_unittest.cc
index aad55ac..5a8dd0b 100644
--- a/webrtc/system_wrappers/source/condition_variable_unittest.cc
+++ b/webrtc/system_wrappers/source/condition_variable_unittest.cc
@@ -144,12 +144,10 @@
class CondVarTest : public ::testing::Test {
public:
- CondVarTest() {}
+ CondVarTest() : thread_(&WaitingRunFunction, &baton_, "CondVarTest") {}
virtual void SetUp() {
- thread_ = PlatformThread::CreateThread(&WaitingRunFunction, &baton_,
- "CondVarTest");
- ASSERT_TRUE(thread_->Start());
+ thread_.Start();
}
virtual void TearDown() {
@@ -160,14 +158,14 @@
// and Pass).
ASSERT_TRUE(baton_.Pass(kShortWaitMs));
ASSERT_TRUE(baton_.Grab(kShortWaitMs));
- ASSERT_TRUE(thread_->Stop());
+ thread_.Stop();
}
protected:
Baton baton_;
private:
- rtc::scoped_ptr<PlatformThread> thread_;
+ rtc::PlatformThread thread_;
};
// The SetUp and TearDown functions use condition variables.
diff --git a/webrtc/system_wrappers/source/critical_section_unittest.cc b/webrtc/system_wrappers/source/critical_section_unittest.cc
index 347cb55..9abf8b8 100644
--- a/webrtc/system_wrappers/source/critical_section_unittest.cc
+++ b/webrtc/system_wrappers/source/critical_section_unittest.cc
@@ -78,10 +78,10 @@
CriticalSectionWrapper* crit_sect =
CriticalSectionWrapper::CreateCriticalSection();
ProtectedCount count(crit_sect);
- rtc::scoped_ptr<PlatformThread> thread = PlatformThread::CreateThread(
+ rtc::PlatformThread thread(
&LockUnlockThenStopRunFunction, &count, "ThreadWakesOnce");
crit_sect->Enter();
- ASSERT_TRUE(thread->Start());
+ thread.Start();
SwitchProcess();
// The critical section is of reentrant mode, so this should not release
// the lock, even though count.Count() locks and unlocks the critical section
@@ -90,7 +90,7 @@
ASSERT_EQ(0, count.Count());
crit_sect->Leave(); // This frees the thread to act.
EXPECT_TRUE(WaitForCount(1, &count));
- EXPECT_TRUE(thread->Stop());
+ thread.Stop();
delete crit_sect;
}
@@ -105,10 +105,10 @@
CriticalSectionWrapper* crit_sect =
CriticalSectionWrapper::CreateCriticalSection();
ProtectedCount count(crit_sect);
- rtc::scoped_ptr<PlatformThread> thread = PlatformThread::CreateThread(
+ rtc::PlatformThread thread(
&LockUnlockRunFunction, &count, "ThreadWakesTwice");
crit_sect->Enter(); // Make sure counter stays 0 until we wait for it.
- ASSERT_TRUE(thread->Start());
+ thread.Start();
crit_sect->Leave();
// The thread is capable of grabbing the lock multiple times,
@@ -128,7 +128,7 @@
SwitchProcess();
EXPECT_TRUE(WaitForCount(count_before + 1, &count));
- EXPECT_TRUE(thread->Stop());
+ thread.Stop();
delete crit_sect;
}
diff --git a/webrtc/system_wrappers/source/data_log.cc b/webrtc/system_wrappers/source/data_log.cc
index c25971d..7787696 100644
--- a/webrtc/system_wrappers/source/data_log.cc
+++ b/webrtc/system_wrappers/source/data_log.cc
@@ -318,11 +318,12 @@
}
DataLogImpl::DataLogImpl()
- : counter_(1),
- tables_(),
- flush_event_(EventWrapper::Create()),
- tables_lock_(RWLockWrapper::CreateRWLock()) {
-}
+ : counter_(1),
+ tables_(),
+ flush_event_(EventWrapper::Create()),
+ file_writer_thread_(
+ new rtc::PlatformThread(DataLogImpl::Run, instance_, "DataLog")),
+ tables_lock_(RWLockWrapper::CreateRWLock()) {}
DataLogImpl::~DataLogImpl() {
StopThread();
@@ -348,12 +349,8 @@
}
int DataLogImpl::Init() {
- file_writer_thread_ =
- PlatformThread::CreateThread(DataLogImpl::Run, instance_, "DataLog");
- bool success = file_writer_thread_->Start();
- if (!success)
- return -1;
- file_writer_thread_->SetPriority(kHighestPriority);
+ file_writer_thread_->Start();
+ file_writer_thread_->SetPriority(rtc::kHighestPriority);
return 0;
}
@@ -406,13 +403,8 @@
if (tables_.count(table_name) == 0)
return -1;
tables_[table_name]->NextRow();
- if (!file_writer_thread_) {
- // Write every row to file as they get complete.
- tables_[table_name]->Flush();
- } else {
- // Signal a complete row
- flush_event_->Set();
- }
+ // Signal a complete row
+ flush_event_->Set();
return 0;
}
@@ -435,10 +427,8 @@
}
void DataLogImpl::StopThread() {
- if (file_writer_thread_) {
- flush_event_->Set();
- file_writer_thread_->Stop();
- }
+ flush_event_->Set();
+ file_writer_thread_->Stop();
}
} // namespace webrtc
diff --git a/webrtc/system_wrappers/source/event_timer_posix.cc b/webrtc/system_wrappers/source/event_timer_posix.cc
index ff26e76..9f9a324 100644
--- a/webrtc/system_wrappers/source/event_timer_posix.cc
+++ b/webrtc/system_wrappers/source/event_timer_posix.cc
@@ -154,14 +154,14 @@
// Start the timer thread
timer_event_.reset(new EventTimerPosix());
const char* thread_name = "WebRtc_event_timer_thread";
- timer_thread_ = PlatformThread::CreateThread(Run, this, thread_name);
+ timer_thread_.reset(new rtc::PlatformThread(Run, this, thread_name));
periodic_ = periodic;
time_ = time;
- bool started = timer_thread_->Start();
- timer_thread_->SetPriority(kRealtimePriority);
+ timer_thread_->Start();
+ timer_thread_->SetPriority(rtc::kRealtimePriority);
pthread_mutex_unlock(&mutex_);
- return started;
+ return true;
}
bool EventTimerPosix::Run(void* obj) {
@@ -215,9 +215,7 @@
timer_event_->Set();
}
if (timer_thread_) {
- if (!timer_thread_->Stop()) {
- return false;
- }
+ timer_thread_->Stop();
timer_thread_.reset();
}
timer_event_.reset();
diff --git a/webrtc/system_wrappers/source/event_timer_posix.h b/webrtc/system_wrappers/source/event_timer_posix.h
index 6e45b38..bbf51f7 100644
--- a/webrtc/system_wrappers/source/event_timer_posix.h
+++ b/webrtc/system_wrappers/source/event_timer_posix.h
@@ -46,7 +46,8 @@
pthread_mutex_t mutex_;
bool event_set_;
- rtc::scoped_ptr<PlatformThread> timer_thread_;
+ // TODO(pbos): Remove scoped_ptr and use PlatformThread directly.
+ rtc::scoped_ptr<rtc::PlatformThread> timer_thread_;
rtc::scoped_ptr<EventTimerPosix> timer_event_;
timespec created_at_;
diff --git a/webrtc/test/channel_transport/udp_socket2_manager_win.cc b/webrtc/test/channel_transport/udp_socket2_manager_win.cc
index bd466a2..9f40350 100644
--- a/webrtc/test/channel_transport/udp_socket2_manager_win.cc
+++ b/webrtc/test/channel_transport/udp_socket2_manager_win.cc
@@ -520,8 +520,8 @@
UdpSocket2WorkerWindows::UdpSocket2WorkerWindows(HANDLE ioCompletionHandle)
: _ioCompletionHandle(ioCompletionHandle),
- _init(false)
-{
+ _pThread(Run, this, "UdpSocket2ManagerWindows_thread"),
+ _init(false) {
_workerNumber = _numOfWorkers++;
WEBRTC_TRACE(kTraceMemory, kTraceTransport, -1,
"UdpSocket2WorkerWindows created");
@@ -537,10 +537,9 @@
{
WEBRTC_TRACE(kTraceStateInfo, kTraceTransport, -1,
"Start UdpSocket2WorkerWindows");
- if (!_pThread->Start())
- return false;
+ _pThread.Start();
- _pThread->SetPriority(kRealtimePriority);
+ _pThread.SetPriority(rtc::kRealtimePriority);
return true;
}
@@ -548,18 +547,14 @@
{
WEBRTC_TRACE(kTraceStateInfo, kTraceTransport, -1,
"Stop UdpSocket2WorkerWindows");
- return _pThread->Stop();
+ _pThread.Stop();
+ return true;
}
int32_t UdpSocket2WorkerWindows::Init()
{
- if(!_init)
- {
- const char* threadName = "UdpSocket2ManagerWindows_thread";
- _pThread = PlatformThread::CreateThread(Run, this, threadName);
- _init = true;
- }
- return 0;
+ _init = true;
+ return 0;
}
bool UdpSocket2WorkerWindows::Run(void* obj)
diff --git a/webrtc/test/channel_transport/udp_socket2_manager_win.h b/webrtc/test/channel_transport/udp_socket2_manager_win.h
index 9cfc0f0..e762dcc 100644
--- a/webrtc/test/channel_transport/udp_socket2_manager_win.h
+++ b/webrtc/test/channel_transport/udp_socket2_manager_win.h
@@ -105,7 +105,7 @@
bool Process();
private:
HANDLE _ioCompletionHandle;
- rtc::scoped_ptr<PlatformThread> _pThread;
+ rtc::PlatformThread _pThread;
static int32_t _numOfWorkers;
int32_t _workerNumber;
volatile bool _stop;
diff --git a/webrtc/test/channel_transport/udp_socket_manager_posix.cc b/webrtc/test/channel_transport/udp_socket_manager_posix.cc
index 6b597e7..6b1a466 100644
--- a/webrtc/test/channel_transport/udp_socket_manager_posix.cc
+++ b/webrtc/test/channel_transport/udp_socket_manager_posix.cc
@@ -184,12 +184,11 @@
return retVal;
}
-
UdpSocketManagerPosixImpl::UdpSocketManagerPosixImpl()
-{
- _critSectList = CriticalSectionWrapper::CreateCriticalSection();
- _thread = PlatformThread::CreateThread(UdpSocketManagerPosixImpl::Run, this,
- "UdpSocketManagerPosixImplThread");
+ : _thread(UdpSocketManagerPosixImpl::Run,
+ this,
+ "UdpSocketManagerPosixImplThread"),
+ _critSectList(CriticalSectionWrapper::CreateCriticalSection()) {
FD_ZERO(&_readFds);
WEBRTC_TRACE(kTraceMemory, kTraceTransport, -1,
"UdpSocketManagerPosix created");
@@ -220,29 +219,19 @@
bool UdpSocketManagerPosixImpl::Start()
{
- if (!_thread)
- {
- return false;
- }
-
WEBRTC_TRACE(kTraceStateInfo, kTraceTransport, -1,
"Start UdpSocketManagerPosix");
- if (!_thread->Start())
- return false;
- _thread->SetPriority(kRealtimePriority);
+ _thread.Start();
+ _thread.SetPriority(rtc::kRealtimePriority);
return true;
}
bool UdpSocketManagerPosixImpl::Stop()
{
- if (!_thread)
- {
- return true;
- }
-
WEBRTC_TRACE(kTraceStateInfo, kTraceTransport, -1,
"Stop UdpSocketManagerPosix");
- return _thread->Stop();
+ _thread.Stop();
+ return true;
}
bool UdpSocketManagerPosixImpl::Process()
diff --git a/webrtc/test/channel_transport/udp_socket_manager_posix.h b/webrtc/test/channel_transport/udp_socket_manager_posix.h
index 0750a4a..45e55af 100644
--- a/webrtc/test/channel_transport/udp_socket_manager_posix.h
+++ b/webrtc/test/channel_transport/udp_socket_manager_posix.h
@@ -75,7 +75,7 @@
private:
typedef std::list<UdpSocketWrapper*> SocketList;
typedef std::list<SOCKET> FdList;
- rtc::scoped_ptr<PlatformThread> _thread;
+ rtc::PlatformThread _thread;
CriticalSectionWrapper* _critSectList;
fd_set _readFds;
diff --git a/webrtc/test/direct_transport.cc b/webrtc/test/direct_transport.cc
index 837281b..b5c5f81 100644
--- a/webrtc/test/direct_transport.cc
+++ b/webrtc/test/direct_transport.cc
@@ -18,26 +18,17 @@
namespace test {
DirectTransport::DirectTransport(Call* send_call)
- : send_call_(send_call),
- packet_event_(EventWrapper::Create()),
- thread_(
- PlatformThread::CreateThread(NetworkProcess, this, "NetworkProcess")),
- clock_(Clock::GetRealTimeClock()),
- shutting_down_(false),
- fake_network_(FakeNetworkPipe::Config()) {
- EXPECT_TRUE(thread_->Start());
-}
+ : DirectTransport(FakeNetworkPipe::Config(), send_call) {}
DirectTransport::DirectTransport(const FakeNetworkPipe::Config& config,
Call* send_call)
: send_call_(send_call),
packet_event_(EventWrapper::Create()),
- thread_(
- PlatformThread::CreateThread(NetworkProcess, this, "NetworkProcess")),
+ thread_(NetworkProcess, this, "NetworkProcess"),
clock_(Clock::GetRealTimeClock()),
shutting_down_(false),
fake_network_(config) {
- EXPECT_TRUE(thread_->Start());
+ thread_.Start();
}
DirectTransport::~DirectTransport() { StopSending(); }
@@ -53,7 +44,7 @@
}
packet_event_->Set();
- EXPECT_TRUE(thread_->Stop());
+ thread_.Stop();
}
void DirectTransport::SetReceiver(PacketReceiver* receiver) {
diff --git a/webrtc/test/direct_transport.h b/webrtc/test/direct_transport.h
index d3cc084..728fe06 100644
--- a/webrtc/test/direct_transport.h
+++ b/webrtc/test/direct_transport.h
@@ -53,7 +53,7 @@
rtc::CriticalSection lock_;
Call* const send_call_;
rtc::scoped_ptr<EventWrapper> packet_event_;
- rtc::scoped_ptr<PlatformThread> thread_;
+ rtc::PlatformThread thread_;
Clock* const clock_;
bool shutting_down_;
diff --git a/webrtc/test/fake_audio_device.cc b/webrtc/test/fake_audio_device.cc
index 4eee660..31cebda 100644
--- a/webrtc/test/fake_audio_device.cc
+++ b/webrtc/test/fake_audio_device.cc
@@ -30,6 +30,7 @@
last_playout_ms_(-1),
clock_(clock),
tick_(EventTimerWrapper::Create()),
+ thread_(FakeAudioDevice::Run, this, "FakeAudioDevice"),
file_utility_(new ModuleFileUtility(0)),
input_stream_(FileWrapper::Create()) {
memset(captured_audio_, 0, sizeof(captured_audio_));
@@ -42,8 +43,7 @@
FakeAudioDevice::~FakeAudioDevice() {
Stop();
- if (thread_.get() != NULL)
- thread_->Stop();
+ thread_.Stop();
}
int32_t FakeAudioDevice::Init() {
@@ -53,15 +53,8 @@
if (!tick_->StartTimer(true, 10))
return -1;
- thread_ = PlatformThread::CreateThread(FakeAudioDevice::Run, this,
- "FakeAudioDevice");
- if (thread_.get() == NULL)
- return -1;
- if (!thread_->Start()) {
- thread_.reset();
- return -1;
- }
- thread_->SetPriority(webrtc::kHighPriority);
+ thread_.Start();
+ thread_.SetPriority(rtc::kHighPriority);
return 0;
}
diff --git a/webrtc/test/fake_audio_device.h b/webrtc/test/fake_audio_device.h
index 9733da3..7ca657b 100644
--- a/webrtc/test/fake_audio_device.h
+++ b/webrtc/test/fake_audio_device.h
@@ -13,6 +13,7 @@
#include <string>
#include "webrtc/base/criticalsection.h"
+#include "webrtc/base/platform_thread.h"
#include "webrtc/base/scoped_ptr.h"
#include "webrtc/modules/audio_device/include/fake_audio_device.h"
#include "webrtc/typedefs.h"
@@ -23,7 +24,6 @@
class EventTimerWrapper;
class FileWrapper;
class ModuleFileUtility;
-class PlatformThread;
namespace test {
@@ -59,7 +59,7 @@
Clock* clock_;
rtc::scoped_ptr<EventTimerWrapper> tick_;
mutable rtc::CriticalSection lock_;
- rtc::scoped_ptr<PlatformThread> thread_;
+ rtc::PlatformThread thread_;
rtc::scoped_ptr<ModuleFileUtility> file_utility_;
rtc::scoped_ptr<FileWrapper> input_stream_;
};
diff --git a/webrtc/test/frame_generator_capturer.cc b/webrtc/test/frame_generator_capturer.cc
index cc0ad88..35ce616 100644
--- a/webrtc/test/frame_generator_capturer.cc
+++ b/webrtc/test/frame_generator_capturer.cc
@@ -65,6 +65,7 @@
clock_(clock),
sending_(false),
tick_(EventTimerWrapper::Create()),
+ thread_(FrameGeneratorCapturer::Run, this, "FrameGeneratorCapturer"),
frame_generator_(frame_generator),
target_fps_(target_fps),
first_frame_capture_time_(-1) {
@@ -76,8 +77,7 @@
FrameGeneratorCapturer::~FrameGeneratorCapturer() {
Stop();
- if (thread_.get() != NULL)
- thread_->Stop();
+ thread_.Stop();
}
bool FrameGeneratorCapturer::Init() {
@@ -88,15 +88,8 @@
if (!tick_->StartTimer(true, 1000 / target_fps_))
return false;
- thread_ = PlatformThread::CreateThread(FrameGeneratorCapturer::Run, this,
- "FrameGeneratorCapturer");
- if (thread_.get() == NULL)
- return false;
- if (!thread_->Start()) {
- thread_.reset();
- return false;
- }
- thread_->SetPriority(webrtc::kHighPriority);
+ thread_.Start();
+ thread_.SetPriority(rtc::kHighPriority);
return true;
}
diff --git a/webrtc/test/frame_generator_capturer.h b/webrtc/test/frame_generator_capturer.h
index 73c97a6..88b2e00 100644
--- a/webrtc/test/frame_generator_capturer.h
+++ b/webrtc/test/frame_generator_capturer.h
@@ -13,6 +13,7 @@
#include <string>
#include "webrtc/base/criticalsection.h"
+#include "webrtc/base/platform_thread.h"
#include "webrtc/base/scoped_ptr.h"
#include "webrtc/test/video_capturer.h"
#include "webrtc/typedefs.h"
@@ -21,7 +22,6 @@
class CriticalSectionWrapper;
class EventTimerWrapper;
-class PlatformThread;
namespace test {
@@ -64,7 +64,7 @@
rtc::scoped_ptr<EventTimerWrapper> tick_;
rtc::CriticalSection lock_;
- rtc::scoped_ptr<PlatformThread> thread_;
+ rtc::PlatformThread thread_;
rtc::scoped_ptr<FrameGenerator> frame_generator_;
int target_fps_;
diff --git a/webrtc/video/rampup_tests.cc b/webrtc/video/rampup_tests.cc
index fc0d0cb..21b4423 100644
--- a/webrtc/video/rampup_tests.cc
+++ b/webrtc/video/rampup_tests.cc
@@ -60,9 +60,9 @@
extension_type_(extension_type),
ssrcs_(GenerateSsrcs(num_streams, 100)),
rtx_ssrcs_(GenerateSsrcs(num_streams, 200)),
- poller_thread_(PlatformThread::CreateThread(&BitrateStatsPollingThread,
- this,
- "BitrateStatsPollingThread")),
+ poller_thread_(&BitrateStatsPollingThread,
+ this,
+ "BitrateStatsPollingThread"),
sender_call_(nullptr) {
if (rtx_) {
for (size_t i = 0; i < ssrcs_.size(); ++i)
@@ -277,11 +277,11 @@
void RampUpTester::PerformTest() {
test_start_ms_ = clock_->TimeInMilliseconds();
- poller_thread_->Start();
+ poller_thread_.Start();
EXPECT_EQ(kEventSignaled, Wait())
<< "Timed out while waiting for ramp-up to complete.";
TriggerTestDone();
- poller_thread_->Stop();
+ poller_thread_.Stop();
}
RampUpDownUpTester::RampUpDownUpTester(size_t num_streams,
diff --git a/webrtc/video/rampup_tests.h b/webrtc/video/rampup_tests.h
index 3632a81..0e73da5 100644
--- a/webrtc/video/rampup_tests.h
+++ b/webrtc/video/rampup_tests.h
@@ -98,7 +98,7 @@
std::vector<uint32_t> rtx_ssrcs_;
SsrcMap rtx_ssrc_map_;
- rtc::scoped_ptr<PlatformThread> poller_thread_;
+ rtc::PlatformThread poller_thread_;
Call* sender_call_;
};
diff --git a/webrtc/video/video_capture_input.cc b/webrtc/video/video_capture_input.cc
index d15932d..ac05e36 100644
--- a/webrtc/video/video_capture_input.cc
+++ b/webrtc/video/video_capture_input.cc
@@ -42,9 +42,7 @@
local_renderer_(local_renderer),
stats_proxy_(stats_proxy),
incoming_frame_cs_(CriticalSectionWrapper::CreateCriticalSection()),
- encoder_thread_(PlatformThread::CreateThread(EncoderThreadFunction,
- this,
- "EncoderThread")),
+ encoder_thread_(EncoderThreadFunction, this, "EncoderThread"),
capture_event_(EventWrapper::Create()),
stop_(0),
last_captured_timestamp_(0),
@@ -56,8 +54,8 @@
overuse_observer,
stats_proxy)),
encoding_time_observer_(encoding_time_observer) {
- encoder_thread_->Start();
- encoder_thread_->SetPriority(kHighPriority);
+ encoder_thread_.Start();
+ encoder_thread_.SetPriority(rtc::kHighPriority);
module_process_thread_->RegisterModule(overuse_detector_.get());
}
@@ -67,7 +65,7 @@
// Stop the thread.
rtc::AtomicOps::ReleaseStore(&stop_, 1);
capture_event_->Set();
- encoder_thread_->Stop();
+ encoder_thread_.Stop();
}
void VideoCaptureInput::IncomingCapturedFrame(const VideoFrame& video_frame) {
diff --git a/webrtc/video/video_capture_input.h b/webrtc/video/video_capture_input.h
index 2cdcbf8..9a5aae3 100644
--- a/webrtc/video/video_capture_input.h
+++ b/webrtc/video/video_capture_input.h
@@ -78,7 +78,7 @@
rtc::scoped_ptr<CriticalSectionWrapper> incoming_frame_cs_;
VideoFrame incoming_frame_;
- rtc::scoped_ptr<PlatformThread> encoder_thread_;
+ rtc::PlatformThread encoder_thread_;
rtc::scoped_ptr<EventWrapper> capture_event_;
volatile int stop_;
diff --git a/webrtc/video/video_quality_test.cc b/webrtc/video/video_quality_test.cc
index da52297..09c1037 100644
--- a/webrtc/video/video_quality_test.cc
+++ b/webrtc/video/video_quality_test.cc
@@ -69,6 +69,7 @@
rtp_timestamp_delta_(0),
avg_psnr_threshold_(avg_psnr_threshold),
avg_ssim_threshold_(avg_ssim_threshold),
+ stats_polling_thread_(&PollStatsThread, this, "StatsPoller"),
comparison_available_event_(EventWrapper::Create()),
done_(EventWrapper::Create()) {
// Create thread pool for CPU-expensive PSNR/SSIM calculations.
@@ -91,19 +92,17 @@
}
for (uint32_t i = 0; i < num_cores; ++i) {
- rtc::scoped_ptr<PlatformThread> thread = PlatformThread::CreateThread(
- &FrameComparisonThread, this, "Analyzer");
- EXPECT_TRUE(thread->Start());
- comparison_thread_pool_.push_back(thread.release());
+ rtc::PlatformThread* thread =
+ new rtc::PlatformThread(&FrameComparisonThread, this, "Analyzer");
+ thread->Start();
+ comparison_thread_pool_.push_back(thread);
}
- stats_polling_thread_ =
- PlatformThread::CreateThread(&PollStatsThread, this, "StatsPoller");
}
~VideoAnalyzer() {
- for (PlatformThread* thread : comparison_thread_pool_) {
- EXPECT_TRUE(thread->Stop());
+ for (rtc::PlatformThread* thread : comparison_thread_pool_) {
+ thread->Stop();
delete thread;
}
}
@@ -221,7 +220,7 @@
// at time-out check if frames_processed is going up. If so, give it more
// time, otherwise fail. Hopefully this will reduce test flakiness.
- EXPECT_TRUE(stats_polling_thread_->Start());
+ stats_polling_thread_.Start();
int last_frames_processed = -1;
EventTypeWrapper eventType;
@@ -257,7 +256,7 @@
// since it uses the send_stream_ reference that might be reclaimed after
// returning from this method.
done_->Set();
- EXPECT_TRUE(stats_polling_thread_->Stop());
+ stats_polling_thread_.Stop();
}
VideoCaptureInput* input_;
@@ -602,8 +601,8 @@
const double avg_ssim_threshold_;
rtc::CriticalSection comparison_lock_;
- std::vector<PlatformThread*> comparison_thread_pool_;
- rtc::scoped_ptr<PlatformThread> stats_polling_thread_;
+ std::vector<rtc::PlatformThread*> comparison_thread_pool_;
+ rtc::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_;
diff --git a/webrtc/video_engine/vie_channel.cc b/webrtc/video_engine/vie_channel.cc
index 91c862b..b17b6ce 100644
--- a/webrtc/video_engine/vie_channel.cc
+++ b/webrtc/video_engine/vie_channel.cc
@@ -111,6 +111,7 @@
packet_router_(packet_router),
bandwidth_observer_(bandwidth_observer),
transport_feedback_observer_(transport_feedback_observer),
+ decode_thread_(ChannelDecodeThreadFunction, this, "DecodingThread"),
nack_history_size_sender_(kMinSendSidePacketHistorySize),
max_nack_reordering_threshold_(kMaxPacketAgeToNack),
pre_render_callback_(NULL),
@@ -186,9 +187,7 @@
module_process_thread_->DeRegisterModule(rtp_rtcp);
delete rtp_rtcp;
}
- if (decode_thread_) {
- StopDecodeThread();
- }
+ StopDecodeThread();
// Release modules.
VideoCodingModule::Destroy(vcm_);
}
@@ -1148,23 +1147,17 @@
void ViEChannel::StartDecodeThread() {
RTC_DCHECK(!sender_);
- // Start the decode thread
- if (decode_thread_)
+ if (decode_thread_.IsRunning())
return;
- decode_thread_ = PlatformThread::CreateThread(ChannelDecodeThreadFunction,
- this, "DecodingThread");
- decode_thread_->Start();
- decode_thread_->SetPriority(kHighestPriority);
+ // Start the decode thread
+ decode_thread_.Start();
+ decode_thread_.SetPriority(rtc::kHighestPriority);
}
void ViEChannel::StopDecodeThread() {
- if (!decode_thread_)
- return;
-
vcm_->TriggerDecoderShutdown();
- decode_thread_->Stop();
- decode_thread_.reset();
+ decode_thread_.Stop();
}
int32_t ViEChannel::SetVoiceChannel(int32_t ve_channel_id,
diff --git a/webrtc/video_engine/vie_channel.h b/webrtc/video_engine/vie_channel.h
index d5030de..17b56ca 100644
--- a/webrtc/video_engine/vie_channel.h
+++ b/webrtc/video_engine/vie_channel.h
@@ -15,6 +15,7 @@
#include <map>
#include <vector>
+#include "webrtc/base/platform_thread.h"
#include "webrtc/base/scoped_ptr.h"
#include "webrtc/base/scoped_ref_ptr.h"
#include "webrtc/modules/remote_bitrate_estimator/include/remote_bitrate_estimator.h"
@@ -43,7 +44,6 @@
class ReceiveStatisticsProxy;
class ReportBlockStats;
class RtcpRttStats;
-class PlatformThread;
class ViEChannelProtectionCallback;
class ViERTPObserver;
class VideoCodingModule;
@@ -435,7 +435,7 @@
const rtc::scoped_ptr<RtcpBandwidthObserver> bandwidth_observer_;
TransportFeedbackObserver* const transport_feedback_observer_;
- rtc::scoped_ptr<PlatformThread> decode_thread_;
+ rtc::PlatformThread decode_thread_;
int nack_history_size_sender_;
int max_nack_reordering_threshold_;
diff --git a/webrtc/voice_engine/test/android/android_test/jni/android_test.cc b/webrtc/voice_engine/test/android/android_test/jni/android_test.cc
index 55dfa15..766b9e7 100644
--- a/webrtc/voice_engine/test/android/android_test/jni/android_test.cc
+++ b/webrtc/voice_engine/test/android/android_test/jni/android_test.cc
@@ -177,7 +177,7 @@
static bool Run(void* ptr);
bool Process();
private:
- rtc::scoped_ptr<PlatformThread> _thread;
+ rtc::PlatformThread _thread;
};
ThreadTest::~ThreadTest()
@@ -188,7 +188,7 @@
ThreadTest::ThreadTest()
{
- _thread = PlatformThread::CreateThread(Run, this, "ThreadTest thread");
+ _thread(Run, this, "ThreadTest thread");
}
bool ThreadTest::Run(void* ptr)
diff --git a/webrtc/voice_engine/test/auto_test/fakes/conference_transport.cc b/webrtc/voice_engine/test/auto_test/fakes/conference_transport.cc
index e360d41..70f6829 100644
--- a/webrtc/voice_engine/test/auto_test/fakes/conference_transport.cc
+++ b/webrtc/voice_engine/test/auto_test/fakes/conference_transport.cc
@@ -40,9 +40,7 @@
: pq_crit_(webrtc::CriticalSectionWrapper::CreateCriticalSection()),
stream_crit_(webrtc::CriticalSectionWrapper::CreateCriticalSection()),
packet_event_(webrtc::EventWrapper::Create()),
- thread_(webrtc::PlatformThread::CreateThread(Run,
- this,
- "ConferenceTransport")),
+ thread_(Run, this, "ConferenceTransport"),
rtt_ms_(0),
stream_count_(0),
rtp_header_parser_(webrtc::RtpHeaderParser::Create()) {
@@ -79,8 +77,8 @@
EXPECT_EQ(0, remote_network_->RegisterExternalTransport(reflector_, *this));
EXPECT_EQ(0, remote_rtp_rtcp_->SetLocalSSRC(reflector_, kReflectorSsrc));
- thread_->Start();
- thread_->SetPriority(webrtc::kHighPriority);
+ thread_.Start();
+ thread_.SetPriority(rtc::kHighPriority);
}
ConferenceTransport::~ConferenceTransport() {
@@ -93,7 +91,7 @@
RemoveStream(stream->first);
}
- EXPECT_TRUE(thread_->Stop());
+ thread_.Stop();
remote_file_->Release();
remote_rtp_rtcp_->Release();
diff --git a/webrtc/voice_engine/test/auto_test/fakes/conference_transport.h b/webrtc/voice_engine/test/auto_test/fakes/conference_transport.h
index b9b4e76..5d105aa 100644
--- a/webrtc/voice_engine/test/auto_test/fakes/conference_transport.h
+++ b/webrtc/voice_engine/test/auto_test/fakes/conference_transport.h
@@ -131,7 +131,7 @@
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::PlatformThread> thread_;
+ rtc::PlatformThread thread_;
unsigned int rtt_ms_;
unsigned int stream_count_;
diff --git a/webrtc/voice_engine/test/auto_test/fixtures/after_initialization_fixture.h b/webrtc/voice_engine/test/auto_test/fixtures/after_initialization_fixture.h
index 7b4bc63..116ff0a 100644
--- a/webrtc/voice_engine/test/auto_test/fixtures/after_initialization_fixture.h
+++ b/webrtc/voice_engine/test/auto_test/fixtures/after_initialization_fixture.h
@@ -30,16 +30,14 @@
LoopBackTransport(webrtc::VoENetwork* voe_network, int channel)
: crit_(webrtc::CriticalSectionWrapper::CreateCriticalSection()),
packet_event_(webrtc::EventWrapper::Create()),
- thread_(webrtc::PlatformThread::CreateThread(NetworkProcess,
- this,
- "LoopBackTransport")),
+ thread_(NetworkProcess, this, "LoopBackTransport"),
channel_(channel),
voe_network_(voe_network),
transmitted_packets_(0) {
- thread_->Start();
+ thread_.Start();
}
- ~LoopBackTransport() { thread_->Stop(); }
+ ~LoopBackTransport() { thread_.Stop(); }
bool SendRtp(const uint8_t* data,
size_t len,
@@ -147,7 +145,7 @@
const rtc::scoped_ptr<webrtc::CriticalSectionWrapper> crit_;
const rtc::scoped_ptr<webrtc::EventWrapper> packet_event_;
- const rtc::scoped_ptr<webrtc::PlatformThread> thread_;
+ rtc::PlatformThread thread_;
std::deque<Packet> packet_queue_ GUARDED_BY(crit_.get());
const int channel_;
std::map<uint32_t, int> channels_ GUARDED_BY(crit_.get());
diff --git a/webrtc/voice_engine/test/auto_test/voe_standard_test.h b/webrtc/voice_engine/test/auto_test/voe_standard_test.h
index e60107c..b925959 100644
--- a/webrtc/voice_engine/test/auto_test/voe_standard_test.h
+++ b/webrtc/voice_engine/test/auto_test/voe_standard_test.h
@@ -44,7 +44,6 @@
#ifdef WEBRTC_VOICE_ENGINE_NETEQ_STATS_API
namespace webrtc {
class CriticalSectionWrapper;
-class PlatformThread;
class VoENetEqStats;
}
#endif
diff --git a/webrtc/voice_engine/test/auto_test/voe_stress_test.cc b/webrtc/voice_engine/test/auto_test/voe_stress_test.cc
index 91b39eb..259eff0 100644
--- a/webrtc/voice_engine/test/auto_test/voe_stress_test.cc
+++ b/webrtc/voice_engine/test/auto_test/voe_stress_test.cc
@@ -334,9 +334,9 @@
int rnd(0);
// Start extra thread
- _ptrExtraApiThread = PlatformThread::CreateThread(RunExtraApi, this,
- "StressTestExtraApiThread");
- VALIDATE_STRESS(!_ptrExtraApiThread->Start());
+ _ptrExtraApiThread.reset(
+ new rtc::PlatformThread(RunExtraApi, this, "StressTestExtraApiThread"));
+ _ptrExtraApiThread->Start();
// Some possible extensions include:
// Add more API calls to randomize
@@ -365,7 +365,7 @@
ANL();
// Stop extra thread
- VALIDATE_STRESS(!_ptrExtraApiThread->Stop());
+ _ptrExtraApiThread->Stop();
///////////// End test /////////////
diff --git a/webrtc/voice_engine/test/auto_test/voe_stress_test.h b/webrtc/voice_engine/test/auto_test/voe_stress_test.h
index b69e8da..715e8ef 100644
--- a/webrtc/voice_engine/test/auto_test/voe_stress_test.h
+++ b/webrtc/voice_engine/test/auto_test/voe_stress_test.h
@@ -12,10 +12,9 @@
#define WEBRTC_VOICE_ENGINE_VOE_STRESS_TEST_H
#include "webrtc/base/platform_thread.h"
+#include "webrtc/base/scoped_ptr.h"
namespace voetest {
-// TODO(andrew): using directives are not permitted.
-using namespace webrtc;
class VoETestManager;
@@ -38,7 +37,8 @@
VoETestManager& _mgr;
- rtc::scoped_ptr<PlatformThread> _ptrExtraApiThread;
+ // TODO(pbos): Remove scoped_ptr and use PlatformThread directly.
+ rtc::scoped_ptr<rtc::PlatformThread> _ptrExtraApiThread;
};
} // namespace voetest