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

Unified Diff: chromeos/audio/cras_audio_handler.h

Issue 1186293003: Implement HasInputDevices in CrasAudioManager (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add SetHasInputDevice in FakeAudioManager Created 5 years, 6 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 | « chromeos/audio/audio_device.h ('k') | 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 10c77a471da34484a652cd488124cccf26c5613d..be9a42001f1fcee625654edb4267dfcede486e70 100644
--- a/chromeos/audio/cras_audio_handler.h
+++ b/chromeos/audio/cras_audio_handler.h
@@ -22,6 +22,10 @@
class PrefRegistrySimple;
class PrefService;
+namespace media {
+class AudioManager;
stevenjb 2015/07/01 21:11:53 Is this needed? I don't see any references to it b
+}
+
namespace chromeos {
class AudioDevicesPrefHandler;
@@ -64,9 +68,38 @@ 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);
+ };
+
+ // The implementation of AudioManagerWrapper for production code.
+ class AudioManagerWrapperImpl : public AudioManagerWrapper {
+ public:
+ AudioManagerWrapperImpl();
+ ~AudioManagerWrapperImpl() override;
+ void SetHasInputDevices(bool has_input_devices) override;
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(AudioManagerWrapperImpl);
+ };
+
// Sets the global instance. Must be called before any calls to Get().
+ // An implemantation of AudioManagerWrapper is passed to constructor
+ // of CrasAudioHandler. It should be AudioManagerWrapperImpl
+ // for production code.
static void Initialize(
- scoped_refptr<AudioDevicesPrefHandler> audio_pref_handler);
+ scoped_refptr<AudioDevicesPrefHandler> audio_pref_handler,
+ scoped_ptr<AudioManagerWrapper> audio_manager);
// Sets the global instance for testing.
static void InitializeForTesting();
@@ -199,13 +232,27 @@ class CHROMEOS_EXPORT CrasAudioHandler : public CrasAudioClient::Observer,
bool force_rediscovering);
protected:
- explicit CrasAudioHandler(
- scoped_refptr<AudioDevicesPrefHandler> audio_pref_handler);
+ CrasAudioHandler(scoped_refptr<AudioDevicesPrefHandler> audio_pref_handler,
+ scoped_ptr<AudioManagerWrapper> audio_manager);
~CrasAudioHandler() override;
private:
friend class CrasAudioHandlerTest;
+ // The implementation of AudioManagerWrapper for testing.
+ // This implementation is used in unittest which needs CrasAudioHandler
+ // while there is no AudioManagerCras, e.g.: running unittests related
+ // to Cras on Linux.
+ class AudioManagerWrapperForTesting : public AudioManagerWrapper {
+ public:
+ AudioManagerWrapperForTesting();
+ ~AudioManagerWrapperForTesting() override;
+ void SetHasInputDevices(bool has_input_devices) override;
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(AudioManagerWrapperForTesting);
+ };
+
// CrasAudioClient::Observer overrides.
void AudioClientRestarted() override;
void NodesChanged() override;
@@ -291,6 +338,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
@@ -328,6 +381,10 @@ class CHROMEOS_EXPORT CrasAudioHandler : public CrasAudioClient::Observer,
scoped_refptr<AudioDevicesPrefHandler> audio_pref_handler_;
base::ObserverList<AudioObserver> observers_;
+ // audio_manager_ will hold an AudioManagerWrapperImpl object or
+ // a mocked AudioManagerWrapper object for testing.
+ scoped_ptr<CrasAudioHandler::AudioManagerWrapper> audio_manager_;
+
// Audio data and state.
AudioDeviceMap audio_devices_;
« no previous file with comments | « chromeos/audio/audio_device.h ('k') | chromeos/audio/cras_audio_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698