| 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/pulse/pulse_input.h" | 5 #include "media/audio/pulse/pulse_input.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "media/audio/audio_device_description.h" |
| 10 #include "media/audio/pulse/audio_manager_pulse.h" | 11 #include "media/audio/pulse/audio_manager_pulse.h" |
| 11 #include "media/audio/pulse/pulse_util.h" | 12 #include "media/audio/pulse/pulse_util.h" |
| 12 | 13 |
| 13 namespace media { | 14 namespace media { |
| 14 | 15 |
| 15 using pulse::AutoPulseLock; | 16 using pulse::AutoPulseLock; |
| 16 using pulse::WaitForOperationCompletion; | 17 using pulse::WaitForOperationCompletion; |
| 17 | 18 |
| 18 // Number of blocks of buffers used in the |fifo_|. | 19 // Number of blocks of buffers used in the |fifo_|. |
| 19 const int kNumberOfBlocksBufferInFifo = 2; | 20 const int kNumberOfBlocksBufferInFifo = 2; |
| (...skipping 25 matching lines...) Expand all Loading... |
| 45 PulseAudioInputStream::~PulseAudioInputStream() { | 46 PulseAudioInputStream::~PulseAudioInputStream() { |
| 46 // All internal structures should already have been freed in Close(), | 47 // All internal structures should already have been freed in Close(), |
| 47 // which calls AudioManagerPulse::Release which deletes this object. | 48 // which calls AudioManagerPulse::Release which deletes this object. |
| 48 DCHECK(!handle_); | 49 DCHECK(!handle_); |
| 49 } | 50 } |
| 50 | 51 |
| 51 bool PulseAudioInputStream::Open() { | 52 bool PulseAudioInputStream::Open() { |
| 52 DCHECK(thread_checker_.CalledOnValidThread()); | 53 DCHECK(thread_checker_.CalledOnValidThread()); |
| 53 AutoPulseLock auto_lock(pa_mainloop_); | 54 AutoPulseLock auto_lock(pa_mainloop_); |
| 54 std::string device_name_to_use = device_name_; | 55 std::string device_name_to_use = device_name_; |
| 55 if (device_name_ == AudioManagerBase::kDefaultDeviceId) { | 56 if (device_name_ == AudioDeviceDescription::kDefaultDeviceId) { |
| 56 GetSystemDefaultInputDevice(); | 57 GetSystemDefaultInputDevice(); |
| 57 device_name_to_use = default_system_device_name_; | 58 device_name_to_use = default_system_device_name_; |
| 58 } | 59 } |
| 59 | 60 |
| 60 if (!pulse::CreateInputStream(pa_mainloop_, pa_context_, &handle_, params_, | 61 if (!pulse::CreateInputStream(pa_mainloop_, pa_context_, &handle_, params_, |
| 61 device_name_to_use, &StreamNotifyCallback, | 62 device_name_to_use, &StreamNotifyCallback, |
| 62 this)) { | 63 this)) { |
| 63 return false; | 64 return false; |
| 64 } | 65 } |
| 65 | 66 |
| (...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 353 return false; | 354 return false; |
| 354 | 355 |
| 355 size_t index = pa_stream_get_device_index(handle_); | 356 size_t index = pa_stream_get_device_index(handle_); |
| 356 pa_operation* operation = | 357 pa_operation* operation = |
| 357 pa_context_get_source_info_by_index(pa_context_, index, callback, this); | 358 pa_context_get_source_info_by_index(pa_context_, index, callback, this); |
| 358 WaitForOperationCompletion(pa_mainloop_, operation); | 359 WaitForOperationCompletion(pa_mainloop_, operation); |
| 359 return true; | 360 return true; |
| 360 } | 361 } |
| 361 | 362 |
| 362 } // namespace media | 363 } // namespace media |
| OLD | NEW |