Chromium Code Reviews| Index: media/audio/audio_thread_impl.cc |
| diff --git a/media/audio/audio_thread_impl.cc b/media/audio/audio_thread_impl.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..f5ce631b79d32147d760d9f2d85868f2f0667c77 |
| --- /dev/null |
| +++ b/media/audio/audio_thread_impl.cc |
| @@ -0,0 +1,43 @@ |
| +// Copyright 2016 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "media/audio/audio_thread_impl.h" |
| + |
| +#include "base/threading/thread_task_runner_handle.h" |
| + |
| +namespace media { |
| + |
| +AudioThreadImpl::AudioThreadImpl() : thread_("AudioThread") { |
| +#if defined(OS_WIN) |
| + thread_.init_com_with_mta(true); |
| +#endif |
| + CHECK(thread_.Start()); |
| + |
| +#if defined(OS_MACOSX) |
| + // On Mac, the audio task runner must belong to the main thread. |
| + // See http://crbug.com/158170. |
| + task_runner_ = base::ThreadTaskRunnerHandle::Get(); |
| +#else |
| + task_runner_ = thread_.task_runner(); |
| +#endif |
| + worker_task_runner_ = thread_.task_runner(); |
| +} |
| + |
| +AudioThreadImpl::~AudioThreadImpl() {} |
| + |
| +void AudioThreadImpl::Stop() { |
| + thread_.Stop(); |
| + task_runner_ = nullptr; |
|
o1ka
2017/04/28 13:24:20
This does not guarantee that task_runner is delete
o1ka
2017/04/28 13:24:20
Could you add explanations of how Stop() works in
alokp
2017/04/28 17:31:12
Yes I will add more comments and also add a thread
alokp
2017/04/28 17:31:13
Clients keeping a ref-ptr is OK (although they do
o1ka
2017/05/02 16:16:00
Acknowledged.
o1ka
2017/05/02 16:16:01
sgtm
|
| + worker_task_runner_ = nullptr; |
| +} |
| + |
| +base::SingleThreadTaskRunner* AudioThreadImpl::GetTaskRunner() { |
| + return task_runner_.get(); |
| +} |
| + |
| +base::SingleThreadTaskRunner* AudioThreadImpl::GetWorkerTaskRunner() { |
| + return worker_task_runner_.get(); |
| +} |
| + |
| +} // namespace media |