Switch to using the new app install flow
[chromium-blink-merge.git] / media / audio / fake_audio_manager.cc
bloba181a2f263115195e5debd86398a554e8f8f175c
1 // Copyright 2013 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.
5 #include "media/audio/fake_audio_manager.h"
7 namespace media {
9 namespace {
11 const int kDefaultInputBufferSize = 1024;
12 const int kDefaultSampleRate = 48000;
14 } // namespace
16 FakeAudioManager::FakeAudioManager(AudioLogFactory* audio_log_factory)
17 : AudioManagerBase(audio_log_factory) {}
19 FakeAudioManager::~FakeAudioManager() {
20 Shutdown();
23 // Implementation of AudioManager.
24 bool FakeAudioManager::HasAudioOutputDevices() { return false; }
26 bool FakeAudioManager::HasAudioInputDevices() { return false; }
28 // Implementation of AudioManagerBase.
29 AudioOutputStream* FakeAudioManager::MakeLinearOutputStream(
30 const AudioParameters& params) {
31 return FakeAudioOutputStream::MakeFakeStream(this, params);
34 AudioOutputStream* FakeAudioManager::MakeLowLatencyOutputStream(
35 const AudioParameters& params,
36 const std::string& device_id) {
37 return FakeAudioOutputStream::MakeFakeStream(this, params);
40 AudioInputStream* FakeAudioManager::MakeLinearInputStream(
41 const AudioParameters& params,
42 const std::string& device_id) {
43 return FakeAudioInputStream::MakeFakeStream(this, params);
46 AudioInputStream* FakeAudioManager::MakeLowLatencyInputStream(
47 const AudioParameters& params,
48 const std::string& device_id) {
49 return FakeAudioInputStream::MakeFakeStream(this, params);
52 AudioParameters FakeAudioManager::GetPreferredOutputStreamParameters(
53 const std::string& output_device_id,
54 const AudioParameters& input_params) {
55 static const int kDefaultOutputBufferSize = 2048;
56 static const int kDefaultSampleRate = 48000;
57 ChannelLayout channel_layout = CHANNEL_LAYOUT_STEREO;
58 int sample_rate = kDefaultSampleRate;
59 int buffer_size = kDefaultOutputBufferSize;
60 int bits_per_sample = 16;
61 if (input_params.IsValid()) {
62 sample_rate = input_params.sample_rate();
63 bits_per_sample = input_params.bits_per_sample();
64 channel_layout = input_params.channel_layout();
65 buffer_size = std::min(input_params.frames_per_buffer(), buffer_size);
68 return AudioParameters(
69 AudioParameters::AUDIO_PCM_LOW_LATENCY, channel_layout,
70 sample_rate, bits_per_sample, buffer_size, AudioParameters::NO_EFFECTS);
73 AudioParameters FakeAudioManager::GetInputStreamParameters(
74 const std::string& device_id) {
75 return AudioParameters(
76 AudioParameters::AUDIO_PCM_LOW_LATENCY, CHANNEL_LAYOUT_STEREO,
77 kDefaultSampleRate, 16, kDefaultInputBufferSize);
80 } // namespace media