Chromium Code Reviews| 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 #ifndef CHROMEOS_AUDIO_CRAS_AUDIO_HANDLER_H_ | 5 #ifndef CHROMEOS_AUDIO_CRAS_AUDIO_HANDLER_H_ |
| 6 #define CHROMEOS_AUDIO_CRAS_AUDIO_HANDLER_H_ | 6 #define CHROMEOS_AUDIO_CRAS_AUDIO_HANDLER_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 #include <queue> | 9 #include <queue> |
| 10 | 10 |
| 11 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
| 12 #include "base/memory/weak_ptr.h" | 12 #include "base/memory/weak_ptr.h" |
| 13 #include "base/observer_list.h" | 13 #include "base/observer_list.h" |
| 14 #include "base/timer/timer.h" | |
| 14 #include "chromeos/audio/audio_device.h" | 15 #include "chromeos/audio/audio_device.h" |
| 15 #include "chromeos/audio/audio_pref_observer.h" | 16 #include "chromeos/audio/audio_pref_observer.h" |
| 16 #include "chromeos/dbus/audio_node.h" | 17 #include "chromeos/dbus/audio_node.h" |
| 17 #include "chromeos/dbus/cras_audio_client.h" | 18 #include "chromeos/dbus/cras_audio_client.h" |
| 18 #include "chromeos/dbus/session_manager_client.h" | 19 #include "chromeos/dbus/session_manager_client.h" |
| 19 #include "chromeos/dbus/volume_state.h" | 20 #include "chromeos/dbus/volume_state.h" |
| 20 | 21 |
| 21 class PrefRegistrySimple; | 22 class PrefRegistrySimple; |
| 22 class PrefService; | 23 class PrefService; |
| 23 | 24 |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 181 | 182 |
| 182 // Swaps the left and right channel of the internal speaker. | 183 // Swaps the left and right channel of the internal speaker. |
| 183 // Swap the left and right channel if |swap| is true; otherwise, swap the left | 184 // Swap the left and right channel if |swap| is true; otherwise, swap the left |
| 184 // and right channel back to the normal mode. | 185 // and right channel back to the normal mode. |
| 185 // If the feature is not supported on the device, nothing happens. | 186 // If the feature is not supported on the device, nothing happens. |
| 186 virtual void SwapInternalSpeakerLeftRightChannel(bool swap); | 187 virtual void SwapInternalSpeakerLeftRightChannel(bool swap); |
| 187 | 188 |
| 188 // Enables error logging. | 189 // Enables error logging. |
| 189 virtual void LogErrors(); | 190 virtual void LogErrors(); |
| 190 | 191 |
| 192 // If necessary, sets the starting point for re-discovering the active HDMI | |
| 193 // output device caused by device entering/exiting docking mode, HDMI display | |
| 194 // changing resolution, or chromeos device suspend/resume. If | |
| 195 // |force_rediscovering| is true, it will force to set the starting point for | |
| 196 // re-discovering the active HDMI output device again if it has been in the | |
| 197 // middle of rediscovering the HDMI active output device. | |
| 198 virtual void SetActiveHDMIOutoutRediscoveringIfNecessary( | |
| 199 bool force_rediscovering); | |
| 200 | |
| 191 protected: | 201 protected: |
| 192 explicit CrasAudioHandler( | 202 explicit CrasAudioHandler( |
| 193 scoped_refptr<AudioDevicesPrefHandler> audio_pref_handler); | 203 scoped_refptr<AudioDevicesPrefHandler> audio_pref_handler); |
| 194 ~CrasAudioHandler() override; | 204 ~CrasAudioHandler() override; |
| 195 | 205 |
| 196 private: | 206 private: |
| 197 friend class CrasAudioHandlerTest; | 207 friend class CrasAudioHandlerTest; |
| 198 | 208 |
| 199 // CrasAudioClient::Observer overrides. | 209 // CrasAudioClient::Observer overrides. |
| 200 void AudioClientRestarted() override; | 210 void AudioClientRestarted() override; |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 286 // primary active node. Otherwise, it will be added as an additional active | 296 // primary active node. Otherwise, it will be added as an additional active |
| 287 // node. | 297 // node. |
| 288 void AddActiveNode(uint64_t node_id, bool notify); | 298 void AddActiveNode(uint64_t node_id, bool notify); |
| 289 | 299 |
| 290 // Adds |node_id| into additional active nodes. | 300 // Adds |node_id| into additional active nodes. |
| 291 void AddAdditionalActiveNode(uint64_t node_id, bool notify); | 301 void AddAdditionalActiveNode(uint64_t node_id, bool notify); |
| 292 | 302 |
| 293 // Removes |node_id| from additional active nodes. | 303 // Removes |node_id| from additional active nodes. |
| 294 void RemoveActiveNodeInternal(uint64_t node_id, bool notify); | 304 void RemoveActiveNodeInternal(uint64_t node_id, bool notify); |
| 295 | 305 |
| 306 void UpdateAudioAfterHDMIRediscoverGracePeriod(); | |
| 307 | |
| 308 bool IsHDMIPrimaryOutputDevice() const; | |
| 309 | |
| 310 void StartHDMIRediscoverGracePeriod(); | |
| 311 | |
| 312 bool hdmi_rediscovering() const { return hdmi_rediscovering_; } | |
| 313 | |
| 314 void SetHDMIRediscoverGracePeriodForTesting(int during_in_ms); | |
|
cychiang
2015/06/26 10:00:21
should name it duration_in_ms ?
jennyz
2015/06/29 20:49:41
Done.
| |
| 315 | |
| 296 enum DeviceStatus { | 316 enum DeviceStatus { |
| 297 OLD_DEVICE, | 317 OLD_DEVICE, |
| 298 NEW_DEVICE, | 318 NEW_DEVICE, |
| 299 CHANGED_DEVICE, | 319 CHANGED_DEVICE, |
| 300 }; | 320 }; |
| 301 | 321 |
| 302 // Checks if |device| is a newly discovered, changed, or existing device for | 322 // Checks if |device| is a newly discovered, changed, or existing device for |
| 303 // the nodes sent from NodesChanged signal. | 323 // the nodes sent from NodesChanged signal. |
| 304 DeviceStatus CheckDeviceStatus(const AudioDevice& device); | 324 DeviceStatus CheckDeviceStatus(const AudioDevice& device); |
| 305 | 325 |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 321 uint64_t active_output_node_id_; | 341 uint64_t active_output_node_id_; |
| 322 uint64_t active_input_node_id_; | 342 uint64_t active_input_node_id_; |
| 323 bool has_alternative_input_; | 343 bool has_alternative_input_; |
| 324 bool has_alternative_output_; | 344 bool has_alternative_output_; |
| 325 | 345 |
| 326 bool output_mute_locked_; | 346 bool output_mute_locked_; |
| 327 | 347 |
| 328 // Failures are not logged at startup, since CRAS may not be running yet. | 348 // Failures are not logged at startup, since CRAS may not be running yet. |
| 329 bool log_errors_; | 349 bool log_errors_; |
| 330 | 350 |
| 351 // Timer for HDMI re-discovering grace period. | |
| 352 base::OneShotTimer<CrasAudioHandler> hdmi_rediscover_timer_; | |
| 353 int hdmi_rediscover_grace_period_duration_in_ms_; | |
| 354 bool hdmi_rediscovering_; | |
| 355 | |
| 331 base::WeakPtrFactory<CrasAudioHandler> weak_ptr_factory_; | 356 base::WeakPtrFactory<CrasAudioHandler> weak_ptr_factory_; |
| 332 | 357 |
| 333 DISALLOW_COPY_AND_ASSIGN(CrasAudioHandler); | 358 DISALLOW_COPY_AND_ASSIGN(CrasAudioHandler); |
| 334 }; | 359 }; |
| 335 | 360 |
| 336 } // namespace chromeos | 361 } // namespace chromeos |
| 337 | 362 |
| 338 #endif // CHROMEOS_AUDIO_CRAS_AUDIO_HANDLER_H_ | 363 #endif // CHROMEOS_AUDIO_CRAS_AUDIO_HANDLER_H_ |
| OLD | NEW |