Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "media/audio/mac/audio_output_mac.h" | 5 #include "media/audio/mac/audio_output_mac.h" |
| 6 | 6 |
| 7 #include <CoreServices/CoreServices.h> | 7 #include <CoreServices/CoreServices.h> |
| 8 | 8 |
| 9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
| 10 #include "base/debug/trace_event.h" | 10 #include "base/debug/trace_event.h" |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 108 UInt32 device_id_size = sizeof(device_id); | 108 UInt32 device_id_size = sizeof(device_id); |
| 109 OSStatus err = AudioObjectGetPropertyData(kAudioObjectSystemObject, | 109 OSStatus err = AudioObjectGetPropertyData(kAudioObjectSystemObject, |
| 110 &property_address, 0, NULL, | 110 &property_address, 0, NULL, |
| 111 &device_id_size, &device_id); | 111 &device_id_size, &device_id); |
| 112 if (err != noErr) { | 112 if (err != noErr) { |
| 113 HandleError(err); | 113 HandleError(err); |
| 114 return false; | 114 return false; |
| 115 } | 115 } |
| 116 // Get the size of the channel layout. | 116 // Get the size of the channel layout. |
| 117 UInt32 core_layout_size; | 117 UInt32 core_layout_size; |
| 118 // TODO(annacc): AudioDeviceGetPropertyInfo() is deprecated, but its | 118 property_address.mSelector = kAudioDevicePropertyPreferredChannelLayout; |
|
scherkus (not reviewing)
2012/07/31 01:44:21
...but this change would run into the bug on my 10
| |
| 119 // replacement, AudioObjectGetPropertyDataSize(), doesn't work yet with | 119 property_address.mScope = kAudioDevicePropertyScopeOutput; |
| 120 // kAudioDevicePropertyPreferredChannelLayout. | 120 err = AudioObjectGetPropertyDataSize(device_id, &property_address, 0, NULL, |
| 121 #pragma clang diagnostic push | 121 &core_layout_size); |
| 122 #pragma clang diagnostic ignored "-Wdeprecated-declarations" | |
| 123 err = AudioDeviceGetPropertyInfo(device_id, 0, false, | |
| 124 kAudioDevicePropertyPreferredChannelLayout, | |
| 125 &core_layout_size, NULL); | |
| 126 if (err != noErr) { | 122 if (err != noErr) { |
| 127 HandleError(err); | 123 HandleError(err); |
| 128 return false; | 124 return false; |
| 129 } | 125 } |
| 130 // Get the device's channel layout. This layout may vary in sized based on | 126 // Get the device's channel layout. This layout may vary in sized based on |
| 131 // the number of channels. Use |core_layout_size| to allocate memory. | 127 // the number of channels. Use |core_layout_size| to allocate memory. |
| 132 scoped_ptr_malloc<AudioChannelLayout> core_channel_layout; | 128 scoped_ptr_malloc<AudioChannelLayout> core_channel_layout; |
| 133 core_channel_layout.reset( | 129 core_channel_layout.reset( |
| 134 reinterpret_cast<AudioChannelLayout*>(malloc(core_layout_size))); | 130 reinterpret_cast<AudioChannelLayout*>(malloc(core_layout_size))); |
| 135 memset(core_channel_layout.get(), 0, core_layout_size); | 131 memset(core_channel_layout.get(), 0, core_layout_size); |
| 136 // TODO(annacc): AudioDeviceGetProperty() is deprecated, but its | 132 err = AudioObjectGetPropertyData(device_id, &property_address, 0, NULL, |
| 137 // replacement, AudioObjectGetPropertyData(), doesn't work yet with | 133 &core_layout_size, |
| 138 // kAudioDevicePropertyPreferredChannelLayout. | 134 core_channel_layout.get()); |
| 139 err = AudioDeviceGetProperty(device_id, 0, false, | |
| 140 kAudioDevicePropertyPreferredChannelLayout, | |
| 141 &core_layout_size, core_channel_layout.get()); | |
| 142 if (err != noErr) { | 135 if (err != noErr) { |
| 143 HandleError(err); | 136 HandleError(err); |
| 144 return false; | 137 return false; |
| 145 } | 138 } |
| 146 #pragma clang diagnostic pop | 139 #pragma clang diagnostic pop |
| 147 | 140 |
| 148 num_core_channels_ = | 141 num_core_channels_ = |
| 149 static_cast<int>(core_channel_layout->mNumberChannelDescriptions); | 142 static_cast<int>(core_channel_layout->mNumberChannelDescriptions); |
| 150 if (num_core_channels_ == 2 && | 143 if (num_core_channels_ == 2 && |
| 151 ChannelLayoutToChannelCount(source_layout_) > 2) { | 144 ChannelLayoutToChannelCount(source_layout_) > 2) { |
| (...skipping 387 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 539 source_ = source; | 532 source_ = source; |
| 540 } | 533 } |
| 541 | 534 |
| 542 AudioOutputStream::AudioSourceCallback* | 535 AudioOutputStream::AudioSourceCallback* |
| 543 PCMQueueOutAudioOutputStream::GetSource() { | 536 PCMQueueOutAudioOutputStream::GetSource() { |
| 544 base::AutoLock lock(source_lock_); | 537 base::AutoLock lock(source_lock_); |
| 545 return source_; | 538 return source_; |
| 546 } | 539 } |
| 547 | 540 |
| 548 } // namespace media | 541 } // namespace media |
| OLD | NEW |