Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(293)

Side by Side Diff: media/audio/mac/audio_input_mac.cc

Issue 4661001: Simplified AudioOutputStream interface. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: - Created 10 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « media/audio/mac/audio_input_mac.h ('k') | media/audio/mac/audio_manager_mac.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "media/audio/audio_util.h" 9 #include "media/audio/audio_util.h"
10 #include "media/audio/mac/audio_manager_mac.h" 10 #include "media/audio/mac/audio_manager_mac.h"
11 11
12 #if !defined(MAC_OS_X_VERSION_10_6) || \ 12 #if !defined(MAC_OS_X_VERSION_10_6) || \
13 MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_6 13 MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_6
14 enum { 14 enum {
15 kAudioQueueErr_EnqueueDuringReset = -66632 15 kAudioQueueErr_EnqueueDuringReset = -66632
16 }; 16 };
17 #endif 17 #endif
18 18
19 PCMQueueInAudioInputStream::PCMQueueInAudioInputStream( 19 PCMQueueInAudioInputStream::PCMQueueInAudioInputStream(
20 AudioManagerMac* manager, 20 AudioManagerMac* manager, AudioParameters params)
21 AudioParameters params,
22 int samples_per_buffer)
23 : manager_(manager), 21 : manager_(manager),
24 callback_(NULL), 22 callback_(NULL),
25 audio_queue_(NULL), 23 audio_queue_(NULL),
26 buffer_size_bytes_(0) { 24 buffer_size_bytes_(0) {
27 // We must have a manager. 25 // We must have a manager.
28 DCHECK(manager_); 26 DCHECK(manager_);
29 // A frame is one sample across all channels. In interleaved audio the per 27 // A frame is one sample across all channels. In interleaved audio the per
30 // frame fields identify the set of n |channels|. In uncompressed audio, a 28 // frame fields identify the set of n |channels|. In uncompressed audio, a
31 // packet is always one frame. 29 // packet is always one frame.
32 format_.mSampleRate = params.sample_rate; 30 format_.mSampleRate = params.sample_rate;
33 format_.mFormatID = kAudioFormatLinearPCM; 31 format_.mFormatID = kAudioFormatLinearPCM;
34 format_.mFormatFlags = kLinearPCMFormatFlagIsPacked | 32 format_.mFormatFlags = kLinearPCMFormatFlagIsPacked |
35 kLinearPCMFormatFlagIsSignedInteger; 33 kLinearPCMFormatFlagIsSignedInteger;
36 format_.mBitsPerChannel = params.bits_per_sample; 34 format_.mBitsPerChannel = params.bits_per_sample;
37 format_.mChannelsPerFrame = params.channels; 35 format_.mChannelsPerFrame = params.channels;
38 format_.mFramesPerPacket = 1; 36 format_.mFramesPerPacket = 1;
39 format_.mBytesPerPacket = (params.bits_per_sample * params.channels) / 8; 37 format_.mBytesPerPacket = (params.bits_per_sample * params.channels) / 8;
40 format_.mBytesPerFrame = format_.mBytesPerPacket; 38 format_.mBytesPerFrame = format_.mBytesPerPacket;
41 39
42 buffer_size_bytes_ = format_.mBytesPerFrame * samples_per_buffer; 40 buffer_size_bytes_ = params.GetPacketSize();
43 } 41 }
44 42
45 PCMQueueInAudioInputStream::~PCMQueueInAudioInputStream() { 43 PCMQueueInAudioInputStream::~PCMQueueInAudioInputStream() {
46 DCHECK(!callback_); 44 DCHECK(!callback_);
47 DCHECK(!audio_queue_); 45 DCHECK(!audio_queue_);
48 } 46 }
49 47
50 bool PCMQueueInAudioInputStream::Open() { 48 bool PCMQueueInAudioInputStream::Open() {
51 OSStatus err = AudioQueueNewInput(&format_, 49 OSStatus err = AudioQueueNewInput(&format_,
52 &HandleInputBufferStatic, 50 &HandleInputBufferStatic,
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
171 // TODO(joth): PCMQueueOutAudioOutputStream uses callback_ to provide an 169 // TODO(joth): PCMQueueOutAudioOutputStream uses callback_ to provide an
172 // extra guard for this situation, but it seems to introduce more 170 // extra guard for this situation, but it seems to introduce more
173 // complications than it solves (memory barrier issues accessing it from 171 // complications than it solves (memory barrier issues accessing it from
174 // multiple threads, looses the means to indicate OnClosed to client). 172 // multiple threads, looses the means to indicate OnClosed to client).
175 // Should determine if we need to do something equivalent here. 173 // Should determine if we need to do something equivalent here.
176 return; 174 return;
177 } 175 }
178 HandleError(err); 176 HandleError(err);
179 } 177 }
180 } 178 }
OLDNEW
« no previous file with comments | « media/audio/mac/audio_input_mac.h ('k') | media/audio/mac/audio_manager_mac.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698