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

Side by Side Diff: webrtc/modules/audio_device/ios/audio_device_ios.h

Issue 1435293003: Improved error handling in iOS ADM to avoid race during init (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Fine tuned audio session deactivation scheme Created 5 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
OLDNEW
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
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 // a BT headset is enabled or disabled. 177 // a BT headset is enabled or disabled.
178 bool RestartAudioUnitWithNewFormat(float sample_rate); 178 bool RestartAudioUnitWithNewFormat(float sample_rate);
179 179
180 // Activates our audio session, creates and initializes the voice-processing 180 // Activates our audio session, creates and initializes the voice-processing
181 // audio unit and verifies that we got the preferred native audio parameters. 181 // audio unit and verifies that we got the preferred native audio parameters.
182 bool InitPlayOrRecord(); 182 bool InitPlayOrRecord();
183 183
184 // Closes and deletes the voice-processing I/O unit. 184 // Closes and deletes the voice-processing I/O unit.
185 bool ShutdownPlayOrRecord(); 185 bool ShutdownPlayOrRecord();
186 186
187 // Helper method for destroying the existing audio unit.
188 void DisposeAudioUnit();
189
187 // Callback function called on a real-time priority I/O thread from the audio 190 // 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. 191 // unit. This method is used to signal that recorded audio is available.
189 static OSStatus RecordedDataIsAvailable( 192 static OSStatus RecordedDataIsAvailable(
190 void* in_ref_con, 193 void* in_ref_con,
191 AudioUnitRenderActionFlags* io_action_flags, 194 AudioUnitRenderActionFlags* io_action_flags,
192 const AudioTimeStamp* time_stamp, 195 const AudioTimeStamp* time_stamp,
193 UInt32 in_bus_number, 196 UInt32 in_bus_number,
194 UInt32 in_number_frames, 197 UInt32 in_number_frames,
195 AudioBufferList* io_data); 198 AudioBufferList* io_data);
196 OSStatus OnRecordedDataIsAvailable( 199 OSStatus OnRecordedDataIsAvailable(
197 AudioUnitRenderActionFlags* io_action_flags, 200 AudioUnitRenderActionFlags* io_action_flags,
198 const AudioTimeStamp* time_stamp, 201 const AudioTimeStamp* time_stamp,
199 UInt32 in_bus_number, 202 UInt32 in_bus_number,
200 UInt32 in_number_frames); 203 UInt32 in_number_frames);
201 204
202 // Callback function called on a real-time priority I/O thread from the audio 205 // 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. 206 // unit. This method is used to provide audio samples to the audio unit.
204 static OSStatus GetPlayoutData(void* in_ref_con, 207 static OSStatus GetPlayoutData(void* in_ref_con,
205 AudioUnitRenderActionFlags* io_action_flags, 208 AudioUnitRenderActionFlags* io_action_flags,
206 const AudioTimeStamp* time_stamp, 209 const AudioTimeStamp* time_stamp,
207 UInt32 in_bus_number, 210 UInt32 in_bus_number,
208 UInt32 in_number_frames, 211 UInt32 in_number_frames,
209 AudioBufferList* io_data); 212 AudioBufferList* io_data);
210 OSStatus OnGetPlayoutData(AudioUnitRenderActionFlags* io_action_flags, 213 OSStatus OnGetPlayoutData(AudioUnitRenderActionFlags* io_action_flags,
211 UInt32 in_number_frames, 214 UInt32 in_number_frames,
212 AudioBufferList* io_data); 215 AudioBufferList* io_data);
213 216
217 static volatile int object_count_;
tkchin_webrtc 2015/11/16 21:30:08 nit: Add comment for what this is used for and why
henrika_webrtc 2015/11/17 14:46:11 Done.
218
214 // Ensures that methods are called from the same thread as this object is 219 // Ensures that methods are called from the same thread as this object is
215 // created on. 220 // created on.
216 rtc::ThreadChecker thread_checker_; 221 rtc::ThreadChecker thread_checker_;
217 222
218 // Raw pointer handle provided to us in AttachAudioBuffer(). Owned by the 223 // Raw pointer handle provided to us in AttachAudioBuffer(). Owned by the
219 // AudioDeviceModuleImpl class and called by AudioDeviceModuleImpl::Create(). 224 // AudioDeviceModuleImpl class and called by AudioDeviceModuleImpl::Create().
220 // The AudioDeviceBuffer is a member of the AudioDeviceModuleImpl instance 225 // The AudioDeviceBuffer is a member of the AudioDeviceModuleImpl instance
221 // and therefore outlives this object. 226 // and therefore outlives this object.
222 AudioDeviceBuffer* audio_device_buffer_; 227 AudioDeviceBuffer* audio_device_buffer_;
223 228
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
286 void* audio_interruption_observer_; 291 void* audio_interruption_observer_;
287 void* route_change_observer_; 292 void* route_change_observer_;
288 293
289 // Contains the audio data format specification for a stream of audio. 294 // Contains the audio data format specification for a stream of audio.
290 AudioStreamBasicDescription application_format_; 295 AudioStreamBasicDescription application_format_;
291 }; 296 };
292 297
293 } // namespace webrtc 298 } // namespace webrtc
294 299
295 #endif // WEBRTC_MODULES_AUDIO_DEVICE_IOS_AUDIO_DEVICE_IOS_H_ 300 #endif // WEBRTC_MODULES_AUDIO_DEVICE_IOS_AUDIO_DEVICE_IOS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698