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 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
167 } | 167 } |
168 | 168 |
169 AudioInputStream* AudioManagerPulse::MakeLowLatencyInputStream( | 169 AudioInputStream* AudioManagerPulse::MakeLowLatencyInputStream( |
170 const AudioParameters& params, | 170 const AudioParameters& params, |
171 const std::string& device_id, | 171 const std::string& device_id, |
172 const LogCallback& log_callback) { | 172 const LogCallback& log_callback) { |
173 DCHECK_EQ(AudioParameters::AUDIO_PCM_LOW_LATENCY, params.format()); | 173 DCHECK_EQ(AudioParameters::AUDIO_PCM_LOW_LATENCY, params.format()); |
174 return MakeInputStream(params, device_id); | 174 return MakeInputStream(params, device_id); |
175 } | 175 } |
176 | 176 |
177 std::string AudioManagerPulse::GetDefaultOutputDeviceID() { | |
178 return pulse::GetRealDefaultDeviceId(input_mainloop_, input_context_, false); | |
179 } | |
180 | |
181 std::string AudioManagerPulse::GetAssociatedOutputDeviceID( | |
182 const std::string& input_device_id) { | |
183 DCHECK(AudioManager::Get()->GetTaskRunner()->BelongsToCurrentThread()); | |
184 DCHECK(input_mainloop_); | |
185 DCHECK(input_context_); | |
186 std::string input; | |
Guido Urdaneta
2016/08/29 10:31:12
use const ref to avoid copying in the case where i
Max Morin
2016/08/29 11:54:02
Done.
| |
187 if (input_device_id == AudioDeviceDescription::kDefaultDeviceId) | |
188 input = | |
189 pulse::GetRealDefaultDeviceId(input_mainloop_, input_context_, true); | |
190 else | |
191 input = input_device_id; | |
192 | |
193 std::string input_bus = | |
194 pulse::GetBusOfInput(input_mainloop_, input_context_, input); | |
195 if (input_bus.empty()) { | |
196 return ""; | |
197 } | |
198 std::string s = pulse::GetOutputCorrespondingTo(input_mainloop_, | |
199 input_context_, input_bus); | |
200 return s; | |
201 } | |
202 | |
177 AudioParameters AudioManagerPulse::GetPreferredOutputStreamParameters( | 203 AudioParameters AudioManagerPulse::GetPreferredOutputStreamParameters( |
178 const std::string& output_device_id, | 204 const std::string& output_device_id, |
179 const AudioParameters& input_params) { | 205 const AudioParameters& input_params) { |
180 // TODO(tommi): Support |output_device_id|. | 206 // TODO(tommi): Support |output_device_id|. |
181 VLOG_IF(0, !output_device_id.empty()) << "Not implemented!"; | 207 VLOG_IF(0, !output_device_id.empty()) << "Not implemented!"; |
182 | 208 |
183 ChannelLayout channel_layout = CHANNEL_LAYOUT_STEREO; | 209 ChannelLayout channel_layout = CHANNEL_LAYOUT_STEREO; |
184 int buffer_size = kMinimumOutputBufferSize; | 210 int buffer_size = kMinimumOutputBufferSize; |
185 int bits_per_sample = 16; | 211 int bits_per_sample = 16; |
186 int sample_rate = GetNativeSampleRate(); | 212 int sample_rate = GetNativeSampleRate(); |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
339 void AudioManagerPulse::SampleRateInfoCallback(pa_context* context, | 365 void AudioManagerPulse::SampleRateInfoCallback(pa_context* context, |
340 const pa_server_info* info, | 366 const pa_server_info* info, |
341 void* user_data) { | 367 void* user_data) { |
342 AudioManagerPulse* manager = reinterpret_cast<AudioManagerPulse*>(user_data); | 368 AudioManagerPulse* manager = reinterpret_cast<AudioManagerPulse*>(user_data); |
343 | 369 |
344 manager->native_input_sample_rate_ = info->sample_spec.rate; | 370 manager->native_input_sample_rate_ = info->sample_spec.rate; |
345 pa_threaded_mainloop_signal(manager->input_mainloop_, 0); | 371 pa_threaded_mainloop_signal(manager->input_mainloop_, 0); |
346 } | 372 } |
347 | 373 |
348 } // namespace media | 374 } // namespace media |
OLD | NEW |