Chromium Code Reviews| 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/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/bind.h" | 8 #include "base/bind.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
| (...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 240 // also called when closing the input controller. | 240 // also called when closing the input controller. |
| 241 audio_manager_->DecreaseActiveInputStreamCount(); | 241 audio_manager_->DecreaseActiveInputStreamCount(); |
| 242 | 242 |
| 243 weak_factory_.InvalidateWeakPtrs(); // Cancel the next scheduled read. | 243 weak_factory_.InvalidateWeakPtrs(); // Cancel the next scheduled read. |
| 244 int error = wrapper_->PcmDrop(device_handle_); | 244 int error = wrapper_->PcmDrop(device_handle_); |
| 245 if (error < 0) | 245 if (error < 0) |
| 246 HandleError("PcmDrop", error); | 246 HandleError("PcmDrop", error); |
| 247 } | 247 } |
| 248 | 248 |
| 249 void AlsaPcmInputStream::Close() { | 249 void AlsaPcmInputStream::Close() { |
| 250 scoped_ptr<AlsaPcmInputStream> self_deleter(this); | 250 if (device_handle_) { |
| 251 weak_factory_.InvalidateWeakPtrs(); // Cancel the next scheduled read. | |
| 252 int error = alsa_util::CloseDevice(wrapper_, device_handle_); | |
| 253 if (error < 0) | |
| 254 HandleError("PcmClose", error); | |
| 251 | 255 |
| 252 // Check in case we were already closed or not initialized yet. | 256 if (mixer_handle_) |
|
tommi (sloooow) - chröme
2012/03/05 14:28:28
where is mixer_handle_ set to NULL?
... I guess it
no longer working on chromium
2012/03/06 15:27:07
Done.
| |
| 253 if (!device_handle_) | 257 alsa_util::CloseMixer(wrapper_, mixer_handle_, device_name_); |
| 254 return; | |
| 255 | 258 |
| 256 weak_factory_.InvalidateWeakPtrs(); // Cancel the next scheduled read. | 259 audio_packet_.reset(); |
| 257 int error = alsa_util::CloseDevice(wrapper_, device_handle_); | 260 device_handle_ = NULL; |
| 258 if (error < 0) | |
| 259 HandleError("PcmClose", error); | |
| 260 | 261 |
| 261 if (mixer_handle_) | 262 if (callback_) |
| 262 alsa_util::CloseMixer(wrapper_, mixer_handle_, device_name_); | 263 callback_->OnClose(this); |
| 264 } | |
| 263 | 265 |
| 264 audio_packet_.reset(); | 266 audio_manager_->ReleaseInputStream(this); |
| 265 device_handle_ = NULL; | |
| 266 | |
| 267 if (callback_) | |
| 268 callback_->OnClose(this); | |
| 269 } | 267 } |
| 270 | 268 |
| 271 double AlsaPcmInputStream::GetMaxVolume() { | 269 double AlsaPcmInputStream::GetMaxVolume() { |
| 272 if (!mixer_handle_ || !mixer_element_handle_) { | 270 if (!mixer_handle_ || !mixer_element_handle_) { |
| 273 DLOG(WARNING) << "GetMaxVolume is not supported for " << device_name_; | 271 DLOG(WARNING) << "GetMaxVolume is not supported for " << device_name_; |
| 274 return 0.0; | 272 return 0.0; |
| 275 } | 273 } |
| 276 | 274 |
| 277 if (!wrapper_->MixerSelemHasCaptureVolume(mixer_element_handle_)) { | 275 if (!wrapper_->MixerSelemHasCaptureVolume(mixer_element_handle_)) { |
| 278 DLOG(WARNING) << "Unsupported microphone volume for " << device_name_; | 276 DLOG(WARNING) << "Unsupported microphone volume for " << device_name_; |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 321 return 0.0; | 319 return 0.0; |
| 322 } | 320 } |
| 323 | 321 |
| 324 return static_cast<double>(current_volume); | 322 return static_cast<double>(current_volume); |
| 325 } | 323 } |
| 326 | 324 |
| 327 void AlsaPcmInputStream::HandleError(const char* method, int error) { | 325 void AlsaPcmInputStream::HandleError(const char* method, int error) { |
| 328 LOG(WARNING) << method << ": " << wrapper_->StrError(error); | 326 LOG(WARNING) << method << ": " << wrapper_->StrError(error); |
| 329 callback_->OnError(this, error); | 327 callback_->OnError(this, error); |
| 330 } | 328 } |
| OLD | NEW |