| 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/alsa/alsa_input.h" | 5 #include "media/audio/alsa/alsa_input.h" |
| 6 | 6 |
| 7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
| 8 #include "base/bind.h" | 8 #include "base/bind.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 const char AlsaPcmInputStream::kAutoSelectDevice[] = ""; | 25 const char AlsaPcmInputStream::kAutoSelectDevice[] = ""; |
| 26 | 26 |
| 27 AlsaPcmInputStream::AlsaPcmInputStream(AudioManagerBase* audio_manager, | 27 AlsaPcmInputStream::AlsaPcmInputStream(AudioManagerBase* audio_manager, |
| 28 const std::string& device_name, | 28 const std::string& device_name, |
| 29 const AudioParameters& params, | 29 const AudioParameters& params, |
| 30 AlsaWrapper* wrapper) | 30 AlsaWrapper* wrapper) |
| 31 : audio_manager_(audio_manager), | 31 : audio_manager_(audio_manager), |
| 32 device_name_(device_name), | 32 device_name_(device_name), |
| 33 params_(params), | 33 params_(params), |
| 34 bytes_per_buffer_(params.frames_per_buffer() * | 34 bytes_per_buffer_(params.frames_per_buffer() * |
| 35 (params.channels() * params.bits_per_sample()) / 8), | 35 (params.channels() * params.bits_per_sample()) / |
| 36 8), |
| 36 wrapper_(wrapper), | 37 wrapper_(wrapper), |
| 37 buffer_duration_(base::TimeDelta::FromMicroseconds( | 38 buffer_duration_(base::TimeDelta::FromMicroseconds( |
| 38 params.frames_per_buffer() * base::Time::kMicrosecondsPerSecond / | 39 params.frames_per_buffer() * base::Time::kMicrosecondsPerSecond / |
| 39 static_cast<float>(params.sample_rate()))), | 40 static_cast<float>(params.sample_rate()))), |
| 40 callback_(NULL), | 41 callback_(NULL), |
| 41 device_handle_(NULL), | 42 device_handle_(NULL), |
| 42 mixer_handle_(NULL), | 43 mixer_handle_(NULL), |
| 43 mixer_element_handle_(NULL), | 44 mixer_element_handle_(NULL), |
| 44 weak_factory_(this), | 45 read_callback_behind_schedule_(false), |
| 45 read_callback_behind_schedule_(false) { | 46 weak_factory_(this) {} |
| 46 } | |
| 47 | 47 |
| 48 AlsaPcmInputStream::~AlsaPcmInputStream() {} | 48 AlsaPcmInputStream::~AlsaPcmInputStream() {} |
| 49 | 49 |
| 50 bool AlsaPcmInputStream::Open() { | 50 bool AlsaPcmInputStream::Open() { |
| 51 if (device_handle_) | 51 if (device_handle_) |
| 52 return false; // Already open. | 52 return false; // Already open. |
| 53 | 53 |
| 54 snd_pcm_format_t pcm_format = alsa_util::BitsToFormat( | 54 snd_pcm_format_t pcm_format = alsa_util::BitsToFormat( |
| 55 params_.bits_per_sample()); | 55 params_.bits_per_sample()); |
| 56 if (pcm_format == SND_PCM_FORMAT_UNKNOWN) { | 56 if (pcm_format == SND_PCM_FORMAT_UNKNOWN) { |
| (...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 330 | 330 |
| 331 return static_cast<double>(current_volume); | 331 return static_cast<double>(current_volume); |
| 332 } | 332 } |
| 333 | 333 |
| 334 void AlsaPcmInputStream::HandleError(const char* method, int error) { | 334 void AlsaPcmInputStream::HandleError(const char* method, int error) { |
| 335 LOG(WARNING) << method << ": " << wrapper_->StrError(error); | 335 LOG(WARNING) << method << ": " << wrapper_->StrError(error); |
| 336 callback_->OnError(this); | 336 callback_->OnError(this); |
| 337 } | 337 } |
| 338 | 338 |
| 339 } // namespace media | 339 } // namespace media |
| OLD | NEW |