Commit afc1d76e authored by joi@chromium.org's avatar joi@chromium.org

Implement GetAudioOutputDeviceNames for Mac OS X.

BUG=276894
R=tommi@chromium.org

Review URL: https://codereview.chromium.org/24072002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@222217 0039d316-1c4b-4281-b951-d872f2087c98
parent f3617171
......@@ -32,6 +32,8 @@ void GetAudioOutputDeviceNamesImpl(AudioManager* audio_manager) {
}
TEST(AudioManagerTest, GetAudioOutputDeviceNames) {
// On Linux, we may be able to test both the Alsa and Pulseaudio
// versions of the audio manager.
#if defined(USE_PULSEAUDIO)
{
VLOG(2) << "Testing AudioManagerPulse.";
......@@ -49,6 +51,12 @@ TEST(AudioManagerTest, GetAudioOutputDeviceNames) {
GetAudioOutputDeviceNamesImpl(alsa_audio_manager.get());
}
#endif // defined(USE_ALSA)
#if defined(OS_MACOSX)
VLOG(2) << "Testing platform-default AudioManager.";
scoped_ptr<AudioManager> audio_manager(AudioManager::Create());
GetAudioOutputDeviceNamesImpl(audio_manager.get());
#endif // defined(OS_MACOSX)
}
} // namespace media
......@@ -81,6 +81,8 @@ bool AudioManagerMac::HasUnifiedDefaultIO() {
return input_id == output_id;
}
// Retrieves information on audio devices, and prepends the default
// device to the list if the list is non-empty.
static void GetAudioDeviceInfo(bool is_input,
media::AudioDeviceNames* device_names) {
// Query the number of total devices.
......@@ -173,6 +175,16 @@ static void GetAudioDeviceInfo(bool is_input,
if (name)
CFRelease(name);
}
if (!device_names->empty()) {
// Prepend the default device to the list since we always want it to be
// on the top of the list for all platforms. There is no duplicate
// counting here since the default device has been abstracted out before.
media::AudioDeviceName name;
name.device_name = AudioManagerBase::kDefaultDeviceName;
name.unique_id = AudioManagerBase::kDefaultDeviceId;
device_names->push_front(name);
}
}
static AudioDeviceID GetAudioDeviceIdByUId(bool is_input,
......@@ -396,15 +408,12 @@ void AudioManagerMac::GetAudioInputDeviceNames(
media::AudioDeviceNames* device_names) {
DCHECK(device_names->empty());
GetAudioDeviceInfo(true, device_names);
if (!device_names->empty()) {
// Prepend the default device to the list since we always want it to be
// on the top of the list for all platforms. There is no duplicate
// counting here since the default device has been abstracted out before.
media::AudioDeviceName name;
name.device_name = AudioManagerBase::kDefaultDeviceName;
name.unique_id = AudioManagerBase::kDefaultDeviceId;
device_names->push_front(name);
}
}
void AudioManagerMac::GetAudioOutputDeviceNames(
media::AudioDeviceNames* device_names) {
DCHECK(device_names->empty());
GetAudioDeviceInfo(false, device_names);
}
AudioParameters AudioManagerMac::GetInputStreamParameters(
......
......@@ -29,6 +29,8 @@ class MEDIA_EXPORT AudioManagerMac : public AudioManagerBase {
virtual bool HasAudioInputDevices() OVERRIDE;
virtual void GetAudioInputDeviceNames(media::AudioDeviceNames* device_names)
OVERRIDE;
virtual void GetAudioOutputDeviceNames(media::AudioDeviceNames* device_names)
OVERRIDE;
virtual AudioParameters GetInputStreamParameters(
const std::string& device_id) OVERRIDE;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment