| 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/pulse/audio_manager_pulse.h" | 5 #include "media/audio/pulse/audio_manager_pulse.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/environment.h" | 8 #include "base/environment.h" |
| 9 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 169 | 169 |
| 170 AudioParameters AudioManagerPulse::GetPreferredOutputStreamParameters( | 170 AudioParameters AudioManagerPulse::GetPreferredOutputStreamParameters( |
| 171 const std::string& output_device_id, | 171 const std::string& output_device_id, |
| 172 const AudioParameters& input_params) { | 172 const AudioParameters& input_params) { |
| 173 // TODO(tommi): Support |output_device_id|. | 173 // TODO(tommi): Support |output_device_id|. |
| 174 VLOG_IF(0, !output_device_id.empty()) << "Not implemented!"; | 174 VLOG_IF(0, !output_device_id.empty()) << "Not implemented!"; |
| 175 | 175 |
| 176 ChannelLayout channel_layout = CHANNEL_LAYOUT_STEREO; | 176 ChannelLayout channel_layout = CHANNEL_LAYOUT_STEREO; |
| 177 int buffer_size = kMinimumOutputBufferSize; | 177 int buffer_size = kMinimumOutputBufferSize; |
| 178 int bits_per_sample = 16; | 178 int bits_per_sample = 16; |
| 179 int input_channels = 0; | |
| 180 int sample_rate = GetNativeSampleRate(); | 179 int sample_rate = GetNativeSampleRate(); |
| 181 if (input_params.IsValid()) { | 180 if (input_params.IsValid()) { |
| 182 bits_per_sample = input_params.bits_per_sample(); | 181 bits_per_sample = input_params.bits_per_sample(); |
| 183 channel_layout = input_params.channel_layout(); | 182 channel_layout = input_params.channel_layout(); |
| 184 input_channels = input_params.input_channels(); | |
| 185 buffer_size = | 183 buffer_size = |
| 186 std::min(kMaximumOutputBufferSize, | 184 std::min(kMaximumOutputBufferSize, |
| 187 std::max(buffer_size, input_params.frames_per_buffer())); | 185 std::max(buffer_size, input_params.frames_per_buffer())); |
| 188 } | 186 } |
| 189 | 187 |
| 190 int user_buffer_size = GetUserBufferSize(); | 188 int user_buffer_size = GetUserBufferSize(); |
| 191 if (user_buffer_size) | 189 if (user_buffer_size) |
| 192 buffer_size = user_buffer_size; | 190 buffer_size = user_buffer_size; |
| 193 | 191 |
| 194 return AudioParameters( | 192 return AudioParameters( |
| 195 AudioParameters::AUDIO_PCM_LOW_LATENCY, channel_layout, input_channels, | 193 AudioParameters::AUDIO_PCM_LOW_LATENCY, channel_layout, |
| 196 sample_rate, bits_per_sample, buffer_size, AudioParameters::NO_EFFECTS); | 194 sample_rate, bits_per_sample, buffer_size, AudioParameters::NO_EFFECTS); |
| 197 } | 195 } |
| 198 | 196 |
| 199 AudioOutputStream* AudioManagerPulse::MakeOutputStream( | 197 AudioOutputStream* AudioManagerPulse::MakeOutputStream( |
| 200 const AudioParameters& params, | 198 const AudioParameters& params, |
| 201 const std::string& device_id) { | 199 const std::string& device_id) { |
| 202 DCHECK(!device_id.empty()); | 200 DCHECK(!device_id.empty()); |
| 203 return new PulseAudioOutputStream(params, device_id, this); | 201 return new PulseAudioOutputStream(params, device_id, this); |
| 204 } | 202 } |
| 205 | 203 |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 335 void AudioManagerPulse::SampleRateInfoCallback(pa_context* context, | 333 void AudioManagerPulse::SampleRateInfoCallback(pa_context* context, |
| 336 const pa_server_info* info, | 334 const pa_server_info* info, |
| 337 void* user_data) { | 335 void* user_data) { |
| 338 AudioManagerPulse* manager = reinterpret_cast<AudioManagerPulse*>(user_data); | 336 AudioManagerPulse* manager = reinterpret_cast<AudioManagerPulse*>(user_data); |
| 339 | 337 |
| 340 manager->native_input_sample_rate_ = info->sample_spec.rate; | 338 manager->native_input_sample_rate_ = info->sample_spec.rate; |
| 341 pa_threaded_mainloop_signal(manager->input_mainloop_, 0); | 339 pa_threaded_mainloop_signal(manager->input_mainloop_, 0); |
| 342 } | 340 } |
| 343 | 341 |
| 344 } // namespace media | 342 } // namespace media |
| OLD | NEW |