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

Unified Diff: media/audio/mac/audio_manager_mac.cc

Issue 12662038: Revert 187936 "Pass more detailed audio hardware configuration i..." (Closed) Base URL: svn://svn.chromium.org/chrome/branches/1440/src/
Patch Set: Created 7 years, 9 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 | « media/audio/mac/audio_manager_mac.h ('k') | media/base/audio_converter.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/audio/mac/audio_manager_mac.cc
===================================================================
--- media/audio/mac/audio_manager_mac.cc (revision 189875)
+++ media/audio/mac/audio_manager_mac.cc (working copy)
@@ -264,97 +264,6 @@
return HasAudioHardware(kAudioHardwarePropertyDefaultInputDevice);
}
-// TODO(crogers): There are several places on the OSX specific code which
-// could benefit from this helper function.
-bool AudioManagerMac::GetDefaultOutputDevice(
- AudioDeviceID* device) {
- CHECK(device);
-
- // Obtain the current output device selected by the user.
- static const AudioObjectPropertyAddress kAddress = {
- kAudioHardwarePropertyDefaultOutputDevice,
- kAudioObjectPropertyScopeGlobal,
- kAudioObjectPropertyElementMaster
- };
-
- UInt32 size = sizeof(*device);
-
- OSStatus result = AudioObjectGetPropertyData(
- kAudioObjectSystemObject,
- &kAddress,
- 0,
- 0,
- &size,
- device);
-
- if ((result != kAudioHardwareNoError) || (*device == kAudioDeviceUnknown)) {
- DLOG(ERROR) << "Error getting default output AudioDevice.";
- return false;
- }
-
- return true;
-}
-
-bool AudioManagerMac::GetDefaultOutputChannels(
- int* channels, int* channels_per_frame) {
- AudioDeviceID device;
- if (!GetDefaultOutputDevice(&device))
- return false;
-
- return GetDeviceChannels(device,
- kAudioDevicePropertyScopeOutput,
- channels,
- channels_per_frame);
-}
-
-bool AudioManagerMac::GetDeviceChannels(
- AudioDeviceID device,
- AudioObjectPropertyScope scope,
- int* channels,
- int* channels_per_frame) {
- CHECK(channels);
- CHECK(channels_per_frame);
-
- // Get stream configuration.
- AudioObjectPropertyAddress pa;
- pa.mSelector = kAudioDevicePropertyStreamConfiguration;
- pa.mScope = scope;
- pa.mElement = kAudioObjectPropertyElementMaster;
-
- UInt32 size;
- OSStatus result = AudioObjectGetPropertyDataSize(device, &pa, 0, 0, &size);
- if (result != noErr || !size)
- return false;
-
- // Allocate storage.
- scoped_array<uint8> list_storage(new uint8[size]);
- AudioBufferList& buffer_list =
- *reinterpret_cast<AudioBufferList*>(list_storage.get());
-
- result = AudioObjectGetPropertyData(
- device,
- &pa,
- 0,
- 0,
- &size,
- &buffer_list);
- if (result != noErr)
- return false;
-
- // Determine number of input channels.
- *channels_per_frame = buffer_list.mNumberBuffers > 0 ?
- buffer_list.mBuffers[0].mNumberChannels : 0;
- if (*channels_per_frame == 1 && buffer_list.mNumberBuffers > 1) {
- // Non-interleaved.
- *channels = buffer_list.mNumberBuffers;
- } else {
- // Interleaved.
- *channels = *channels_per_frame;
- }
-
- return true;
-}
-
void AudioManagerMac::GetAudioInputDeviceNames(
media::AudioDeviceNames* device_names) {
GetAudioDeviceInfo(true, device_names);
@@ -424,23 +333,11 @@
AudioParameters AudioManagerMac::GetPreferredOutputStreamParameters(
const AudioParameters& input_params) {
- int hardware_channels = 2;
- int hardware_channels_per_frame = 1;
- if (!GetDefaultOutputChannels(&hardware_channels,
- &hardware_channels_per_frame)) {
- // Fallback to stereo.
- hardware_channels = 2;
- }
-
- ChannelLayout channel_layout = GuessChannelLayout(hardware_channels);
-
+ ChannelLayout channel_layout = CHANNEL_LAYOUT_STEREO;
int buffer_size = kDefaultLowLatencyBufferSize;
- int user_buffer_size = GetUserBufferSize();
- if (user_buffer_size)
- buffer_size = user_buffer_size;
-
int input_channels = 0;
if (input_params.IsValid()) {
+ channel_layout = input_params.channel_layout();
input_channels = input_params.input_channels();
if (input_channels > 0) {
@@ -452,18 +349,13 @@
}
}
- AudioParameters params(
- AudioParameters::AUDIO_PCM_LOW_LATENCY,
- channel_layout,
- input_channels,
- AUAudioOutputStream::HardwareSampleRate(),
- 16,
- buffer_size);
+ int user_buffer_size = GetUserBufferSize();
+ if (user_buffer_size)
+ buffer_size = user_buffer_size;
- if (channel_layout == CHANNEL_LAYOUT_UNSUPPORTED)
- params.SetDiscreteChannels(hardware_channels);
-
- return params;
+ return AudioParameters(
+ AudioParameters::AUDIO_PCM_LOW_LATENCY, channel_layout, input_channels,
+ AUAudioOutputStream::HardwareSampleRate(), 16, buffer_size);
}
void AudioManagerMac::CreateDeviceListener() {
« no previous file with comments | « media/audio/mac/audio_manager_mac.h ('k') | media/base/audio_converter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698