OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
11 #ifndef WEBRTC_MODULES_AUDIO_DEVICE_IOS_AUDIO_DEVICE_IOS_H_ | 11 #ifndef WEBRTC_MODULES_AUDIO_DEVICE_IOS_AUDIO_DEVICE_IOS_H_ |
12 #define WEBRTC_MODULES_AUDIO_DEVICE_IOS_AUDIO_DEVICE_IOS_H_ | 12 #define WEBRTC_MODULES_AUDIO_DEVICE_IOS_AUDIO_DEVICE_IOS_H_ |
13 | 13 |
14 #include <AudioUnit/AudioUnit.h> | 14 #include <AudioUnit/AudioUnit.h> |
15 | 15 |
16 #include "webrtc/base/criticalsection.h" | |
16 #include "webrtc/base/scoped_ptr.h" | 17 #include "webrtc/base/scoped_ptr.h" |
17 #include "webrtc/base/thread_checker.h" | 18 #include "webrtc/base/thread_checker.h" |
18 #include "webrtc/modules/audio_device/audio_device_generic.h" | 19 #include "webrtc/modules/audio_device/audio_device_generic.h" |
19 | 20 |
20 namespace webrtc { | 21 namespace webrtc { |
21 | 22 |
22 class FineAudioBuffer; | 23 class FineAudioBuffer; |
23 | 24 |
24 // Implements full duplex 16-bit mono PCM audio support for iOS using a | 25 // Implements full duplex 16-bit mono PCM audio support for iOS using a |
25 // Voice-Processing (VP) I/O audio unit in Core Audio. The VP I/O audio unit | 26 // Voice-Processing (VP) I/O audio unit in Core Audio. The VP I/O audio unit |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
177 // a BT headset is enabled or disabled. | 178 // a BT headset is enabled or disabled. |
178 bool RestartAudioUnitWithNewFormat(float sample_rate); | 179 bool RestartAudioUnitWithNewFormat(float sample_rate); |
179 | 180 |
180 // Activates our audio session, creates and initializes the voice-processing | 181 // Activates our audio session, creates and initializes the voice-processing |
181 // audio unit and verifies that we got the preferred native audio parameters. | 182 // audio unit and verifies that we got the preferred native audio parameters. |
182 bool InitPlayOrRecord(); | 183 bool InitPlayOrRecord(); |
183 | 184 |
184 // Closes and deletes the voice-processing I/O unit. | 185 // Closes and deletes the voice-processing I/O unit. |
185 bool ShutdownPlayOrRecord(); | 186 bool ShutdownPlayOrRecord(); |
186 | 187 |
188 // Helper method for destroying the existing audio unit. | |
189 void DisposeAudioUnit(); | |
190 | |
187 // Callback function called on a real-time priority I/O thread from the audio | 191 // Callback function called on a real-time priority I/O thread from the audio |
188 // unit. This method is used to signal that recorded audio is available. | 192 // unit. This method is used to signal that recorded audio is available. |
189 static OSStatus RecordedDataIsAvailable( | 193 static OSStatus RecordedDataIsAvailable( |
190 void* in_ref_con, | 194 void* in_ref_con, |
191 AudioUnitRenderActionFlags* io_action_flags, | 195 AudioUnitRenderActionFlags* io_action_flags, |
192 const AudioTimeStamp* time_stamp, | 196 const AudioTimeStamp* time_stamp, |
193 UInt32 in_bus_number, | 197 UInt32 in_bus_number, |
194 UInt32 in_number_frames, | 198 UInt32 in_number_frames, |
195 AudioBufferList* io_data); | 199 AudioBufferList* io_data); |
196 OSStatus OnRecordedDataIsAvailable( | 200 OSStatus OnRecordedDataIsAvailable( |
197 AudioUnitRenderActionFlags* io_action_flags, | 201 AudioUnitRenderActionFlags* io_action_flags, |
198 const AudioTimeStamp* time_stamp, | 202 const AudioTimeStamp* time_stamp, |
199 UInt32 in_bus_number, | 203 UInt32 in_bus_number, |
200 UInt32 in_number_frames); | 204 UInt32 in_number_frames); |
201 | 205 |
202 // Callback function called on a real-time priority I/O thread from the audio | 206 // Callback function called on a real-time priority I/O thread from the audio |
203 // unit. This method is used to provide audio samples to the audio unit. | 207 // unit. This method is used to provide audio samples to the audio unit. |
204 static OSStatus GetPlayoutData(void* in_ref_con, | 208 static OSStatus GetPlayoutData(void* in_ref_con, |
205 AudioUnitRenderActionFlags* io_action_flags, | 209 AudioUnitRenderActionFlags* io_action_flags, |
206 const AudioTimeStamp* time_stamp, | 210 const AudioTimeStamp* time_stamp, |
207 UInt32 in_bus_number, | 211 UInt32 in_bus_number, |
208 UInt32 in_number_frames, | 212 UInt32 in_number_frames, |
209 AudioBufferList* io_data); | 213 AudioBufferList* io_data); |
210 OSStatus OnGetPlayoutData(AudioUnitRenderActionFlags* io_action_flags, | 214 OSStatus OnGetPlayoutData(AudioUnitRenderActionFlags* io_action_flags, |
211 UInt32 in_number_frames, | 215 UInt32 in_number_frames, |
212 AudioBufferList* io_data); | 216 AudioBufferList* io_data); |
213 | 217 |
218 // Counts number of times setActive:YES has been called on the singleton | |
219 // AVAudioSession instance. Used to ensure that we don't disable an audio | |
220 // session when it is still in used by other instances of this object. | |
221 // Member is static to ensure that the value is counted for all instances | |
222 // and not per instance. | |
223 static int audio_session_activation_count_; | |
pbos-webrtc
2015/11/18 12:54:22
Put GUARDED_BY(lock_) between "count_" and ";"
henrika_webrtc
2015/11/18 16:05:32
Done.
| |
224 | |
225 // Protects |audio_session_activation_count_|. | |
226 static rtc::GlobalLockPod lock_; | |
227 | |
214 // Ensures that methods are called from the same thread as this object is | 228 // Ensures that methods are called from the same thread as this object is |
215 // created on. | 229 // created on. |
216 rtc::ThreadChecker thread_checker_; | 230 rtc::ThreadChecker thread_checker_; |
217 | 231 |
218 // Raw pointer handle provided to us in AttachAudioBuffer(). Owned by the | 232 // Raw pointer handle provided to us in AttachAudioBuffer(). Owned by the |
219 // AudioDeviceModuleImpl class and called by AudioDeviceModuleImpl::Create(). | 233 // AudioDeviceModuleImpl class and called by AudioDeviceModuleImpl::Create(). |
220 // The AudioDeviceBuffer is a member of the AudioDeviceModuleImpl instance | 234 // The AudioDeviceBuffer is a member of the AudioDeviceModuleImpl instance |
221 // and therefore outlives this object. | 235 // and therefore outlives this object. |
222 AudioDeviceBuffer* audio_device_buffer_; | 236 AudioDeviceBuffer* audio_device_buffer_; |
223 | 237 |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
286 void* audio_interruption_observer_; | 300 void* audio_interruption_observer_; |
287 void* route_change_observer_; | 301 void* route_change_observer_; |
288 | 302 |
289 // Contains the audio data format specification for a stream of audio. | 303 // Contains the audio data format specification for a stream of audio. |
290 AudioStreamBasicDescription application_format_; | 304 AudioStreamBasicDescription application_format_; |
291 }; | 305 }; |
292 | 306 |
293 } // namespace webrtc | 307 } // namespace webrtc |
294 | 308 |
295 #endif // WEBRTC_MODULES_AUDIO_DEVICE_IOS_AUDIO_DEVICE_IOS_H_ | 309 #endif // WEBRTC_MODULES_AUDIO_DEVICE_IOS_AUDIO_DEVICE_IOS_H_ |
OLD | NEW |