1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
media / audio / mock_audio_manager.cc [blame]
// Copyright 2012 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "media/audio/mock_audio_manager.h"
#include <utility>
#include "base/check.h"
#include "base/functional/bind.h"
#include "base/functional/callback.h"
#include "media/audio/mock_audio_debug_recording_manager.h"
#include "media/base/audio_parameters.h"
namespace media {
MockAudioManager::MockAudioManager(std::unique_ptr<AudioThread> audio_thread)
: AudioManager(std::move(audio_thread)) {}
MockAudioManager::~MockAudioManager() = default;
void MockAudioManager::ShutdownOnAudioThread() {
DCHECK(GetTaskRunner()->BelongsToCurrentThread());
}
bool MockAudioManager::HasAudioOutputDevices() {
DCHECK(GetTaskRunner()->BelongsToCurrentThread());
return has_output_devices_;
}
bool MockAudioManager::HasAudioInputDevices() {
DCHECK(GetTaskRunner()->BelongsToCurrentThread());
return has_input_devices_;
}
void MockAudioManager::GetAudioInputDeviceDescriptions(
AudioDeviceDescriptions* device_descriptions) {
DCHECK(GetTaskRunner()->BelongsToCurrentThread());
if (!get_input_device_descriptions_cb_)
return;
get_input_device_descriptions_cb_.Run(device_descriptions);
}
void MockAudioManager::GetAudioOutputDeviceDescriptions(
AudioDeviceDescriptions* device_descriptions) {
DCHECK(GetTaskRunner()->BelongsToCurrentThread());
if (!get_output_device_descriptions_cb_)
return;
get_output_device_descriptions_cb_.Run(device_descriptions);
}
media::AudioOutputStream* MockAudioManager::MakeAudioOutputStream(
const media::AudioParameters& params,
const std::string& device_id,
const LogCallback& log_callback) {
return MakeAudioOutputStreamProxy(params, device_id);
}
media::AudioOutputStream* MockAudioManager::MakeAudioOutputStreamProxy(
const media::AudioParameters& params,
const std::string& device_id) {
return make_output_stream_cb_ ? make_output_stream_cb_.Run(params, device_id)
: nullptr;
}
media::AudioInputStream* MockAudioManager::MakeAudioInputStream(
const media::AudioParameters& params,
const std::string& device_id,
const LogCallback& log_callback) {
return make_input_stream_cb_ ? make_input_stream_cb_.Run(params, device_id)
: nullptr;
}
void MockAudioManager::AddOutputDeviceChangeListener(
AudioDeviceListener* listener) {
}
void MockAudioManager::RemoveOutputDeviceChangeListener(
AudioDeviceListener* listener) {
}
AudioParameters MockAudioManager::GetOutputStreamParameters(
const std::string& device_id) {
DCHECK(GetTaskRunner()->BelongsToCurrentThread());
return output_params_;
}
AudioParameters MockAudioManager::GetInputStreamParameters(
const std::string& device_id) {
DCHECK(GetTaskRunner()->BelongsToCurrentThread());
return input_params_;
}
std::string MockAudioManager::GetAssociatedOutputDeviceID(
const std::string& input_device_id) {
DCHECK(GetTaskRunner()->BelongsToCurrentThread());
return get_associated_output_device_id_cb_
? get_associated_output_device_id_cb_.Run(input_device_id)
: std::string();
}
std::string MockAudioManager::GetDefaultInputDeviceID() {
return std::string();
}
std::string MockAudioManager::GetDefaultOutputDeviceID() {
return std::string();
}
std::string MockAudioManager::GetCommunicationsInputDeviceID() {
return std::string();
}
std::string MockAudioManager::GetCommunicationsOutputDeviceID() {
return std::string();
}
std::unique_ptr<AudioLog> MockAudioManager::CreateAudioLog(
AudioLogFactory::AudioComponent component,
int component_id) {
return nullptr;
}
void MockAudioManager::InitializeDebugRecording() {
if (!GetTaskRunner()->BelongsToCurrentThread()) {
GetTaskRunner()->PostTask(
FROM_HERE, base::BindOnce(&MockAudioManager::InitializeDebugRecording,
base::Unretained(this)));
return;
}
DCHECK(!debug_recording_manager_);
debug_recording_manager_ = std::make_unique<MockAudioDebugRecordingManager>();
}
AudioDebugRecordingManager* MockAudioManager::GetAudioDebugRecordingManager() {
DCHECK(GetTaskRunner()->BelongsToCurrentThread());
return debug_recording_manager_.get();
}
void MockAudioManager::SetAecDumpRecordingManager(
base::WeakPtr<AecdumpRecordingManager>) {
DCHECK(GetTaskRunner()->BelongsToCurrentThread());
// This is no-op by default.
}
const char* MockAudioManager::GetName() {
return nullptr;
}
void MockAudioManager::SetMakeOutputStreamCB(MakeOutputStreamCallback cb) {
make_output_stream_cb_ = std::move(cb);
}
void MockAudioManager::SetMakeInputStreamCB(MakeInputStreamCallback cb) {
make_input_stream_cb_ = std::move(cb);
}
void MockAudioManager::SetInputStreamParameters(const AudioParameters& params) {
input_params_ = params;
}
void MockAudioManager::SetOutputStreamParameters(
const AudioParameters& params) {
output_params_ = params;
}
void MockAudioManager::SetDefaultOutputStreamParameters(
const AudioParameters& params) {
default_output_params_ = params;
}
void MockAudioManager::SetHasInputDevices(bool has_input_devices) {
has_input_devices_ = has_input_devices;
}
void MockAudioManager::SetHasOutputDevices(bool has_output_devices) {
has_output_devices_ = has_output_devices;
}
void MockAudioManager::SetInputDeviceDescriptionsCallback(
GetDeviceDescriptionsCallback callback) {
get_input_device_descriptions_cb_ = std::move(callback);
}
void MockAudioManager::SetOutputDeviceDescriptionsCallback(
GetDeviceDescriptionsCallback callback) {
get_output_device_descriptions_cb_ = std::move(callback);
}
void MockAudioManager::SetAssociatedOutputDeviceIDCallback(
GetAssociatedOutputDeviceIDCallback callback) {
get_associated_output_device_id_cb_ = std::move(callback);
}
} // namespace media.