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_, | |
179 pulse::RequestType::OUTPUT); | |
180 } | |
181 | |
182 std::string AudioManagerPulse::GetAssociatedOutputDeviceID( | |
183 const std::string& input_device_id) { | |
184 DCHECK(AudioManager::Get()->GetTaskRunner()->BelongsToCurrentThread()); | |
185 DCHECK(input_mainloop_); | |
186 DCHECK(input_context_); | |
187 std::string input = | |
188 (input_device_id == AudioDeviceDescription::kDefaultDeviceId) | |
189 ? pulse::GetRealDefaultDeviceId(input_mainloop_, input_context_, | |
190 pulse::RequestType::INPUT) | |
191 : input_device_id; | |
192 | |
193 std::string input_bus = | |
194 pulse::GetBusOfInput(input_mainloop_, input_context_, input); | |
195 return input_bus.empty() ? "" | |
196 : pulse::GetOutputCorrespondingTo( | |
197 input_mainloop_, input_context_, input_bus); | |
198 } | |
199 | |
200 AudioParameters AudioManagerPulse::GetPreferredOutputStreamParameters( | 177 AudioParameters AudioManagerPulse::GetPreferredOutputStreamParameters( |
201 const std::string& output_device_id, | 178 const std::string& output_device_id, |
202 const AudioParameters& input_params) { | 179 const AudioParameters& input_params) { |
203 // TODO(tommi): Support |output_device_id|. | 180 // TODO(tommi): Support |output_device_id|. |
204 VLOG_IF(0, !output_device_id.empty()) << "Not implemented!"; | 181 VLOG_IF(0, !output_device_id.empty()) << "Not implemented!"; |
205 | 182 |
206 ChannelLayout channel_layout = CHANNEL_LAYOUT_STEREO; | 183 ChannelLayout channel_layout = CHANNEL_LAYOUT_STEREO; |
207 int buffer_size = kMinimumOutputBufferSize; | 184 int buffer_size = kMinimumOutputBufferSize; |
208 int bits_per_sample = 16; | 185 int bits_per_sample = 16; |
209 int sample_rate = GetNativeSampleRate(); | 186 int sample_rate = GetNativeSampleRate(); |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
362 void AudioManagerPulse::SampleRateInfoCallback(pa_context* context, | 339 void AudioManagerPulse::SampleRateInfoCallback(pa_context* context, |
363 const pa_server_info* info, | 340 const pa_server_info* info, |
364 void* user_data) { | 341 void* user_data) { |
365 AudioManagerPulse* manager = reinterpret_cast<AudioManagerPulse*>(user_data); | 342 AudioManagerPulse* manager = reinterpret_cast<AudioManagerPulse*>(user_data); |
366 | 343 |
367 manager->native_input_sample_rate_ = info->sample_spec.rate; | 344 manager->native_input_sample_rate_ = info->sample_spec.rate; |
368 pa_threaded_mainloop_signal(manager->input_mainloop_, 0); | 345 pa_threaded_mainloop_signal(manager->input_mainloop_, 0); |
369 } | 346 } |
370 | 347 |
371 } // namespace media | 348 } // namespace media |
OLD | NEW |