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 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 // TODO(annacc): AudioDeviceGetPropertyInfo() is deprecated, but its |
119 // replacement, AudioObjectGetPropertyDataSize(), doesn't work yet with | 119 // replacement, AudioObjectGetPropertyDataSize(), doesn't work yet with |
120 // kAudioDevicePropertyPreferredChannelLayout. | 120 // kAudioDevicePropertyPreferredChannelLayout. |
| 121 #pragma clang diagnostic push |
| 122 #pragma clang diagnostic ignored "-Wdeprecated-declarations" |
121 err = AudioDeviceGetPropertyInfo(device_id, 0, false, | 123 err = AudioDeviceGetPropertyInfo(device_id, 0, false, |
122 kAudioDevicePropertyPreferredChannelLayout, | 124 kAudioDevicePropertyPreferredChannelLayout, |
123 &core_layout_size, NULL); | 125 &core_layout_size, NULL); |
124 if (err != noErr) { | 126 if (err != noErr) { |
125 HandleError(err); | 127 HandleError(err); |
126 return false; | 128 return false; |
127 } | 129 } |
128 // Get the device's channel layout. This layout may vary in sized based on | 130 // Get the device's channel layout. This layout may vary in sized based on |
129 // the number of channels. Use |core_layout_size| to allocate memory. | 131 // the number of channels. Use |core_layout_size| to allocate memory. |
130 scoped_ptr_malloc<AudioChannelLayout> core_channel_layout; | 132 scoped_ptr_malloc<AudioChannelLayout> core_channel_layout; |
131 core_channel_layout.reset( | 133 core_channel_layout.reset( |
132 reinterpret_cast<AudioChannelLayout*>(malloc(core_layout_size))); | 134 reinterpret_cast<AudioChannelLayout*>(malloc(core_layout_size))); |
133 memset(core_channel_layout.get(), 0, core_layout_size); | 135 memset(core_channel_layout.get(), 0, core_layout_size); |
134 // TODO(annacc): AudioDeviceGetProperty() is deprecated, but its | 136 // TODO(annacc): AudioDeviceGetProperty() is deprecated, but its |
135 // replacement, AudioObjectGetPropertyData(), doesn't work yet with | 137 // replacement, AudioObjectGetPropertyData(), doesn't work yet with |
136 // kAudioDevicePropertyPreferredChannelLayout. | 138 // kAudioDevicePropertyPreferredChannelLayout. |
137 err = AudioDeviceGetProperty(device_id, 0, false, | 139 err = AudioDeviceGetProperty(device_id, 0, false, |
138 kAudioDevicePropertyPreferredChannelLayout, | 140 kAudioDevicePropertyPreferredChannelLayout, |
139 &core_layout_size, core_channel_layout.get()); | 141 &core_layout_size, core_channel_layout.get()); |
140 if (err != noErr) { | 142 if (err != noErr) { |
141 HandleError(err); | 143 HandleError(err); |
142 return false; | 144 return false; |
143 } | 145 } |
| 146 #pragma clang diagnostic pop |
144 | 147 |
145 num_core_channels_ = | 148 num_core_channels_ = |
146 static_cast<int>(core_channel_layout->mNumberChannelDescriptions); | 149 static_cast<int>(core_channel_layout->mNumberChannelDescriptions); |
147 if (num_core_channels_ == 2 && | 150 if (num_core_channels_ == 2 && |
148 ChannelLayoutToChannelCount(source_layout_) > 2) { | 151 ChannelLayoutToChannelCount(source_layout_) > 2) { |
149 should_down_mix_ = true; | 152 should_down_mix_ = true; |
150 format_.mChannelsPerFrame = num_core_channels_; | 153 format_.mChannelsPerFrame = num_core_channels_; |
151 format_.mBytesPerFrame = (format_.mBitsPerChannel >> 3) * | 154 format_.mBytesPerFrame = (format_.mBitsPerChannel >> 3) * |
152 format_.mChannelsPerFrame; | 155 format_.mChannelsPerFrame; |
153 format_.mBytesPerPacket = format_.mBytesPerFrame * format_.mFramesPerPacket; | 156 format_.mBytesPerPacket = format_.mBytesPerFrame * format_.mFramesPerPacket; |
(...skipping 382 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
536 source_ = source; | 539 source_ = source; |
537 } | 540 } |
538 | 541 |
539 AudioOutputStream::AudioSourceCallback* | 542 AudioOutputStream::AudioSourceCallback* |
540 PCMQueueOutAudioOutputStream::GetSource() { | 543 PCMQueueOutAudioOutputStream::GetSource() { |
541 base::AutoLock lock(source_lock_); | 544 base::AutoLock lock(source_lock_); |
542 return source_; | 545 return source_; |
543 } | 546 } |
544 | 547 |
545 } // namespace media | 548 } // namespace media |
OLD | NEW |