| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/openbsd/audio_manager_openbsd.h" | 5 #include "media/audio/openbsd/audio_manager_openbsd.h" |
| 6 | 6 |
| 7 #include <fcntl.h> | 7 #include <fcntl.h> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/file_path.h" | 10 #include "base/file_path.h" |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 48 } | 48 } |
| 49 | 49 |
| 50 bool AudioManagerOpenBSD::HasAudioOutputDevices() { | 50 bool AudioManagerOpenBSD::HasAudioOutputDevices() { |
| 51 return HasAudioHardware(); | 51 return HasAudioHardware(); |
| 52 } | 52 } |
| 53 | 53 |
| 54 bool AudioManagerOpenBSD::HasAudioInputDevices() { | 54 bool AudioManagerOpenBSD::HasAudioInputDevices() { |
| 55 return HasAudioHardware(); | 55 return HasAudioHardware(); |
| 56 } | 56 } |
| 57 | 57 |
| 58 AudioParameters AudioManagerOpenBSD::GetInputStreamParameters( | 58 AudioParameters AudioManagerOpenBSD::GetPreferredInputStreamParameters( |
| 59 const std::string& device_id) { | 59 const std::string& input_device_id, |
| 60 const AudioParameters& input_params) { |
| 60 static const int kDefaultInputBufferSize = 1024; | 61 static const int kDefaultInputBufferSize = 1024; |
| 61 | 62 |
| 63 ChannelLayout channel_layout = CHANNEL_LAYOUT_STEREO; |
| 64 int sample_rate = kDefaultSampleRate; |
| 65 int buffer_size = kDefaultInputBufferSize; |
| 66 int bits_per_sample = 16; |
| 67 if (input_params.IsValid()) { |
| 68 sample_rate = input_params.sample_rate(); |
| 69 bits_per_sample = input_params.bits_per_sample(); |
| 70 channel_layout = input_params.channel_layout(); |
| 71 buffer_size = std::min(buffer_size, input_params.frames_per_buffer()); |
| 72 } |
| 73 |
| 62 int user_buffer_size = GetUserBufferSize(); | 74 int user_buffer_size = GetUserBufferSize(); |
| 63 int buffer_size = user_buffer_size ? | 75 if (user_buffer_size) |
| 64 user_buffer_size : kDefaultInputBufferSize; | 76 buffer_size = user_buffer_size; |
| 65 | 77 |
| 66 return AudioParameters( | 78 return AudioParameters( |
| 67 AudioParameters::AUDIO_PCM_LOW_LATENCY, CHANNEL_LAYOUT_STEREO, | 79 AudioParameters::AUDIO_PCM_LOW_LATENCY, channel_layout, |
| 68 kDefaultSampleRate, 16, buffer_size); | 80 sample_rate, bits_per_sample, buffer_size); |
| 69 } | 81 } |
| 70 | 82 |
| 71 AudioManagerOpenBSD::AudioManagerOpenBSD(AudioLogFactory* audio_log_factory) | 83 AudioManagerOpenBSD::AudioManagerOpenBSD(AudioLogFactory* audio_log_factory) |
| 72 : AudioManagerBase(audio_log_factory), | 84 : AudioManagerBase(audio_log_factory), |
| 73 pulse_library_is_initialized_(false) { | 85 pulse_library_is_initialized_(false) { |
| 74 SetMaxOutputStreamsAllowed(kMaxOutputStreams); | 86 SetMaxOutputStreamsAllowed(kMaxOutputStreams); |
| 75 StubPathMap paths; | 87 StubPathMap paths; |
| 76 | 88 |
| 77 // Check if the pulse library is avialbale. | 89 // Check if the pulse library is avialbale. |
| 78 paths[kModulePulse].push_back(kPulseLib); | 90 paths[kModulePulse].push_back(kPulseLib); |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 153 return NULL; | 165 return NULL; |
| 154 } | 166 } |
| 155 | 167 |
| 156 // TODO(xians): Merge AudioManagerOpenBSD with AudioManagerPulse; | 168 // TODO(xians): Merge AudioManagerOpenBSD with AudioManagerPulse; |
| 157 // static | 169 // static |
| 158 AudioManager* CreateAudioManager(AudioLogFactory* audio_log_factory) { | 170 AudioManager* CreateAudioManager(AudioLogFactory* audio_log_factory) { |
| 159 return new AudioManagerOpenBSD(audio_log_factory); | 171 return new AudioManagerOpenBSD(audio_log_factory); |
| 160 } | 172 } |
| 161 | 173 |
| 162 } // namespace media | 174 } // namespace media |
| OLD | NEW |