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

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

Issue 7134001: Fix for CoreAudio stereo problem for unknown speakers (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fixing few mistakes Created 9 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/audio/mac/audio_output_mac.cc
diff --git a/media/audio/mac/audio_output_mac.cc b/media/audio/mac/audio_output_mac.cc
index cbc4f9ef90ef490fb0466cafbd4d5c48a6c47e79..33d999e533d4afe2626492770fc181241cc3ff5e 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;
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698