Ensure CreateTimeControllerBasedCallFactory use simulated time in Call::SharedModuleThread

Also removes unnecessary Call::SharedModulesThread ctor.

Bug: webrtc:11598
Change-Id: I6d6a7ca4359598fbbfd4ae1aa550be6227ea27e7
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/178394
Reviewed-by: Sebastian Jansson <srte@webrtc.org>
Reviewed-by: Tommi <tommi@webrtc.org>
Commit-Queue: Per Kjellander <perkj@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#31594}
This commit is contained in:
Per Kjellander
2020-06-30 14:39:43 +02:00
committed by Commit Bot
parent ae94067865
commit 4c50e70569
5 changed files with 12 additions and 19 deletions

View File

@ -37,7 +37,8 @@ std::unique_ptr<CallFactoryInterface> CreateTimeControllerBasedCallFactory(
Call* CreateCall(const Call::Config& config) override {
if (!module_thread_) {
module_thread_ = SharedModuleThread::Create(
"CallModules", [this]() { module_thread_ = nullptr; });
time_controller_->CreateProcessThread("CallModules"),
[this]() { module_thread_ = nullptr; });
}
return Call::Create(config, time_controller_->GetClock(), module_thread_,
time_controller_->CreateProcessThread("Pacer"));

View File

@ -412,7 +412,8 @@ std::string Call::Stats::ToString(int64_t time_ms) const {
Call* Call::Create(const Call::Config& config) {
rtc::scoped_refptr<SharedModuleThread> call_thread =
SharedModuleThread::Create("ModuleProcessThread", nullptr);
SharedModuleThread::Create(ProcessThread::Create("ModuleProcessThread"),
nullptr);
return Create(config, std::move(call_thread));
}
@ -501,12 +502,6 @@ SharedModuleThread::SharedModuleThread(
SharedModuleThread::~SharedModuleThread() = default;
// static
rtc::scoped_refptr<SharedModuleThread> SharedModuleThread::Create(
const char* name,
std::function<void()> on_one_ref_remaining) {
return new SharedModuleThread(ProcessThread::Create(name),
std::move(on_one_ref_remaining));
}
rtc::scoped_refptr<SharedModuleThread> SharedModuleThread::Create(
std::unique_ptr<ProcessThread> process_thread,

View File

@ -47,11 +47,6 @@ class SharedModuleThread : public rtc::RefCountInterface {
~SharedModuleThread() override;
public:
// Instantiates a default implementation of ProcessThread.
static rtc::scoped_refptr<SharedModuleThread> Create(
const char* name,
std::function<void()> on_one_ref_remaining);
// Allows injection of an externally created process thread.
static rtc::scoped_refptr<SharedModuleThread> Create(
std::unique_ptr<ProcessThread> process_thread,

View File

@ -88,10 +88,11 @@ Call* CallFactory::CreateCall(const Call::Config& config) {
}
if (!module_thread_) {
module_thread_ = SharedModuleThread::Create("SharedModThread", [this]() {
RTC_DCHECK_RUN_ON(&call_thread_);
module_thread_ = nullptr;
});
module_thread_ = SharedModuleThread::Create(
ProcessThread::Create("SharedModThread"), [this]() {
RTC_DCHECK_RUN_ON(&call_thread_);
module_thread_ = nullptr;
});
}
return Call::Create(config, module_thread_);

View File

@ -418,8 +418,9 @@ TEST(CallTest, SharedModuleThread) {
// the reference count goes back to 1 - meaning |shared| again is the only
// reference, which means we can free the variable and deallocate the thread.
rtc::scoped_refptr<SharedModuleThread> shared;
shared = SharedModuleThread::Create("MySharedProcessThread",
[&shared]() { shared = nullptr; });
shared =
SharedModuleThread::Create(ProcessThread::Create("MySharedProcessThread"),
[&shared]() { shared = nullptr; });
ProcessThread* process_thread = shared->process_thread();
ASSERT_TRUE(shared.get());