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

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

Issue 2687853002: Switching VirtualKeyboardPrivate keyboard config call stack to receive HasInputDevices() responce a… (Closed)
Patch Set: Fix for compilation error on linux_chromium_chromeos Created 3 years, 10 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_system_impl.h ('k') | media/audio/audio_system_impl_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2017 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "media/audio/audio_system_impl.h" 5 #include "media/audio/audio_system_impl.h"
6 6
7 #include "base/memory/ptr_util.h" 7 #include "base/memory/ptr_util.h"
8 #include "base/single_thread_task_runner.h" 8 #include "base/single_thread_task_runner.h"
9 #include "base/task_runner_util.h" 9 #include "base/task_runner_util.h"
10 #include "media/audio/audio_manager.h" 10 #include "media/audio/audio_manager.h"
(...skipping 15 matching lines...) Expand all
26 return AudioParameters(); 26 return AudioParameters();
27 27
28 return audio_manager->GetInputStreamParameters(device_id); 28 return audio_manager->GetInputStreamParameters(device_id);
29 } 29 }
30 30
31 } // namespace 31 } // namespace
32 32
33 AudioSystemImpl::AudioSystemImpl(AudioManager* audio_manager) 33 AudioSystemImpl::AudioSystemImpl(AudioManager* audio_manager)
34 : audio_manager_(audio_manager) { 34 : audio_manager_(audio_manager) {
35 DCHECK(audio_manager_); 35 DCHECK(audio_manager_);
36 AudioSystem::SetInstance(this);
36 } 37 }
37 38
38 AudioSystemImpl::~AudioSystemImpl() {} 39 AudioSystemImpl::~AudioSystemImpl() {
40 AudioSystem::ClearInstance(this);
41 }
39 42
40 // static 43 // static
41 std::unique_ptr<AudioSystem> AudioSystemImpl::Create( 44 std::unique_ptr<AudioSystem> AudioSystemImpl::Create(
42 AudioManager* audio_manager) { 45 AudioManager* audio_manager) {
43 return base::WrapUnique(new AudioSystemImpl(audio_manager)); 46 return base::WrapUnique(new AudioSystemImpl(audio_manager));
44 } 47 }
45 48
46 void AudioSystemImpl::GetInputStreamParameters( 49 void AudioSystemImpl::GetInputStreamParameters(
47 const std::string& device_id, 50 const std::string& device_id,
48 OnAudioParamsCallback on_params_cb) const { 51 OnAudioParamsCallback on_params_cb) const {
49 if (GetTaskRunner()->BelongsToCurrentThread()) { 52 if (GetTaskRunner()->BelongsToCurrentThread()) {
50 GetTaskRunner()->PostTask( 53 GetTaskRunner()->PostTask(
51 FROM_HERE, base::Bind(on_params_cb, GetInputParametersOnDeviceThread( 54 FROM_HERE, base::Bind(on_params_cb, GetInputParametersOnDeviceThread(
52 audio_manager_, device_id))); 55 audio_manager_, device_id)));
53 return; 56 return;
54 } 57 }
55 base::PostTaskAndReplyWithResult( 58 base::PostTaskAndReplyWithResult(
56 GetTaskRunner(), FROM_HERE, 59 GetTaskRunner(), FROM_HERE,
57 base::Bind(&GetInputParametersOnDeviceThread, 60 base::Bind(&GetInputParametersOnDeviceThread,
58 base::Unretained(audio_manager_), device_id), 61 base::Unretained(audio_manager_), device_id),
59 std::move(on_params_cb)); 62 std::move(on_params_cb));
60 } 63 }
61 64
65 void AudioSystemImpl::HasInputDevices(OnBoolCallback on_has_devices_cb) const {
66 if (GetTaskRunner()->BelongsToCurrentThread()) {
tommi (sloooow) - chröme 2017/02/09 16:39:34 I guess this is necessary so that the on_has_devic
o1ka 2017/02/09 16:56:10 It's never called on the audio thread unless it is
tommi (sloooow) - chröme 2017/02/10 10:51:07 Thanks - now looking at this again, I see I misre
67 GetTaskRunner()->PostTask(
68 FROM_HERE,
69 base::Bind(on_has_devices_cb, audio_manager_->HasAudioInputDevices()));
70 return;
71 }
72 base::PostTaskAndReplyWithResult(
73 GetTaskRunner(), FROM_HERE,
74 base::Bind(&AudioManager::HasAudioInputDevices,
75 base::Unretained(audio_manager_)),
76 std::move(on_has_devices_cb));
77 }
78
62 AudioManager* AudioSystemImpl::GetAudioManager() const { 79 AudioManager* AudioSystemImpl::GetAudioManager() const {
63 return audio_manager_; 80 return audio_manager_;
64 } 81 }
65 82
66 base::SingleThreadTaskRunner* AudioSystemImpl::GetTaskRunner() const { 83 base::SingleThreadTaskRunner* AudioSystemImpl::GetTaskRunner() const {
67 return audio_manager_->GetTaskRunner(); 84 return audio_manager_->GetTaskRunner();
68 } 85 }
69 86
70 } // namespace media 87 } // namespace media
OLDNEW
« no previous file with comments | « media/audio/audio_system_impl.h ('k') | media/audio/audio_system_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698