| 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_input_mac.h" | 5 #include "media/audio/mac/audio_input_mac.h" |
| 6 | 6 |
| 7 #include <CoreServices/CoreServices.h> | |
| 8 | |
| 9 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
| 10 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/mac/mac_logging.h" |
| 10 #include "media/audio/audio_manager_base.h" |
| 11 #include "media/audio/audio_util.h" | 11 #include "media/audio/audio_util.h" |
| 12 #include "media/audio/mac/audio_manager_mac.h" | 12 |
| 13 #if !defined(OS_IOS) |
| 14 #include <CoreServices/CoreServices.h> |
| 15 #endif |
| 13 | 16 |
| 14 namespace media { | 17 namespace media { |
| 15 | 18 |
| 16 PCMQueueInAudioInputStream::PCMQueueInAudioInputStream( | 19 PCMQueueInAudioInputStream::PCMQueueInAudioInputStream( |
| 17 AudioManagerMac* manager, const AudioParameters& params) | 20 AudioManagerBase* manager, const AudioParameters& params) |
| 18 : manager_(manager), | 21 : manager_(manager), |
| 19 callback_(NULL), | 22 callback_(NULL), |
| 20 audio_queue_(NULL), | 23 audio_queue_(NULL), |
| 21 buffer_size_bytes_(0), | 24 buffer_size_bytes_(0), |
| 22 started_(false) { | 25 started_(false) { |
| 23 // We must have a manager. | 26 // We must have a manager. |
| 24 DCHECK(manager_); | 27 DCHECK(manager_); |
| 25 // A frame is one sample across all channels. In interleaved audio the per | 28 // A frame is one sample across all channels. In interleaved audio the per |
| 26 // frame fields identify the set of n |channels|. In uncompressed audio, a | 29 // frame fields identify the set of n |channels|. In uncompressed audio, a |
| 27 // packet is always one frame. | 30 // packet is always one frame. |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 127 } | 130 } |
| 128 | 131 |
| 129 bool PCMQueueInAudioInputStream::GetAutomaticGainControl() { | 132 bool PCMQueueInAudioInputStream::GetAutomaticGainControl() { |
| 130 NOTREACHED() << "Only supported for low-latency mode."; | 133 NOTREACHED() << "Only supported for low-latency mode."; |
| 131 return false; | 134 return false; |
| 132 } | 135 } |
| 133 | 136 |
| 134 void PCMQueueInAudioInputStream::HandleError(OSStatus err) { | 137 void PCMQueueInAudioInputStream::HandleError(OSStatus err) { |
| 135 if (callback_) | 138 if (callback_) |
| 136 callback_->OnError(this, static_cast<int>(err)); | 139 callback_->OnError(this, static_cast<int>(err)); |
| 137 NOTREACHED() << "error " << GetMacOSStatusErrorString(err) | 140 // This point should never be reached. |
| 138 << " (" << err << ")"; | 141 OSSTATUS_DCHECK(0, err); |
| 139 } | 142 } |
| 140 | 143 |
| 141 bool PCMQueueInAudioInputStream::SetupBuffers() { | 144 bool PCMQueueInAudioInputStream::SetupBuffers() { |
| 142 DCHECK(buffer_size_bytes_); | 145 DCHECK(buffer_size_bytes_); |
| 143 for (int i = 0; i < kNumberBuffers; ++i) { | 146 for (int i = 0; i < kNumberBuffers; ++i) { |
| 144 AudioQueueBufferRef buffer; | 147 AudioQueueBufferRef buffer; |
| 145 OSStatus err = AudioQueueAllocateBuffer(audio_queue_, | 148 OSStatus err = AudioQueueAllocateBuffer(audio_queue_, |
| 146 buffer_size_bytes_, | 149 buffer_size_bytes_, |
| 147 &buffer); | 150 &buffer); |
| 148 if (err == noErr) | 151 if (err == noErr) |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 207 // complications than it solves (memory barrier issues accessing it from | 210 // complications than it solves (memory barrier issues accessing it from |
| 208 // multiple threads, looses the means to indicate OnClosed to client). | 211 // multiple threads, looses the means to indicate OnClosed to client). |
| 209 // Should determine if we need to do something equivalent here. | 212 // Should determine if we need to do something equivalent here. |
| 210 return; | 213 return; |
| 211 } | 214 } |
| 212 HandleError(err); | 215 HandleError(err); |
| 213 } | 216 } |
| 214 } | 217 } |
| 215 | 218 |
| 216 } // namespace media | 219 } // namespace media |
| OLD | NEW |