| 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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 56 std::move(worker_task_runner), | 56 std::move(worker_task_runner), |
| 57 audio_log_factory), | 57 audio_log_factory), |
| 58 input_mainloop_(NULL), | 58 input_mainloop_(NULL), |
| 59 input_context_(NULL), | 59 input_context_(NULL), |
| 60 devices_(NULL), | 60 devices_(NULL), |
| 61 native_input_sample_rate_(0), | 61 native_input_sample_rate_(0), |
| 62 native_channel_count_(0) { | 62 native_channel_count_(0) { |
| 63 SetMaxOutputStreamsAllowed(kMaxOutputStreams); | 63 SetMaxOutputStreamsAllowed(kMaxOutputStreams); |
| 64 } | 64 } |
| 65 | 65 |
| 66 AudioManagerPulse::~AudioManagerPulse() { | 66 AudioManagerPulse::~AudioManagerPulse() = default; |
| 67 Shutdown(); | |
| 68 // The Pulse objects are the last things to be destroyed since Shutdown() | |
| 69 // needs them. | |
| 70 DestroyPulse(); | |
| 71 } | |
| 72 | 67 |
| 73 bool AudioManagerPulse::Init() { | 68 bool AudioManagerPulse::Init() { |
| 74 // TODO(alokp): Investigate if InitPulse can happen on the audio thread. | 69 // TODO(alokp): Investigate if InitPulse can happen on the audio thread. |
| 75 // It currently needs to happen on the main thread so that is InitPulse fails, | 70 // It currently needs to happen on the main thread so that is InitPulse fails, |
| 76 // we can fallback to ALSA implementation. Initializing it on audio thread | 71 // we can fallback to ALSA implementation. Initializing it on audio thread |
| 77 // would unblock the main thread and make InitPulse consistent with | 72 // would unblock the main thread and make InitPulse consistent with |
| 78 // DestroyPulse which happens on the audio thread. | 73 // DestroyPulse which happens on the audio thread. |
| 79 return InitPulse(); | 74 return InitPulse(); |
| 80 } | 75 } |
| 81 | 76 |
| 82 // Implementation of AudioManager. | 77 void AudioManagerPulse::Shutdown() { |
| 78 AudioManagerBase::Shutdown(); |
| 79 // The Pulse objects are the last things to be destroyed since Shutdown() |
| 80 // needs them. |
| 81 DestroyPulse(); |
| 82 } |
| 83 |
| 83 bool AudioManagerPulse::HasAudioOutputDevices() { | 84 bool AudioManagerPulse::HasAudioOutputDevices() { |
| 84 AudioDeviceNames devices; | 85 AudioDeviceNames devices; |
| 85 GetAudioOutputDeviceNames(&devices); | 86 GetAudioOutputDeviceNames(&devices); |
| 86 return !devices.empty(); | 87 return !devices.empty(); |
| 87 } | 88 } |
| 88 | 89 |
| 89 bool AudioManagerPulse::HasAudioInputDevices() { | 90 bool AudioManagerPulse::HasAudioInputDevices() { |
| 90 AudioDeviceNames devices; | 91 AudioDeviceNames devices; |
| 91 GetAudioInputDeviceNames(&devices); | 92 GetAudioInputDeviceNames(&devices); |
| 92 return !devices.empty(); | 93 return !devices.empty(); |
| (...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 349 const pa_server_info* info, | 350 const pa_server_info* info, |
| 350 void* user_data) { | 351 void* user_data) { |
| 351 AudioManagerPulse* manager = reinterpret_cast<AudioManagerPulse*>(user_data); | 352 AudioManagerPulse* manager = reinterpret_cast<AudioManagerPulse*>(user_data); |
| 352 | 353 |
| 353 manager->native_input_sample_rate_ = info->sample_spec.rate; | 354 manager->native_input_sample_rate_ = info->sample_spec.rate; |
| 354 manager->native_channel_count_ = info->sample_spec.channels; | 355 manager->native_channel_count_ = info->sample_spec.channels; |
| 355 pa_threaded_mainloop_signal(manager->input_mainloop_, 0); | 356 pa_threaded_mainloop_signal(manager->input_mainloop_, 0); |
| 356 } | 357 } |
| 357 | 358 |
| 358 } // namespace media | 359 } // namespace media |
| OLD | NEW |