1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef EXTENSIONS_SHELL_BROWSER_SHELL_AUDIO_CONTROLLER_CHROMEOS_H_
6 #define EXTENSIONS_SHELL_BROWSER_SHELL_AUDIO_CONTROLLER_CHROMEOS_H_
8 #include "base/macros.h"
9 #include "chromeos/audio/audio_devices_pref_handler.h"
10 #include "chromeos/audio/cras_audio_handler.h"
13 class AudioDevicesPrefHandler
;
16 namespace extensions
{
18 // Ensures that the "best" input and output audio devices are always active.
19 class ShellAudioController
: public chromeos::CrasAudioHandler::AudioObserver
{
21 // Requests max volume for all devices and doesn't bother saving prefs.
22 class PrefHandler
: public chromeos::AudioDevicesPrefHandler
{
26 // chromeos::AudioDevicesPrefHandler implementation:
27 virtual double GetOutputVolumeValue(
28 const chromeos::AudioDevice
* device
) override
;
29 virtual double GetInputGainValue(
30 const chromeos::AudioDevice
* device
) override
;
31 virtual void SetVolumeGainValue(const chromeos::AudioDevice
& device
,
32 double value
) override
;
33 virtual bool GetMuteValue(const chromeos::AudioDevice
& device
) override
;
34 virtual void SetMuteValue(const chromeos::AudioDevice
& device
,
35 bool mute_on
) override
;
36 virtual bool GetAudioCaptureAllowedValue() override
;
37 virtual bool GetAudioOutputAllowedValue() override
;
38 virtual void AddAudioPrefObserver(
39 chromeos::AudioPrefObserver
* observer
) override
;
40 virtual void RemoveAudioPrefObserver(
41 chromeos::AudioPrefObserver
* observer
) override
;
44 virtual ~PrefHandler();
47 DISALLOW_COPY_AND_ASSIGN(PrefHandler
);
50 ShellAudioController();
51 virtual ~ShellAudioController();
53 // chromeos::CrasAudioHandler::Observer implementation:
54 virtual void OnOutputVolumeChanged() override
;
55 virtual void OnOutputMuteChanged() override
;
56 virtual void OnInputGainChanged() override
;
57 virtual void OnInputMuteChanged() override
;
58 virtual void OnAudioNodesChanged() override
;
59 virtual void OnActiveOutputNodeChanged() override
;
60 virtual void OnActiveInputNodeChanged() override
;
63 // Gets the current device list from CRAS, chooses the best input and output
64 // device, and activates them if they aren't already active.
65 void ActivateDevices();
67 DISALLOW_COPY_AND_ASSIGN(ShellAudioController
);
70 } // namespace extensions
72 #endif // EXTENSIONS_SHELL_BROWSER_SHELL_AUDIO_CONTROLLER_CHROMEOS_H_