| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 "chromeos/audio/cras_audio_handler.h" | 5 #include "chromeos/audio/cras_audio_handler.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <cmath> | 8 #include <cmath> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 320 audio_pref_handler_->SetMuteValue(*device, mute_on); | 320 audio_pref_handler_->SetMuteValue(*device, mute_on); |
| 321 } | 321 } |
| 322 | 322 |
| 323 void CrasAudioHandler::LogErrors() { | 323 void CrasAudioHandler::LogErrors() { |
| 324 log_errors_ = true; | 324 log_errors_ = true; |
| 325 } | 325 } |
| 326 | 326 |
| 327 CrasAudioHandler::CrasAudioHandler( | 327 CrasAudioHandler::CrasAudioHandler( |
| 328 scoped_refptr<AudioDevicesPrefHandler> audio_pref_handler) | 328 scoped_refptr<AudioDevicesPrefHandler> audio_pref_handler) |
| 329 : audio_pref_handler_(audio_pref_handler), | 329 : audio_pref_handler_(audio_pref_handler), |
| 330 weak_ptr_factory_(this), | |
| 331 output_mute_on_(false), | 330 output_mute_on_(false), |
| 332 input_mute_on_(false), | 331 input_mute_on_(false), |
| 333 output_volume_(0), | 332 output_volume_(0), |
| 334 input_gain_(0), | 333 input_gain_(0), |
| 335 active_output_node_id_(0), | 334 active_output_node_id_(0), |
| 336 active_input_node_id_(0), | 335 active_input_node_id_(0), |
| 337 has_alternative_input_(false), | 336 has_alternative_input_(false), |
| 338 has_alternative_output_(false), | 337 has_alternative_output_(false), |
| 339 output_mute_locked_(false), | 338 output_mute_locked_(false), |
| 340 input_mute_locked_(false), | 339 input_mute_locked_(false), |
| 341 log_errors_(false) { | 340 log_errors_(false), |
| 341 weak_ptr_factory_(this) { |
| 342 if (!audio_pref_handler.get()) | 342 if (!audio_pref_handler.get()) |
| 343 return; | 343 return; |
| 344 // If the DBusThreadManager or the CrasAudioClient aren't available, there | 344 // If the DBusThreadManager or the CrasAudioClient aren't available, there |
| 345 // isn't much we can do. This should only happen when running tests. | 345 // isn't much we can do. This should only happen when running tests. |
| 346 if (!chromeos::DBusThreadManager::IsInitialized() || | 346 if (!chromeos::DBusThreadManager::IsInitialized() || |
| 347 !chromeos::DBusThreadManager::Get() || | 347 !chromeos::DBusThreadManager::Get() || |
| 348 !chromeos::DBusThreadManager::Get()->GetCrasAudioClient()) | 348 !chromeos::DBusThreadManager::Get()->GetCrasAudioClient()) |
| 349 return; | 349 return; |
| 350 chromeos::DBusThreadManager::Get()->GetCrasAudioClient()->AddObserver(this); | 350 chromeos::DBusThreadManager::Get()->GetCrasAudioClient()->AddObserver(this); |
| 351 audio_pref_handler_->AddAudioPrefObserver(this); | 351 audio_pref_handler_->AddAudioPrefObserver(this); |
| (...skipping 379 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 731 UpdateDevicesAndSwitchActive(node_list); | 731 UpdateDevicesAndSwitchActive(node_list); |
| 732 FOR_EACH_OBSERVER(AudioObserver, observers_, OnAudioNodesChanged()); | 732 FOR_EACH_OBSERVER(AudioObserver, observers_, OnAudioNodesChanged()); |
| 733 } | 733 } |
| 734 | 734 |
| 735 void CrasAudioHandler::HandleGetNodesError(const std::string& error_name, | 735 void CrasAudioHandler::HandleGetNodesError(const std::string& error_name, |
| 736 const std::string& error_msg) { | 736 const std::string& error_msg) { |
| 737 LOG_IF(ERROR, log_errors_) << "Failed to call GetNodes: " | 737 LOG_IF(ERROR, log_errors_) << "Failed to call GetNodes: " |
| 738 << error_name << ": " << error_msg; | 738 << error_name << ": " << error_msg; |
| 739 } | 739 } |
| 740 } // namespace chromeos | 740 } // namespace chromeos |
| OLD | NEW |