| 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 |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 148 void ClearPlayoutWarning() override {} | 148 void ClearPlayoutWarning() override {} |
| 149 void ClearPlayoutError() override {} | 149 void ClearPlayoutError() override {} |
| 150 void ClearRecordingWarning() override {} | 150 void ClearRecordingWarning() override {} |
| 151 void ClearRecordingError() override {} | 151 void ClearRecordingError() override {} |
| 152 | 152 |
| 153 private: | 153 private: |
| 154 // Uses current |playout_parameters_| and |record_parameters_| to inform the | 154 // Uses current |playout_parameters_| and |record_parameters_| to inform the |
| 155 // audio device buffer (ADB) about our internal audio parameters. | 155 // audio device buffer (ADB) about our internal audio parameters. |
| 156 void UpdateAudioDeviceBuffer(); | 156 void UpdateAudioDeviceBuffer(); |
| 157 | 157 |
| 158 // Registers observers for the AVAudioSessionRouteChangeNotification and |
| 159 // AVAudioSessionInterruptionNotification notifications. |
| 160 void RegisterNotificationObservers(); |
| 161 void UnregisterNotificationObservers(); |
| 162 |
| 158 // Since the preferred audio parameters are only hints to the OS, the actual | 163 // Since the preferred audio parameters are only hints to the OS, the actual |
| 159 // values may be different once the AVAudioSession has been activated. | 164 // values may be different once the AVAudioSession has been activated. |
| 160 // This method asks for the current hardware parameters and takes actions | 165 // This method asks for the current hardware parameters and takes actions |
| 161 // if they should differ from what we have asked for initially. It also | 166 // if they should differ from what we have asked for initially. It also |
| 162 // defines |playout_parameters_| and |record_parameters_|. | 167 // defines |playout_parameters_| and |record_parameters_|. |
| 163 void SetupAudioBuffersForActiveAudioSession(); | 168 void SetupAudioBuffersForActiveAudioSession(); |
| 164 | 169 |
| 165 // Creates a Voice-Processing I/O unit and configures it for full-duplex | 170 // Creates a Voice-Processing I/O unit and configures it for full-duplex |
| 166 // audio. The selected stream format is selected to avoid internal resampling | 171 // audio. The selected stream format is selected to avoid internal resampling |
| 167 // and to match the 10ms callback rate for WebRTC as well as possible. | 172 // and to match the 10ms callback rate for WebRTC as well as possible. |
| 168 // This method also initializes the created audio unit. | 173 // This method also initializes the created audio unit. |
| 169 bool SetupAndInitializeVoiceProcessingAudioUnit(); | 174 bool SetupAndInitializeVoiceProcessingAudioUnit(); |
| 170 | 175 |
| 176 // Restarts active audio streams using a new sample rate. Required when e.g. |
| 177 // a BT headset is enabled or disabled. |
| 178 bool RestartAudioUnitWithNewFormat(float sample_rate); |
| 179 |
| 171 // Activates our audio session, creates and initializes the voice-processing | 180 // Activates our audio session, creates and initializes the voice-processing |
| 172 // 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. |
| 173 bool InitPlayOrRecord(); | 182 bool InitPlayOrRecord(); |
| 174 | 183 |
| 175 // Closes and deletes the voice-processing I/O unit. | 184 // Closes and deletes the voice-processing I/O unit. |
| 176 bool ShutdownPlayOrRecord(); | 185 bool ShutdownPlayOrRecord(); |
| 177 | 186 |
| 178 // Callback function called on a real-time priority I/O thread from the audio | 187 // Callback function called on a real-time priority I/O thread from the audio |
| 179 // unit. This method is used to signal that recorded audio is available. | 188 // unit. This method is used to signal that recorded audio is available. |
| 180 static OSStatus RecordedDataIsAvailable( | 189 static OSStatus RecordedDataIsAvailable( |
| (...skipping 14 matching lines...) Expand all Loading... |
| 195 static OSStatus GetPlayoutData(void* in_ref_con, | 204 static OSStatus GetPlayoutData(void* in_ref_con, |
| 196 AudioUnitRenderActionFlags* io_action_flags, | 205 AudioUnitRenderActionFlags* io_action_flags, |
| 197 const AudioTimeStamp* time_stamp, | 206 const AudioTimeStamp* time_stamp, |
| 198 UInt32 in_bus_number, | 207 UInt32 in_bus_number, |
| 199 UInt32 in_number_frames, | 208 UInt32 in_number_frames, |
| 200 AudioBufferList* io_data); | 209 AudioBufferList* io_data); |
| 201 OSStatus OnGetPlayoutData(AudioUnitRenderActionFlags* io_action_flags, | 210 OSStatus OnGetPlayoutData(AudioUnitRenderActionFlags* io_action_flags, |
| 202 UInt32 in_number_frames, | 211 UInt32 in_number_frames, |
| 203 AudioBufferList* io_data); | 212 AudioBufferList* io_data); |
| 204 | 213 |
| 205 private: | |
| 206 // Ensures that methods are called from the same thread as this object is | 214 // Ensures that methods are called from the same thread as this object is |
| 207 // created on. | 215 // created on. |
| 208 rtc::ThreadChecker thread_checker_; | 216 rtc::ThreadChecker thread_checker_; |
| 209 | 217 |
| 210 // Raw pointer handle provided to us in AttachAudioBuffer(). Owned by the | 218 // Raw pointer handle provided to us in AttachAudioBuffer(). Owned by the |
| 211 // AudioDeviceModuleImpl class and called by AudioDeviceModuleImpl::Create(). | 219 // AudioDeviceModuleImpl class and called by AudioDeviceModuleImpl::Create(). |
| 212 // The AudioDeviceBuffer is a member of the AudioDeviceModuleImpl instance | 220 // The AudioDeviceBuffer is a member of the AudioDeviceModuleImpl instance |
| 213 // and therefore outlives this object. | 221 // and therefore outlives this object. |
| 214 AudioDeviceBuffer* audio_device_buffer_; | 222 AudioDeviceBuffer* audio_device_buffer_; |
| 215 | 223 |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 269 bool initialized_; | 277 bool initialized_; |
| 270 | 278 |
| 271 // Set to true after successful call to InitRecording(), false otherwise. | 279 // Set to true after successful call to InitRecording(), false otherwise. |
| 272 bool rec_is_initialized_; | 280 bool rec_is_initialized_; |
| 273 | 281 |
| 274 // Set to true after successful call to InitPlayout(), false otherwise. | 282 // Set to true after successful call to InitPlayout(), false otherwise. |
| 275 bool play_is_initialized_; | 283 bool play_is_initialized_; |
| 276 | 284 |
| 277 // Audio interruption observer instance. | 285 // Audio interruption observer instance. |
| 278 void* audio_interruption_observer_; | 286 void* audio_interruption_observer_; |
| 287 void* route_change_observer_; |
| 288 |
| 289 // Contains the audio data format specification for a stream of audio. |
| 290 AudioStreamBasicDescription application_format_; |
| 279 }; | 291 }; |
| 280 | 292 |
| 281 } // namespace webrtc | 293 } // namespace webrtc |
| 282 | 294 |
| 283 #endif // WEBRTC_MODULES_AUDIO_DEVICE_IOS_AUDIO_DEVICE_IOS_H_ | 295 #endif // WEBRTC_MODULES_AUDIO_DEVICE_IOS_AUDIO_DEVICE_IOS_H_ |
| OLD | NEW |