Index: chromeos/audio/cras_audio_handler.h |
diff --git a/chromeos/audio/cras_audio_handler.h b/chromeos/audio/cras_audio_handler.h |
index 633e30a33a7a2d5d9b4729f747479f23c668b79c..32d2d8317c74b577feb1a78cce695fd4a59c2a4f 100644 |
--- a/chromeos/audio/cras_audio_handler.h |
+++ b/chromeos/audio/cras_audio_handler.h |
@@ -21,6 +21,10 @@ |
class PrefRegistrySimple; |
class PrefService; |
+namespace media { |
+class AudioManager; |
+} |
+ |
namespace chromeos { |
class AudioDevicesPrefHandler; |
@@ -63,9 +67,26 @@ class CHROMEOS_EXPORT CrasAudioHandler : public CrasAudioClient::Observer, |
DISALLOW_COPY_AND_ASSIGN(AudioObserver); |
}; |
+ // The wrapper for audio manager methods to be called from this class. |
+ // The detail of AudioManager is hidden from CrasAudioHandler. |
+ class AudioManagerWrapper { |
+ public: |
+ virtual ~AudioManagerWrapper(); |
+ virtual void SetHasInputDevices(bool has_input_devices) = 0; |
+ |
+ protected: |
+ AudioManagerWrapper(); |
+ |
+ private: |
+ DISALLOW_COPY_AND_ASSIGN(AudioManagerWrapper); |
+ }; |
+ |
// Sets the global instance. Must be called before any calls to Get(). |
+ // Optionally pass audio_manager to use implementation other than |
+ // AudioManagerWrapperImpl. |
static void Initialize( |
- scoped_refptr<AudioDevicesPrefHandler> audio_pref_handler); |
+ scoped_refptr<AudioDevicesPrefHandler> audio_pref_handler, |
+ scoped_ptr<AudioManagerWrapper> audio_manager = NULL); |
Daniel Erat
2015/06/24 13:37:45
default arguments aren't allowed in cases like thi
cychiang
2015/06/25 05:45:24
Done. Change production code at chrome/browser/chr
|
// Sets the global instance for testing. |
static void InitializeForTesting(); |
@@ -190,12 +211,23 @@ class CHROMEOS_EXPORT CrasAudioHandler : public CrasAudioClient::Observer, |
protected: |
explicit CrasAudioHandler( |
Daniel Erat
2015/06/24 13:37:45
nit: you don't need 'explicit' here now that this
cychiang
2015/06/25 05:45:24
Done.
|
- scoped_refptr<AudioDevicesPrefHandler> audio_pref_handler); |
+ scoped_refptr<AudioDevicesPrefHandler> audio_pref_handler, |
+ scoped_ptr<AudioManagerWrapper> audio_manager); |
~CrasAudioHandler() override; |
private: |
friend class CrasAudioHandlerTest; |
+ class AudioManagerWrapperImpl : public AudioManagerWrapper { |
+ public: |
+ AudioManagerWrapperImpl(); |
+ ~AudioManagerWrapperImpl() override; |
+ void SetHasInputDevices(bool has_input_devices) override; |
+ |
+ private: |
+ DISALLOW_COPY_AND_ASSIGN(AudioManagerWrapperImpl); |
+ }; |
+ |
// CrasAudioClient::Observer overrides. |
void AudioClientRestarted() override; |
void NodesChanged() override; |
@@ -281,6 +313,12 @@ class CHROMEOS_EXPORT CrasAudioHandler : public CrasAudioClient::Observer, |
void HandleGetNodesError(const std::string& error_name, |
const std::string& error_msg); |
+ // Sets HasInputDevice in AudioManager based on the updated device list. |
+ void UpdateAudioManagerHasInputDevices(); |
+ |
+ // Sets HasInputDevice in AudioManager to true or false. |
+ void SetAudioManagerHasInputDevices(bool has_input_devices); |
+ |
// Adds an active node. |
// If there is no active node, |node_id| will be switched to become the |
// primary active node. Otherwise, it will be added as an additional active |
@@ -308,6 +346,10 @@ class CHROMEOS_EXPORT CrasAudioHandler : public CrasAudioClient::Observer, |
scoped_refptr<AudioDevicesPrefHandler> audio_pref_handler_; |
base::ObserverList<AudioObserver> observers_; |
+ // audio_manager_ will point to an AudioManagerWrapperImpl object or |
Daniel Erat
2015/06/24 13:37:45
nit: "will hold" would probably be more accurate t
cychiang
2015/06/25 05:45:24
Done.
|
+ // a mocked AudioManagerWrapper object for testing. |
+ scoped_ptr<CrasAudioHandler::AudioManagerWrapper> audio_manager_; |
+ |
// Audio data and state. |
AudioDeviceMap audio_devices_; |