Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(218)

Side by Side Diff: media/audio/audio_thread_impl.cc

Issue 2784433002: Ensures that audio tasks cannot run after AudioManager is deleted. (Closed)
Patch Set: rebase Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « media/audio/audio_thread_impl.h ('k') | media/audio/cras/audio_manager_cras.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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 DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
29 }
30
31 void AudioThreadImpl::Stop() {
32 DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
33
34 // Note that on MACOSX, we can still have tasks posted on the |task_runner_|,
35 // since it is the main thread task runner and we do not stop the main thread.
36 // But this is fine becuase none of those tasks will actually run.
37 thread_.Stop();
38 }
39
40 base::SingleThreadTaskRunner* AudioThreadImpl::GetTaskRunner() {
41 return task_runner_.get();
42 }
43
44 base::SingleThreadTaskRunner* AudioThreadImpl::GetWorkerTaskRunner() {
45 return worker_task_runner_.get();
46 }
47
48 } // namespace media
OLDNEW
« no previous file with comments | « media/audio/audio_thread_impl.h ('k') | media/audio/cras/audio_manager_cras.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698