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

Unified Diff: chromeos/audio/cras_audio_handler.h

Issue 2605983002: Simplify logic behind chrome.audio.setActiveDevices (Closed)
Patch Set: . Created 3 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chromeos/audio/cras_audio_handler.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chromeos/audio/cras_audio_handler.h
diff --git a/chromeos/audio/cras_audio_handler.h b/chromeos/audio/cras_audio_handler.h
index a4f9cc39eb1c86e1f557eee57f94f4924e115ae3..1408f061f5d103fc56b55aed917072477056c511 100644
--- a/chromeos/audio/cras_audio_handler.h
+++ b/chromeos/audio/cras_audio_handler.h
@@ -104,106 +104,106 @@ class CHROMEOS_EXPORT CrasAudioHandler : public CrasAudioClient::Observer,
static CrasAudioHandler* Get();
// Adds an audio observer.
- virtual void AddAudioObserver(AudioObserver* observer);
+ void AddAudioObserver(AudioObserver* observer);
// Removes an audio observer.
- virtual void RemoveAudioObserver(AudioObserver* observer);
+ void RemoveAudioObserver(AudioObserver* observer);
// Returns true if keyboard mic exists.
- virtual bool HasKeyboardMic();
+ bool HasKeyboardMic();
// Returns true if audio output is muted for the system.
- virtual bool IsOutputMuted();
+ bool IsOutputMuted();
// Returns true if audio output is muted for a device.
- virtual bool IsOutputMutedForDevice(uint64_t device_id);
+ bool IsOutputMutedForDevice(uint64_t device_id);
// Returns true if audio input is muted.
- virtual bool IsInputMuted();
+ bool IsInputMuted();
// Returns true if audio input is muted for a device.
- virtual bool IsInputMutedForDevice(uint64_t device_id);
+ bool IsInputMutedForDevice(uint64_t device_id);
// Returns true if the output volume is below the default mute volume level.
- virtual bool IsOutputVolumeBelowDefaultMuteLevel();
+ bool IsOutputVolumeBelowDefaultMuteLevel();
// Returns volume level in 0-100% range at which the volume should be muted.
- virtual int GetOutputDefaultVolumeMuteThreshold();
+ int GetOutputDefaultVolumeMuteThreshold();
// Gets volume level in 0-100% range (0 being pure silence) for the current
// active node.
- virtual int GetOutputVolumePercent();
+ int GetOutputVolumePercent();
// Gets volume level in 0-100% range (0 being pure silence) for a device.
- virtual int GetOutputVolumePercentForDevice(uint64_t device_id);
+ int GetOutputVolumePercentForDevice(uint64_t device_id);
// Gets gain level in 0-100% range (0 being pure silence) for the current
// active node.
- virtual int GetInputGainPercent();
+ int GetInputGainPercent();
// Gets volume level in 0-100% range (0 being pure silence) for a device.
- virtual int GetInputGainPercentForDevice(uint64_t device_id);
+ int GetInputGainPercentForDevice(uint64_t device_id);
// Returns node_id of the primary active output node.
- virtual uint64_t GetPrimaryActiveOutputNode() const;
+ uint64_t GetPrimaryActiveOutputNode() const;
// Returns the node_id of the primary active input node.
- virtual uint64_t GetPrimaryActiveInputNode() const;
+ uint64_t GetPrimaryActiveInputNode() const;
// Gets the audio devices back in |device_list|.
// This call can be invoked from I/O thread or UI thread because
// it does not need to access CrasAudioClient on DBus.
- virtual void GetAudioDevices(AudioDeviceList* device_list) const;
+ void GetAudioDevices(AudioDeviceList* device_list) const;
- virtual bool GetPrimaryActiveOutputDevice(AudioDevice* device) const;
+ bool GetPrimaryActiveOutputDevice(AudioDevice* device) const;
// Whether there is alternative input/output audio device.
- virtual bool has_alternative_input() const;
- virtual bool has_alternative_output() const;
+ bool has_alternative_input() const;
+ bool has_alternative_output() const;
// Sets all active output devices' volume levels to |volume_percent|, whose
// range is from 0-100%.
- virtual void SetOutputVolumePercent(int volume_percent);
+ void SetOutputVolumePercent(int volume_percent);
// Sets all active output devices' volume levels to |volume_percent|, whose
// range is from 0-100%, without notifying observers.
- virtual void SetOutputVolumePercentWithoutNotifyingObservers(
+ void SetOutputVolumePercentWithoutNotifyingObservers(
int volume_percent,
AutomatedVolumeChangeReason reason);
// Sets all active input devices' gain level to |gain_percent|, whose range is
// from 0-100%.
- virtual void SetInputGainPercent(int gain_percent);
+ void SetInputGainPercent(int gain_percent);
// Adjusts all active output devices' volume up (positive percentage) or down
// (negative percentage).
- virtual void AdjustOutputVolumeByPercent(int adjust_by_percent);
+ void AdjustOutputVolumeByPercent(int adjust_by_percent);
// Adjusts all active output devices' volume to a minimum audible level if it
// is too low.
- virtual void AdjustOutputVolumeToAudibleLevel();
+ void AdjustOutputVolumeToAudibleLevel();
// Mutes or unmutes audio output device.
- virtual void SetOutputMute(bool mute_on);
+ void SetOutputMute(bool mute_on);
// Mutes or unmutes audio input device.
- virtual void SetInputMute(bool mute_on);
+ void SetInputMute(bool mute_on);
// Switches active audio device to |device|. |activate_by| indicates why
// the device is switched to active: by user's manual choice, by priority,
// or by restoring to its previous active state.
- virtual void SwitchToDevice(const AudioDevice& device,
- bool notify,
- DeviceActivateType activate_by);
+ void SwitchToDevice(const AudioDevice& device,
+ bool notify,
+ DeviceActivateType activate_by);
// Sets volume/gain level for a device.
- virtual void SetVolumeGainPercentForDevice(uint64_t device_id, int value);
+ void SetVolumeGainPercentForDevice(uint64_t device_id, int value);
// Sets the mute for device.
- virtual void SetMuteForDevice(uint64_t device_id, bool mute_on);
+ void SetMuteForDevice(uint64_t device_id, bool mute_on);
// Activates or deactivates keyboard mic if there's one.
- virtual void SetKeyboardMicActive(bool active);
+ void SetKeyboardMicActive(bool active);
// Changes the active nodes to the nodes specified by |new_active_ids|.
// The caller can pass in the "complete" active node list of either input
@@ -213,22 +213,37 @@ class CHROMEOS_EXPORT CrasAudioHandler : public CrasAudioClient::Observer,
// If the nodes specified in |new_active_ids| are already active, they will
// remain active. Otherwise, the old active nodes will be de-activated before
// we activate the new nodes with the same type(input/output).
- virtual void ChangeActiveNodes(const NodeIdList& new_active_ids);
+ // DEPRECATED in favor of |SetActiveInputNodes| and |SetActiveOutputNodes|.
+ void ChangeActiveNodes(const NodeIdList& new_active_ids);
+
+ // Sets the set of active input nodes. Empty |node_ids| will deactivate all
+ // input devices.
+ // |node_ids| is expected to contain only existing input node IDs - the
+ // method will fail if this is not the case.
+ // Returns whether the acive nodes were successfully set.
+ bool SetActiveInputNodes(const NodeIdList& node_ids);
+
+ // Sets the set of active output nodes. Empty |node_ids| will deactivate all
+ // output devices.
+ // |node_ids| is expected to contain only existing output node IDs - the
+ // method will fail if this is not the case.
+ // Returns whether the acive nodes were successfully set.
+ bool SetActiveOutputNodes(const NodeIdList& node_ids);
// Swaps the left and right channel of the internal speaker.
// Swap the left and right channel if |swap| is true; otherwise, swap the left
// and right channel back to the normal mode.
// If the feature is not supported on the device, nothing happens.
- virtual void SwapInternalSpeakerLeftRightChannel(bool swap);
+ void SwapInternalSpeakerLeftRightChannel(bool swap);
// Accessibility audio setting: sets the output mono or not.
- virtual void SetOutputMono(bool mono_on);
+ void SetOutputMono(bool mono_on);
// Returns true if output mono is enabled.
- virtual bool IsOutputMonoEnabled() const;
+ bool IsOutputMonoEnabled() const;
// Enables error logging.
- virtual void LogErrors();
+ void LogErrors();
// If necessary, sets the starting point for re-discovering the active HDMI
// output device caused by device entering/exiting docking mode, HDMI display
@@ -236,10 +251,9 @@ class CHROMEOS_EXPORT CrasAudioHandler : public CrasAudioClient::Observer,
// |force_rediscovering| is true, it will force to set the starting point for
// re-discovering the active HDMI output device again if it has been in the
// middle of rediscovering the HDMI active output device.
- virtual void SetActiveHDMIOutoutRediscoveringIfNecessary(
- bool force_rediscovering);
+ void SetActiveHDMIOutoutRediscoveringIfNecessary(bool force_rediscovering);
- virtual const AudioDevice* GetDeviceFromId(uint64_t device_id) const;
+ const AudioDevice* GetDeviceFromId(uint64_t device_id) const;
protected:
explicit CrasAudioHandler(
@@ -270,11 +284,14 @@ class CHROMEOS_EXPORT CrasAudioHandler : public CrasAudioClient::Observer,
bool notify,
DeviceActivateType activate_by);
+ // Shared implementation for |SetActiveInputNodes| and |SetActiveOutputNodes|.
+ bool SetActiveNodes(const NodeIdList& node_ids, bool is_input);
+
// Sets list of active input or output nodes to |devices|.
// If |is_input| is set, active input nodes will be set, otherwise active
// output nodes will be set.
// For each device in |devices| it is expected device.is_input == is_input.
- void SetActiveNodes(const AudioDeviceList& devices, bool is_input);
+ void SetActiveDevices(const AudioDeviceList& devices, bool is_input);
// Saves |device|'s state in pref. If |active| is true, |activate_by|
// indicates how |device| is activated.
« no previous file with comments | « no previous file | chromeos/audio/cras_audio_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698