OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #include "media/audio/audio_thread_impl.h" | |
6 | |
7 #include "base/threading/thread_task_runner_handle.h" | |
8 | |
9 namespace media { | |
10 | |
11 AudioThreadImpl::AudioThreadImpl() : thread_("AudioThread") { | |
12 #if defined(OS_WIN) | |
13 thread_.init_com_with_mta(true); | |
14 #endif | |
15 CHECK(thread_.Start()); | |
16 | |
17 #if defined(OS_MACOSX) | |
18 // On Mac, the audio task runner must belong to the main thread. | |
19 // See http://crbug.com/158170. | |
20 task_runner_ = base::ThreadTaskRunnerHandle::Get(); | |
21 #else | |
22 task_runner_ = thread_.task_runner(); | |
23 #endif | |
24 worker_task_runner_ = thread_.task_runner(); | |
25 } | |
26 | |
27 AudioThreadImpl::~AudioThreadImpl() {} | |
28 | |
29 void AudioThreadImpl::Stop() { | |
30 thread_.Stop(); | |
31 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
| |
32 worker_task_runner_ = nullptr; | |
33 } | |
34 | |
35 base::SingleThreadTaskRunner* AudioThreadImpl::GetTaskRunner() { | |
36 return task_runner_.get(); | |
37 } | |
38 | |
39 base::SingleThreadTaskRunner* AudioThreadImpl::GetWorkerTaskRunner() { | |
40 return worker_task_runner_.get(); | |
41 } | |
42 | |
43 } // namespace media | |
OLD | NEW |