| 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> | 7 #include <CoreServices/CoreServices.h> |
| 8 | 8 |
| 9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 : manager_(manager), | 23 : manager_(manager), |
| 24 callback_(NULL), | 24 callback_(NULL), |
| 25 audio_queue_(NULL), | 25 audio_queue_(NULL), |
| 26 buffer_size_bytes_(0), | 26 buffer_size_bytes_(0), |
| 27 started_(false) { | 27 started_(false) { |
| 28 // We must have a manager. | 28 // We must have a manager. |
| 29 DCHECK(manager_); | 29 DCHECK(manager_); |
| 30 // A frame is one sample across all channels. In interleaved audio the per | 30 // A frame is one sample across all channels. In interleaved audio the per |
| 31 // frame fields identify the set of n |channels|. In uncompressed audio, a | 31 // frame fields identify the set of n |channels|. In uncompressed audio, a |
| 32 // packet is always one frame. | 32 // packet is always one frame. |
| 33 format_.mSampleRate = params.sample_rate; | 33 format_.mSampleRate = params.sample_rate(); |
| 34 format_.mFormatID = kAudioFormatLinearPCM; | 34 format_.mFormatID = kAudioFormatLinearPCM; |
| 35 format_.mFormatFlags = kLinearPCMFormatFlagIsPacked | | 35 format_.mFormatFlags = kLinearPCMFormatFlagIsPacked | |
| 36 kLinearPCMFormatFlagIsSignedInteger; | 36 kLinearPCMFormatFlagIsSignedInteger; |
| 37 format_.mBitsPerChannel = params.bits_per_sample; | 37 format_.mBitsPerChannel = params.bits_per_sample(); |
| 38 format_.mChannelsPerFrame = params.channels; | 38 format_.mChannelsPerFrame = params.channels(); |
| 39 format_.mFramesPerPacket = 1; | 39 format_.mFramesPerPacket = 1; |
| 40 format_.mBytesPerPacket = (params.bits_per_sample * params.channels) / 8; | 40 format_.mBytesPerPacket = (params.bits_per_sample() * params.channels()) / 8; |
| 41 format_.mBytesPerFrame = format_.mBytesPerPacket; | 41 format_.mBytesPerFrame = format_.mBytesPerPacket; |
| 42 format_.mReserved = 0; | 42 format_.mReserved = 0; |
| 43 | 43 |
| 44 buffer_size_bytes_ = params.GetPacketSize(); | 44 buffer_size_bytes_ = params.GetBytesPerBuffer(); |
| 45 } | 45 } |
| 46 | 46 |
| 47 PCMQueueInAudioInputStream::~PCMQueueInAudioInputStream() { | 47 PCMQueueInAudioInputStream::~PCMQueueInAudioInputStream() { |
| 48 DCHECK(!callback_); | 48 DCHECK(!callback_); |
| 49 DCHECK(!audio_queue_); | 49 DCHECK(!audio_queue_); |
| 50 } | 50 } |
| 51 | 51 |
| 52 bool PCMQueueInAudioInputStream::Open() { | 52 bool PCMQueueInAudioInputStream::Open() { |
| 53 OSStatus err = AudioQueueNewInput(&format_, | 53 OSStatus err = AudioQueueNewInput(&format_, |
| 54 &HandleInputBufferStatic, | 54 &HandleInputBufferStatic, |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 200 // TODO(joth): PCMQueueOutAudioOutputStream uses callback_ to provide an | 200 // TODO(joth): PCMQueueOutAudioOutputStream uses callback_ to provide an |
| 201 // extra guard for this situation, but it seems to introduce more | 201 // extra guard for this situation, but it seems to introduce more |
| 202 // complications than it solves (memory barrier issues accessing it from | 202 // complications than it solves (memory barrier issues accessing it from |
| 203 // multiple threads, looses the means to indicate OnClosed to client). | 203 // multiple threads, looses the means to indicate OnClosed to client). |
| 204 // Should determine if we need to do something equivalent here. | 204 // Should determine if we need to do something equivalent here. |
| 205 return; | 205 return; |
| 206 } | 206 } |
| 207 HandleError(err); | 207 HandleError(err); |
| 208 } | 208 } |
| 209 } | 209 } |
| OLD | NEW |