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. 4 5#ifndef EXTENSIONS_SHELL_BROWSER_SHELL_AUDIO_CONTROLLER_CHROMEOS_H_ 6#define EXTENSIONS_SHELL_BROWSER_SHELL_AUDIO_CONTROLLER_CHROMEOS_H_ 7 8#include "base/macros.h" 9#include "chromeos/audio/audio_devices_pref_handler.h" 10#include "chromeos/audio/cras_audio_handler.h" 11 12namespace chromeos { 13class AudioDevicesPrefHandler; 14} 15 16namespace extensions { 17 18// Ensures that the "best" input and output audio devices are always active. 19class ShellAudioController : public chromeos::CrasAudioHandler::AudioObserver { 20 public: 21 // Requests max volume for all devices and doesn't bother saving prefs. 22 class PrefHandler : public chromeos::AudioDevicesPrefHandler { 23 public: 24 PrefHandler(); 25 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; 42 43 protected: 44 virtual ~PrefHandler(); 45 46 private: 47 DISALLOW_COPY_AND_ASSIGN(PrefHandler); 48 }; 49 50 ShellAudioController(); 51 virtual ~ShellAudioController(); 52 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; 61 62 private: 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(); 66 67 DISALLOW_COPY_AND_ASSIGN(ShellAudioController); 68}; 69 70} // namespace extensions 71 72#endif // EXTENSIONS_SHELL_BROWSER_SHELL_AUDIO_CONTROLLER_CHROMEOS_H_ 73