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

Side by Side Diff: media/audio/test_audio_thread.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
OLDNEW
(Empty)
1 // Copyright 2017 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/test_audio_thread.h"
6
7 #include "base/run_loop.h"
8 #include "base/threading/thread_task_runner_handle.h"
9
10 namespace media {
11
12 TestAudioThread::TestAudioThread() : TestAudioThread(false) {}
13
14 TestAudioThread::TestAudioThread(bool use_real_thread) {
15 if (use_real_thread) {
16 thread_ = base::MakeUnique<base::Thread>("AudioThread");
17 #if defined(OS_WIN)
18 thread_->init_com_with_mta(true);
19 #endif
20 CHECK(thread_->Start());
21 task_runner_ = thread_->task_runner();
22 } else {
23 task_runner_ = base::ThreadTaskRunnerHandle::Get();
24 }
25 }
26
27 TestAudioThread::~TestAudioThread() {
28 DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
29 }
30
31 void TestAudioThread::Stop() {
32 DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
33 if (thread_)
34 thread_->Stop();
35 else
36 base::RunLoop().RunUntilIdle();
37 }
38
39 base::SingleThreadTaskRunner* TestAudioThread::GetTaskRunner() {
40 return task_runner_.get();
41 }
42
43 base::SingleThreadTaskRunner* TestAudioThread::GetWorkerTaskRunner() {
44 return task_runner_.get();
45 }
46
47 } // namespace media
OLDNEW
« no previous file with comments | « media/audio/test_audio_thread.h ('k') | media/audio/win/audio_low_latency_input_win_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698