Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(946)

Side by Side Diff: chromeos/audio/cras_audio_handler.h

Issue 2721733003: Handle the dual microphones and dual cameras cases. Activate the proper microphone when user activa… (Closed)
Patch Set: Nit: log only the invalid camera facing mode value. Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chromeos/audio/audio_device.cc ('k') | chromeos/audio/cras_audio_handler.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 <stddef.h> 8 #include <stddef.h>
9 #include <stdint.h> 9 #include <stdint.h>
10 #include <queue> 10 #include <queue>
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 protected: 80 protected:
81 AudioObserver(); 81 AudioObserver();
82 virtual ~AudioObserver(); 82 virtual ~AudioObserver();
83 DISALLOW_COPY_AND_ASSIGN(AudioObserver); 83 DISALLOW_COPY_AND_ASSIGN(AudioObserver);
84 }; 84 };
85 85
86 enum DeviceActivateType { 86 enum DeviceActivateType {
87 ACTIVATE_BY_PRIORITY = 0, 87 ACTIVATE_BY_PRIORITY = 0,
88 ACTIVATE_BY_USER, 88 ACTIVATE_BY_USER,
89 ACTIVATE_BY_RESTORE_PREVIOUS_STATE, 89 ACTIVATE_BY_RESTORE_PREVIOUS_STATE,
90 ACTIVATE_BY_CAMERA
90 }; 91 };
91 92
92 // Sets the global instance. Must be called before any calls to Get(). 93 // Sets the global instance. Must be called before any calls to Get().
93 static void Initialize( 94 static void Initialize(
94 scoped_refptr<AudioDevicesPrefHandler> audio_pref_handler); 95 scoped_refptr<AudioDevicesPrefHandler> audio_pref_handler);
95 96
96 // Sets the global instance for testing. 97 // Sets the global instance for testing.
97 static void InitializeForTesting(); 98 static void InitializeForTesting();
98 99
99 // Destroys the global instance. 100 // Destroys the global instance.
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
254 // If necessary, sets the starting point for re-discovering the active HDMI 255 // If necessary, sets the starting point for re-discovering the active HDMI
255 // output device caused by device entering/exiting docking mode, HDMI display 256 // output device caused by device entering/exiting docking mode, HDMI display
256 // changing resolution, or chromeos device suspend/resume. If 257 // changing resolution, or chromeos device suspend/resume. If
257 // |force_rediscovering| is true, it will force to set the starting point for 258 // |force_rediscovering| is true, it will force to set the starting point for
258 // re-discovering the active HDMI output device again if it has been in the 259 // re-discovering the active HDMI output device again if it has been in the
259 // middle of rediscovering the HDMI active output device. 260 // middle of rediscovering the HDMI active output device.
260 void SetActiveHDMIOutoutRediscoveringIfNecessary(bool force_rediscovering); 261 void SetActiveHDMIOutoutRediscoveringIfNecessary(bool force_rediscovering);
261 262
262 const AudioDevice* GetDeviceFromId(uint64_t device_id) const; 263 const AudioDevice* GetDeviceFromId(uint64_t device_id) const;
263 264
265 // Returns true the device has dual internal microphones(front and rear).
266 bool HasDualInternalMic() const;
267
268 // Returns true if |device| is front or rear microphone.
269 bool IsFrontOrRearMic(const AudioDevice& device) const;
270
271 // Switches to either front or rear microphone depending on the
272 // the use case. It should be called from a user initiated action.
273 void SwitchToFrontOrRearMic();
274
264 protected: 275 protected:
265 explicit CrasAudioHandler( 276 explicit CrasAudioHandler(
266 scoped_refptr<AudioDevicesPrefHandler> audio_pref_handler); 277 scoped_refptr<AudioDevicesPrefHandler> audio_pref_handler);
267 ~CrasAudioHandler() override; 278 ~CrasAudioHandler() override;
268 279
269 private: 280 private:
270 friend class CrasAudioHandlerTest; 281 friend class CrasAudioHandlerTest;
271 282
272 // CrasAudioClient::Observer overrides. 283 // CrasAudioClient::Observer overrides.
273 void AudioClientRestarted() override; 284 void AudioClientRestarted() override;
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
432 void HandleHotPlugDevice( 443 void HandleHotPlugDevice(
433 const AudioDevice& hotplug_device, 444 const AudioDevice& hotplug_device,
434 const AudioDevicePriorityQueue& device_priority_queue); 445 const AudioDevicePriorityQueue& device_priority_queue);
435 446
436 void SwitchToTopPriorityDevice(bool is_input); 447 void SwitchToTopPriorityDevice(bool is_input);
437 448
438 // Switch to previous active device if it is found, otherwise, switch 449 // Switch to previous active device if it is found, otherwise, switch
439 // to the top priority device. 450 // to the top priority device.
440 void SwitchToPreviousActiveDeviceIfAvailable(bool is_input); 451 void SwitchToPreviousActiveDeviceIfAvailable(bool is_input);
441 452
453 // Activates the internal mic attached with the camera specified by
454 // |camera_facing|.
455 void ActivateMicForCamera(media::VideoFacingMode camera_facing);
456
457 // Activates the front or rear mic that is consistent with the active camera.
458 // Note: This should only be called for the dural camera/mic use case.
459 void ActivateInternalMicForActiveCamera();
460
461 // Returns the microphone for the camera with |camera_facing|.
462 const AudioDevice* GetMicForCamera(media::VideoFacingMode camera_facing);
463
464 // Returns the device matched with |type|. Assuming there is only one device
465 // matched the |type|, if there is more than one matched devices, it will
466 // return the first one found.
467 const AudioDevice* GetDeviceByType(AudioDeviceType type);
468
469 bool IsCameraOn() const;
470
471 // Returns true if there are any external devices.
472 bool HasExternalDevice(bool is_input) const;
473
442 scoped_refptr<AudioDevicesPrefHandler> audio_pref_handler_; 474 scoped_refptr<AudioDevicesPrefHandler> audio_pref_handler_;
443 base::ObserverList<AudioObserver> observers_; 475 base::ObserverList<AudioObserver> observers_;
444 476
445 // Audio data and state. 477 // Audio data and state.
446 AudioDeviceMap audio_devices_; 478 AudioDeviceMap audio_devices_;
447 479
448 AudioDevicePriorityQueue input_devices_pq_; 480 AudioDevicePriorityQueue input_devices_pq_;
449 AudioDevicePriorityQueue output_devices_pq_; 481 AudioDevicePriorityQueue output_devices_pq_;
450 482
451 bool output_mute_on_; 483 bool output_mute_on_;
(...skipping 24 matching lines...) Expand all
476 // FIFO list of reasons passed to 508 // FIFO list of reasons passed to
477 // SetOutputVolumePercentWithoutNotifyingObservers() for which we're still 509 // SetOutputVolumePercentWithoutNotifyingObservers() for which we're still
478 // waiting for OutputNodeVolumeChanged() calls. These are used to suppress 510 // waiting for OutputNodeVolumeChanged() calls. These are used to suppress
479 // notifications for those changes. 511 // notifications for those changes.
480 std::deque<AutomatedVolumeChangeReason> automated_volume_change_reasons_; 512 std::deque<AutomatedVolumeChangeReason> automated_volume_change_reasons_;
481 513
482 bool initializing_audio_state_ = false; 514 bool initializing_audio_state_ = false;
483 int init_volume_; 515 int init_volume_;
484 uint64_t init_node_id_; 516 uint64_t init_node_id_;
485 517
518 bool front_camera_on_ = false;
519 bool rear_camera_on_ = false;
520
486 base::WeakPtrFactory<CrasAudioHandler> weak_ptr_factory_; 521 base::WeakPtrFactory<CrasAudioHandler> weak_ptr_factory_;
487 522
488 DISALLOW_COPY_AND_ASSIGN(CrasAudioHandler); 523 DISALLOW_COPY_AND_ASSIGN(CrasAudioHandler);
489 }; 524 };
490 525
491 } // namespace chromeos 526 } // namespace chromeos
492 527
493 #endif // CHROMEOS_AUDIO_CRAS_AUDIO_HANDLER_H_ 528 #endif // CHROMEOS_AUDIO_CRAS_AUDIO_HANDLER_H_
OLDNEW
« no previous file with comments | « chromeos/audio/audio_device.cc ('k') | chromeos/audio/cras_audio_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698