| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/linux/alsa_input.h" | 5 #include "media/audio/linux/alsa_input.h" |
| 6 | 6 |
| 7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
| 10 #include "base/time.h" | 10 #include "base/time.h" |
| 11 #include "media/audio/linux/alsa_util.h" | 11 #include "media/audio/linux/alsa_util.h" |
| 12 #include "media/audio/linux/alsa_wrapper.h" | 12 #include "media/audio/linux/alsa_wrapper.h" |
| 13 | 13 |
| 14 namespace { | 14 static const int kNumPacketsInRingBuffer = 3; |
| 15 | |
| 16 const int kNumPacketsInRingBuffer = 3; | |
| 17 | 15 |
| 18 // If a read failed with no audio data, try again after this duration. | 16 // If a read failed with no audio data, try again after this duration. |
| 19 const int kNoAudioReadAgainTimeoutMs = 20; | 17 static const int kNoAudioReadAgainTimeoutMs = 20; |
| 20 | 18 |
| 21 const char kDefaultDevice1[] = "default"; | 19 static const char kDefaultDevice1[] = "default"; |
| 22 const char kDefaultDevice2[] = "plug:default"; | 20 static const char kDefaultDevice2[] = "plug:default"; |
| 23 | |
| 24 } // namespace | |
| 25 | 21 |
| 26 const char* AlsaPcmInputStream::kAutoSelectDevice = ""; | 22 const char* AlsaPcmInputStream::kAutoSelectDevice = ""; |
| 27 | 23 |
| 28 AlsaPcmInputStream::AlsaPcmInputStream(const std::string& device_name, | 24 AlsaPcmInputStream::AlsaPcmInputStream(const std::string& device_name, |
| 29 const AudioParameters& params, | 25 const AudioParameters& params, |
| 30 AlsaWrapper* wrapper) | 26 AlsaWrapper* wrapper) |
| 31 : device_name_(device_name), | 27 : device_name_(device_name), |
| 32 params_(params), | 28 params_(params), |
| 33 bytes_per_packet_(params.samples_per_packet * | 29 bytes_per_packet_(params.samples_per_packet * |
| 34 (params.channels * params.bits_per_sample) / 8), | 30 (params.channels * params.bits_per_sample) / 8), |
| (...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 205 | 201 |
| 206 audio_packet_.reset(); | 202 audio_packet_.reset(); |
| 207 device_handle_ = NULL; | 203 device_handle_ = NULL; |
| 208 callback_->OnClose(this); | 204 callback_->OnClose(this); |
| 209 } | 205 } |
| 210 | 206 |
| 211 void AlsaPcmInputStream::HandleError(const char* method, int error) { | 207 void AlsaPcmInputStream::HandleError(const char* method, int error) { |
| 212 LOG(WARNING) << method << ": " << wrapper_->StrError(error); | 208 LOG(WARNING) << method << ": " << wrapper_->StrError(error); |
| 213 callback_->OnError(this, error); | 209 callback_->OnError(this, error); |
| 214 } | 210 } |
| OLD | NEW |