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 // Implementation of AudioInputStream for Mac OS X using the special AUHAL | 5 // Implementation of AudioInputStream for Mac OS X using the special AUHAL |
6 // input Audio Unit present in OS 10.4 and later. | 6 // input Audio Unit present in OS 10.4 and later. |
7 // The AUHAL input Audio Unit is for low-latency audio I/O. | 7 // The AUHAL input Audio Unit is for low-latency audio I/O. |
8 // | 8 // |
9 // Overview of operation: | 9 // Overview of operation: |
10 // | 10 // |
(...skipping 27 matching lines...) Expand all Loading... |
38 | 38 |
39 #include <AudioUnit/AudioUnit.h> | 39 #include <AudioUnit/AudioUnit.h> |
40 #include <CoreAudio/CoreAudio.h> | 40 #include <CoreAudio/CoreAudio.h> |
41 | 41 |
42 #include "base/cancelable_callback.h" | 42 #include "base/cancelable_callback.h" |
43 #include "base/memory/scoped_ptr.h" | 43 #include "base/memory/scoped_ptr.h" |
44 #include "base/synchronization/lock.h" | 44 #include "base/synchronization/lock.h" |
45 #include "media/audio/agc_audio_stream.h" | 45 #include "media/audio/agc_audio_stream.h" |
46 #include "media/audio/audio_io.h" | 46 #include "media/audio/audio_io.h" |
47 #include "media/audio/audio_parameters.h" | 47 #include "media/audio/audio_parameters.h" |
| 48 #include "media/base/audio_block_fifo.h" |
48 | 49 |
49 namespace media { | 50 namespace media { |
50 | 51 |
51 class AudioBus; | 52 class AudioBus; |
52 class AudioFifo; | |
53 class AudioManagerMac; | 53 class AudioManagerMac; |
54 class DataBuffer; | 54 class DataBuffer; |
55 | 55 |
56 class AUAudioInputStream : public AgcAudioStream<AudioInputStream> { | 56 class AUAudioInputStream : public AgcAudioStream<AudioInputStream> { |
57 public: | 57 public: |
58 // The ctor takes all the usual parameters, plus |manager| which is the | 58 // The ctor takes all the usual parameters, plus |manager| which is the |
59 // the audio manager who is creating this object. | 59 // the audio manager who is creating this object. |
60 AUAudioInputStream(AudioManagerMac* manager, | 60 AUAudioInputStream(AudioManagerMac* manager, |
61 const AudioParameters& input_params, | 61 const AudioParameters& input_params, |
62 AudioDeviceID audio_device_id); | 62 AudioDeviceID audio_device_id); |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
141 // True after successfull Start(), false after successful Stop(). | 141 // True after successfull Start(), false after successful Stop(). |
142 bool started_; | 142 bool started_; |
143 | 143 |
144 // Fixed capture hardware latency in frames. | 144 // Fixed capture hardware latency in frames. |
145 double hardware_latency_frames_; | 145 double hardware_latency_frames_; |
146 | 146 |
147 // The number of channels in each frame of audio data, which is used | 147 // The number of channels in each frame of audio data, which is used |
148 // when querying the volume of each channel. | 148 // when querying the volume of each channel. |
149 int number_of_channels_in_frame_; | 149 int number_of_channels_in_frame_; |
150 | 150 |
151 // Dynamically allocated FIFO used to accumulates recorded data when | 151 // FIFO used to accumulates recorded data. |
152 // CoreAudio delivers non-requested frame size of data. | 152 media::AudioBlockFifo fifo_; |
153 scoped_ptr<media::AudioFifo> fifo_; | |
154 | 153 |
155 // Used to defer Start() to workaround http://crbug.com/160920. | 154 // Used to defer Start() to workaround http://crbug.com/160920. |
156 base::CancelableClosure deferred_start_cb_; | 155 base::CancelableClosure deferred_start_cb_; |
157 | 156 |
158 // Audio bus used for storage of deinterleaved data for the OnData callback. | |
159 scoped_ptr<media::AudioBus> audio_bus_; | |
160 | |
161 // Audio bus used to convert interleaved data to deinterleaved data before | |
162 // storing data to FIFO or delivering data via OnData callback. | |
163 scoped_ptr<media::AudioBus> audio_wrapper_; | |
164 | |
165 DISALLOW_COPY_AND_ASSIGN(AUAudioInputStream); | 157 DISALLOW_COPY_AND_ASSIGN(AUAudioInputStream); |
166 }; | 158 }; |
167 | 159 |
168 } // namespace media | 160 } // namespace media |
169 | 161 |
170 #endif // MEDIA_AUDIO_MAC_AUDIO_LOW_LATENCY_INPUT_MAC_H_ | 162 #endif // MEDIA_AUDIO_MAC_AUDIO_LOW_LATENCY_INPUT_MAC_H_ |
OLD | NEW |