| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 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/fake_audio_manager.h" | 5 #include "media/audio/fake_audio_manager.h" |
| 6 | 6 |
| 7 namespace media { | 7 namespace media { |
| 8 | 8 |
| 9 namespace { | 9 namespace { |
| 10 | 10 |
| 11 const int kDefaultInputBufferSize = 1024; | 11 AudioParameters GetPreferredStreamParameters( |
| 12 const int kDefaultSampleRate = 48000; | 12 ChannelLayout default_channel_layout, int default_sample_rate, |
| 13 int default_buffer_size, const AudioParameters& input_params) { |
| 14 ChannelLayout channel_layout = default_channel_layout; |
| 15 int sample_rate = default_sample_rate; |
| 16 int buffer_size = default_buffer_size; |
| 17 int bits_per_sample = 16; |
| 18 int input_channels = 0; |
| 19 if (input_params.IsValid()) { |
| 20 sample_rate = input_params.sample_rate(); |
| 21 bits_per_sample = input_params.bits_per_sample(); |
| 22 channel_layout = input_params.channel_layout(); |
| 23 input_channels = input_params.input_channels(); |
| 24 buffer_size = std::min(input_params.frames_per_buffer(), buffer_size); |
| 25 } |
| 26 |
| 27 return AudioParameters( |
| 28 AudioParameters::AUDIO_PCM_LOW_LATENCY, channel_layout, input_channels, |
| 29 sample_rate, bits_per_sample, buffer_size, AudioParameters::NO_EFFECTS); |
| 30 } |
| 13 | 31 |
| 14 } // namespace | 32 } // namespace |
| 15 | 33 |
| 16 FakeAudioManager::FakeAudioManager(AudioLogFactory* audio_log_factory) | 34 FakeAudioManager::FakeAudioManager(AudioLogFactory* audio_log_factory) |
| 17 : AudioManagerBase(audio_log_factory) {} | 35 : AudioManagerBase(audio_log_factory) {} |
| 18 | 36 |
| 19 FakeAudioManager::~FakeAudioManager() { | 37 FakeAudioManager::~FakeAudioManager() { |
| 20 Shutdown(); | 38 Shutdown(); |
| 21 } | 39 } |
| 22 | 40 |
| (...skipping 23 matching lines...) Expand all Loading... |
| 46 AudioInputStream* FakeAudioManager::MakeLowLatencyInputStream( | 64 AudioInputStream* FakeAudioManager::MakeLowLatencyInputStream( |
| 47 const AudioParameters& params, | 65 const AudioParameters& params, |
| 48 const std::string& device_id) { | 66 const std::string& device_id) { |
| 49 return FakeAudioInputStream::MakeFakeStream(this, params); | 67 return FakeAudioInputStream::MakeFakeStream(this, params); |
| 50 } | 68 } |
| 51 | 69 |
| 52 AudioParameters FakeAudioManager::GetPreferredOutputStreamParameters( | 70 AudioParameters FakeAudioManager::GetPreferredOutputStreamParameters( |
| 53 const std::string& output_device_id, | 71 const std::string& output_device_id, |
| 54 const AudioParameters& input_params) { | 72 const AudioParameters& input_params) { |
| 55 static const int kDefaultOutputBufferSize = 2048; | 73 static const int kDefaultOutputBufferSize = 2048; |
| 56 static const int kDefaultSampleRate = 48000; | 74 static const int kDefaultOutputSampleRate = 48000; |
| 57 ChannelLayout channel_layout = CHANNEL_LAYOUT_STEREO; | 75 return GetPreferredStreamParameters(CHANNEL_LAYOUT_STEREO, |
| 58 int sample_rate = kDefaultSampleRate; | 76 kDefaultOutputSampleRate, |
| 59 int buffer_size = kDefaultOutputBufferSize; | 77 kDefaultOutputBufferSize, |
| 60 int bits_per_sample = 16; | 78 input_params); |
| 61 int input_channels = 0; | |
| 62 if (input_params.IsValid()) { | |
| 63 sample_rate = input_params.sample_rate(); | |
| 64 bits_per_sample = input_params.bits_per_sample(); | |
| 65 channel_layout = input_params.channel_layout(); | |
| 66 input_channels = input_params.input_channels(); | |
| 67 buffer_size = std::min(input_params.frames_per_buffer(), buffer_size); | |
| 68 } | |
| 69 | |
| 70 return AudioParameters( | |
| 71 AudioParameters::AUDIO_PCM_LOW_LATENCY, channel_layout, input_channels, | |
| 72 sample_rate, bits_per_sample, buffer_size, AudioParameters::NO_EFFECTS); | |
| 73 } | 79 } |
| 74 | 80 |
| 75 AudioParameters FakeAudioManager::GetInputStreamParameters( | 81 AudioParameters FakeAudioManager::GetPreferredInputStreamParameters( |
| 76 const std::string& device_id) { | 82 const std::string& input_device_id, |
| 77 return AudioParameters( | 83 const AudioParameters& input_params) { |
| 78 AudioParameters::AUDIO_PCM_LOW_LATENCY, CHANNEL_LAYOUT_STEREO, | 84 static const int kDefaultInputBufferSize = 1024; |
| 79 kDefaultSampleRate, 16, kDefaultInputBufferSize); | 85 static const int kDefaultInputSampleRate = 48000; |
| 86 return GetPreferredStreamParameters(CHANNEL_LAYOUT_STEREO, |
| 87 kDefaultInputSampleRate, |
| 88 kDefaultInputBufferSize, |
| 89 input_params); |
| 80 } | 90 } |
| 81 | 91 |
| 82 } // namespace media | 92 } // namespace media |
| OLD | NEW |