OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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_manager_mac.h" | 5 #include "media/audio/mac/audio_manager_mac.h" |
6 #include "media/audio/mac/audio_output_mac.h" | 6 #include "media/audio/mac/audio_output_mac.h" |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "media/audio/audio_util.h" | 10 #include "media/audio/audio_util.h" |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
139 // queueing data, however at most one callback might still be in flight which | 139 // queueing data, however at most one callback might still be in flight which |
140 // could attempt to enqueue right after the next call. Rather that trying to | 140 // could attempt to enqueue right after the next call. Rather that trying to |
141 // use a lock we rely on the internal Mac queue lock so the enqueue might | 141 // use a lock we rely on the internal Mac queue lock so the enqueue might |
142 // succeed or might fail but it won't crash or leave the queue itself in an | 142 // succeed or might fail but it won't crash or leave the queue itself in an |
143 // inconsistent state. | 143 // inconsistent state. |
144 OSStatus err = AudioQueueStop(audio_queue_, true); | 144 OSStatus err = AudioQueueStop(audio_queue_, true); |
145 if (err != noErr) | 145 if (err != noErr) |
146 HandleError(err); | 146 HandleError(err); |
147 } | 147 } |
148 | 148 |
149 void PCMQueueOutAudioOutputStream::SetVolume(double left_level, | 149 void PCMQueueOutAudioOutputStream::SetVolume(double volume) { |
150 double ) { | |
151 if (!audio_queue_) | 150 if (!audio_queue_) |
152 return; | 151 return; |
153 volume_ = static_cast<float>(left_level); | 152 volume_ = static_cast<float>(volume); |
154 OSStatus err = AudioQueueSetParameter(audio_queue_, | 153 OSStatus err = AudioQueueSetParameter(audio_queue_, |
155 kAudioQueueParam_Volume, | 154 kAudioQueueParam_Volume, |
156 left_level); | 155 volume); |
157 if (err != noErr) { | 156 if (err != noErr) { |
158 HandleError(err); | 157 HandleError(err); |
159 } | 158 } |
160 } | 159 } |
161 | 160 |
162 void PCMQueueOutAudioOutputStream::GetVolume(double* left_level, | 161 void PCMQueueOutAudioOutputStream::GetVolume(double* volume) { |
163 double* right_level) { | |
164 if (!audio_queue_) | 162 if (!audio_queue_) |
165 return; | 163 return; |
166 *left_level = volume_; | 164 *volume = volume_; |
167 *right_level = volume_; | |
168 } | 165 } |
169 | 166 |
170 // Reorder PCM from AAC layout to Core Audio layout. | 167 // Reorder PCM from AAC layout to Core Audio layout. |
171 // TODO(fbarchard): Switch layout when ffmpeg is updated. | 168 // TODO(fbarchard): Switch layout when ffmpeg is updated. |
172 namespace { | 169 namespace { |
173 template<class Format> | 170 template<class Format> |
174 static void SwizzleLayout(Format* b, size_t filled) { | 171 static void SwizzleLayout(Format* b, size_t filled) { |
175 static const int kNumSurroundChannels = 6; | 172 static const int kNumSurroundChannels = 6; |
176 Format aac[kNumSurroundChannels]; | 173 Format aac[kNumSurroundChannels]; |
177 for (size_t i = 0; i < filled; i += sizeof(aac), b += kNumSurroundChannels) { | 174 for (size_t i = 0; i < filled; i += sizeof(aac), b += kNumSurroundChannels) { |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
267 HandleError(err); | 264 HandleError(err); |
268 return; | 265 return; |
269 } | 266 } |
270 } | 267 } |
271 err = AudioQueueStart(audio_queue_, NULL); | 268 err = AudioQueueStart(audio_queue_, NULL); |
272 if (err != noErr) { | 269 if (err != noErr) { |
273 HandleError(err); | 270 HandleError(err); |
274 return; | 271 return; |
275 } | 272 } |
276 } | 273 } |
OLD | NEW |