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
media / audio / fake_audio_manager.cc [blame]
// Copyright 2013 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/fake_audio_manager.h"
#include <algorithm>
#include <utility>
#include "media/base/audio_parameters.h"
#include "media/base/channel_layout.h"
namespace media {
namespace {
const int kDefaultInputBufferSize = 1024;
const int kDefaultSampleRate = 48000;
} // namespace
FakeAudioManager::FakeAudioManager(std::unique_ptr<AudioThread> audio_thread,
AudioLogFactory* audio_log_factory)
: AudioManagerBase(std::move(audio_thread), audio_log_factory) {}
FakeAudioManager::~FakeAudioManager() = default;
// Implementation of AudioManager.
bool FakeAudioManager::HasAudioOutputDevices() { return false; }
bool FakeAudioManager::HasAudioInputDevices() { return false; }
const char* FakeAudioManager::GetName() {
return "Fake";
}
// Implementation of AudioManagerBase.
AudioOutputStream* FakeAudioManager::MakeLinearOutputStream(
const AudioParameters& params,
const LogCallback& log_callback) {
return FakeAudioOutputStream::MakeFakeStream(this, params);
}
AudioOutputStream* FakeAudioManager::MakeLowLatencyOutputStream(
const AudioParameters& params,
const std::string& device_id,
const LogCallback& log_callback) {
return FakeAudioOutputStream::MakeFakeStream(this, params);
}
AudioInputStream* FakeAudioManager::MakeLinearInputStream(
const AudioParameters& params,
const std::string& device_id,
const LogCallback& log_callback) {
return FakeAudioInputStream::MakeFakeStream(this, params);
}
AudioInputStream* FakeAudioManager::MakeLowLatencyInputStream(
const AudioParameters& params,
const std::string& device_id,
const LogCallback& log_callback) {
return FakeAudioInputStream::MakeFakeStream(this, params);
}
AudioParameters FakeAudioManager::GetPreferredOutputStreamParameters(
const std::string& output_device_id,
const AudioParameters& input_params) {
static const int kDefaultOutputBufferSize = 2048;
ChannelLayoutConfig channel_layout_config = ChannelLayoutConfig::Stereo();
int sample_rate = kDefaultSampleRate;
int buffer_size = kDefaultOutputBufferSize;
if (input_params.IsValid()) {
sample_rate = input_params.sample_rate();
channel_layout_config = input_params.channel_layout_config();
buffer_size = std::min(input_params.frames_per_buffer(), buffer_size);
}
return AudioParameters(AudioParameters::AUDIO_PCM_LOW_LATENCY,
channel_layout_config, sample_rate, buffer_size);
}
AudioParameters FakeAudioManager::GetInputStreamParameters(
const std::string& device_id) {
return AudioParameters(AudioParameters::AUDIO_PCM_LOW_LATENCY,
ChannelLayoutConfig::Stereo(), kDefaultSampleRate,
kDefaultInputBufferSize);
}
} // namespace media