summaryrefslogtreecommitdiffstats
path: root/media
diff options
context:
space:
mode:
authorannacc@chromium.org <annacc@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-06-08 16:30:22 +0000
committerannacc@chromium.org <annacc@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-06-08 16:30:22 +0000
commitf4c5bdf28431a1aa230678366c4386442326586e (patch)
tree92838806f7dd98d1cb8eb27f3e2dd9b9edc4e498 /media
parent3bc714dd73a80fcb9eb0306e31467dccb531570b (diff)
downloadchromium_src-f4c5bdf28431a1aa230678366c4386442326586e.zip
chromium_src-f4c5bdf28431a1aa230678366c4386442326586e.tar.gz
chromium_src-f4c5bdf28431a1aa230678366c4386442326586e.tar.bz2
Fix for CoreAudio stereo problem for unknown speakers
BUG=85100 TEST=HTML5 videos with stereo channel layout on Mac with unconfigured speakers can be heard. Review URL: http://codereview.chromium.org/7134001 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@88339 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'media')
-rw-r--r--media/audio/mac/audio_output_mac.cc24
1 files changed, 22 insertions, 2 deletions
diff --git a/media/audio/mac/audio_output_mac.cc b/media/audio/mac/audio_output_mac.cc
index cbc4f9e..33d999e 100644
--- a/media/audio/mac/audio_output_mac.cc
+++ b/media/audio/mac/audio_output_mac.cc
@@ -96,7 +96,7 @@ void PCMQueueOutAudioOutputStream::HandleError(OSStatus err) {
bool PCMQueueOutAudioOutputStream::Open() {
// Get the default device id.
- unsigned int device_id = 0;
+ AudioObjectID device_id = 0;
AudioObjectPropertyAddress property_address = {
kAudioHardwarePropertyDefaultOutputDevice,
kAudioObjectPropertyScopeGlobal,
@@ -112,6 +112,9 @@ bool PCMQueueOutAudioOutputStream::Open() {
}
// Get the size of the channel layout.
UInt32 core_layout_size;
+ // TODO(annacc): AudioDeviceGetPropertyInfo() is deprecated, but its
+ // replacement, AudioObjectGetPropertyDataSize(), doesn't work yet with
+ // kAudioDevicePropertyPreferredChannelLayout.
err = AudioDeviceGetPropertyInfo(device_id, 0, false,
kAudioDevicePropertyPreferredChannelLayout,
&core_layout_size, NULL);
@@ -125,6 +128,9 @@ bool PCMQueueOutAudioOutputStream::Open() {
core_channel_layout.reset(
reinterpret_cast<AudioChannelLayout*>(malloc(core_layout_size)));
memset(core_channel_layout.get(), 0, core_layout_size);
+ // TODO(annacc): AudioDeviceGetProperty() is deprecated, but its
+ // replacement, AudioObjectGetPropertyData(), doesn't work yet with
+ // kAudioDevicePropertyPreferredChannelLayout.
err = AudioDeviceGetProperty(device_id, 0, false,
kAudioDevicePropertyPreferredChannelLayout,
&core_layout_size, core_channel_layout.get());
@@ -174,8 +180,15 @@ bool PCMQueueOutAudioOutputStream::Open() {
for (int i = 0; i < CHANNELS_MAX; ++i)
core_channel_orderings_[i] = kEmptyChannel;
+ bool all_channels_unknown = true;
for (int i = 0; i < num_core_channels_; ++i) {
- switch (core_channel_layout->mChannelDescriptions[i].mChannelLabel) {
+ AudioChannelLabel label =
+ core_channel_layout->mChannelDescriptions[i].mChannelLabel;
+ if (label == kAudioChannelLabel_Unknown) {
+ continue;
+ }
+ all_channels_unknown = false;
+ switch (label) {
case kAudioChannelLabel_Left:
core_channel_orderings_[LEFT] = i;
channel_remap_[i] = kChannelOrderings[source_layout_][LEFT];
@@ -227,6 +240,10 @@ bool PCMQueueOutAudioOutputStream::Open() {
}
}
+ if (all_channels_unknown) {
+ return true;
+ }
+
// Check if we need to adjust the layout.
// If the device has a BACK_LEFT and no SIDE_LEFT and the source has
// a SIDE_LEFT but no BACK_LEFT, then move (and preserve the channel).
@@ -249,6 +266,9 @@ bool PCMQueueOutAudioOutputStream::Open() {
CheckForAdjustedLayout(LEFT_OF_CENTER, SIDE_LEFT);
// Same for RIGHT_OF_CENTER -> SIDE_RIGHT.
CheckForAdjustedLayout(RIGHT_OF_CENTER, SIDE_RIGHT);
+ // For MONO -> STEREO, move audio to LEFT and RIGHT if applicable.
+ CheckForAdjustedLayout(CENTER, LEFT);
+ CheckForAdjustedLayout(CENTER, RIGHT);
// Check if we will need to swizzle from source to device layout (maybe not!).
should_swizzle_ = false;