Index: chromeos/audio/cras_audio_handler.cc |
diff --git a/chromeos/audio/cras_audio_handler.cc b/chromeos/audio/cras_audio_handler.cc |
index 1cf03d172d839ca39cce2294492d4dc5e7a9cae5..cc17ec1b90a84019464dc59fa3aab9d773f78e15 100644 |
--- a/chromeos/audio/cras_audio_handler.cc |
+++ b/chromeos/audio/cras_audio_handler.cc |
@@ -13,6 +13,7 @@ |
#include "chromeos/audio/audio_devices_pref_handler.h" |
#include "chromeos/audio/audio_devices_pref_handler_stub.h" |
#include "chromeos/dbus/dbus_thread_manager.h" |
+#include "media/audio/audio_manager.h" |
using std::max; |
using std::min; |
@@ -84,17 +85,48 @@ void CrasAudioHandler::AudioObserver::OnActiveOutputNodeChanged() { |
void CrasAudioHandler::AudioObserver::OnActiveInputNodeChanged() { |
} |
+CrasAudioHandler::AudioManagerWrapper::AudioManagerWrapper() { |
+} |
+CrasAudioHandler::AudioManagerWrapper::~AudioManagerWrapper() { |
+} |
+ |
+CrasAudioHandler::AudioManagerWrapperImpl::AudioManagerWrapperImpl() { |
+} |
+CrasAudioHandler::AudioManagerWrapperImpl::~AudioManagerWrapperImpl() { |
+} |
+ |
+void CrasAudioHandler::AudioManagerWrapperImpl::SetHasInputDevices( |
+ bool has_input_devices) { |
+ media::AudioManager::Get()->SetHasInputDevices(has_input_devices); |
+} |
+ |
+CrasAudioHandler::AudioManagerWrapperForTesting:: |
+ AudioManagerWrapperForTesting() { |
+} |
+CrasAudioHandler::AudioManagerWrapperForTesting:: |
+ ~AudioManagerWrapperForTesting() { |
+} |
+ |
+void CrasAudioHandler::AudioManagerWrapperForTesting::SetHasInputDevices( |
+ bool has_input_devices) { |
+} |
+ |
// static |
void CrasAudioHandler::Initialize( |
- scoped_refptr<AudioDevicesPrefHandler> audio_pref_handler) { |
+ scoped_refptr<AudioDevicesPrefHandler> audio_pref_handler, |
+ scoped_ptr<AudioManagerWrapper> audio_manager) { |
CHECK(!g_cras_audio_handler); |
- g_cras_audio_handler = new CrasAudioHandler(audio_pref_handler); |
+ g_cras_audio_handler = |
+ new CrasAudioHandler(audio_pref_handler, audio_manager.Pass()); |
} |
// static |
void CrasAudioHandler::InitializeForTesting() { |
CHECK(!g_cras_audio_handler); |
- CrasAudioHandler::Initialize(new AudioDevicesPrefHandlerStub()); |
+ scoped_ptr<AudioManagerWrapper> audio_manager( |
+ new CrasAudioHandler::AudioManagerWrapperForTesting()); |
+ CrasAudioHandler::Initialize(new AudioDevicesPrefHandlerStub(), |
+ audio_manager.Pass()); |
} |
// static |
@@ -456,7 +488,8 @@ void CrasAudioHandler::SetActiveHDMIOutoutRediscoveringIfNecessary( |
} |
CrasAudioHandler::CrasAudioHandler( |
- scoped_refptr<AudioDevicesPrefHandler> audio_pref_handler) |
+ scoped_refptr<AudioDevicesPrefHandler> audio_pref_handler, |
+ scoped_ptr<AudioManagerWrapper> audio_manager) |
: audio_pref_handler_(audio_pref_handler), |
output_mute_on_(false), |
input_mute_on_(false), |
@@ -474,6 +507,7 @@ CrasAudioHandler::CrasAudioHandler( |
weak_ptr_factory_(this) { |
if (!audio_pref_handler.get()) |
return; |
+ audio_manager_ = audio_manager.Pass(); |
// If the DBusThreadManager or the CrasAudioClient aren't available, there |
// isn't much we can do. This should only happen when running tests. |
if (!chromeos::DBusThreadManager::IsInitialized() || |
@@ -936,6 +970,18 @@ void CrasAudioHandler::UpdateDevicesAndSwitchActive( |
} |
} |
+void CrasAudioHandler::UpdateAudioManagerHasInputDevices() { |
+ AudioDeviceList devices; |
+ GetAudioDevices(&devices); |
+ for (size_t i = 0; i < devices.size(); ++i) { |
+ if (devices[i].is_input && devices[i].is_for_simple_usage()) { |
+ audio_manager_->SetHasInputDevices(true); |
+ return; |
+ } |
+ } |
+ audio_manager_->SetHasInputDevices(false); |
+} |
+ |
void CrasAudioHandler::HandleGetNodes(const chromeos::AudioNodeList& node_list, |
bool success) { |
if (!success) { |
@@ -944,6 +990,7 @@ void CrasAudioHandler::HandleGetNodes(const chromeos::AudioNodeList& node_list, |
} |
UpdateDevicesAndSwitchActive(node_list); |
+ UpdateAudioManagerHasInputDevices(); |
FOR_EACH_OBSERVER(AudioObserver, observers_, OnAudioNodesChanged()); |
} |