Post not yet marked as solved
The voice call in our game has such a usage scenario: when the player does not wear the headset or Bluetooth, we use the VPIO mode to turn on the microphone. On the contrary, the player wears the headset or Bluetooth, and the remoteIO mode is used to turn on the microphone. So we have a switch between VPIO and RemoteIO。When we only use RemoteIO (the player has been wearing headphones or Bluetooth since the game), the output volume does not change before and after the microphone is switched on. When we only use the VPIO mode (the player has not been wearing headphones or Bluetooth since the game), before and after turning on the microphone, the output volume will reduce a little (because turning on the microphone will cause the phone to enter the VPIO and the echo cancellation will be turned on), the performance of the output volume in the above two scenarios is normal。However, when we switched between VPIO and RemotoIO (the player didn’t wear headphones or Bluetooth at the beginning, and brought headphones or Bluetooth in the middle of the game), we encountered some problems: As long as I have used VPIO mode before RemotoIO mode, the output volume in RemoteIO mode after turning on the microphone will be the same as in VPIO mode (normally the output volume in RemoteIO should be greater than in VPIO mode), turn off the microphone ,The output volume will become normal.What confuses me is: My understanding is that when we use RemoteIO, the mobile phone should not do some suppression-like speech algorithms, so when we only use RemoteIO, the output volume of the mobile phone does not change. When we use VPIO, the mobile phone will use echo Algorithms, and perhaps dynamic compression and some gain algorithm processing. At this time, the output volume will be reduced to better handle the echo. This behavior is normal. However, when I switch between VPIO and RemotIO, I feel that when I use RemoteIO (VPIO resources are released), some of the previous VPIO algorithm processing is still reserved (may be dynamic compression or gain algorithm), which finally leads to the output volume under RemoteIO is the same as that under VPIO, and this only happens on all of IOS14, the previous version is normal (anytime you enter the remoteIO mode, the volume does not change). I want to know, For IOS14 this behavior (VPIO and RemoteIO switching causes the volume of RemoteIO to decrease) is normal? If it is not normal, how can we solve it?
Post not yet marked as solved
From iOS 12.3 and above iOS versions we are getting AudioToolBox crashes, we do not know why these crashes are happening. We have Crashlytics Crash report but we are not able to debug the issue with the help of Crashlytics crash report.I have attached the Crashlytics crash report.Background of our application :Our application streams the video using RTSP url and VLC mobile kit. even when the application is sent to the background the streaming continues and the stream will try to reconnect when the stream disconnects due to some error.While streaming the video in the background we show the user a red bar on the user iPhone.We tried different scenarios to reproduce the issue some of them are1) we checked if it is happening when we receive a mobile call when the user is streaming2) We checked if interruptions from other streaming applications are causing the issue3) We checked if Siri or getting a face time call is creating the crashWe tried all the above mentioned in debugging, as well as release, buildsfind the crash report details belowJul 2019 11:18:45 GMT # Date: 2019-07-04T10:59:00Z # OS Version: 12.3.1 (16F203) # Device: iPhone 8 # RAM Free: 9.6% # Disk Free: 53.9% #22. Crashed: com.apple.coreaudio.auremoteio
0 AudioToolbox 0x18c489058 SampleRateConverter::SetProperty(unsigned int, unsigned int, void const*) + 192
1 AudioToolbox 0x18c669580 AudioConverterSetProperty + 96
2 AudioToolbox 0x18c51c638 AUConverterBase::SetupConverter(unsigned int, bool) + 1340
3 AudioToolbox 0x18c3fe948 AURemoteIO::SetupConverter(unsigned int, bool) + 224
4 AudioToolbox 0x18c51aed8 AUConverterBase::SetupAllConverters(bool, unsigned int) + 104
5 AudioToolbox 0x18c400a0c AURemoteIO::IOFormatsChanged(int) + 1420
6 AudioToolbox 0x18c402afc __AURIOCallbackReceiver_IOFormatsChanged_block_invoke + 96
7 libdispatch.dylib 0x187f80a38 _dispatch_call_block_and_release + 24
8 libdispatch.dylib 0x187f817d4 _dispatch_client_callout + 16
9 libdispatch.dylib 0x187f5cdec _dispatch_lane_serial_drain$VARIANT$armv81 + 548
10 libdispatch.dylib 0x187f5d92c _dispatch_lane_invoke$VARIANT$armv81 + 408
11 libdispatch.dylib 0x187f65e08 _dispatch_workloop_worker_thread + 584
12 libsystem_pthread.dylib 0x188161114 _pthread_wqthread + 304
13 libsystem_pthread.dylib 0x188163cd4 start_wqthread + 4
--
#0. com.apple.main-thread
0 AppName 0x101169978 _gnutls_ext_deinit + 417 (extensions.c:417)
1 AppName 0x10116f750 _gnutls_global_deinit + 416 (global.c:416)
2 (Missing) 0x1032313c0 (Missing)
3 (Missing) 0x10321a7b8 (Missing)
4 libsystem_c.dylib 0x188038bb4 __cxa_finalize_ranges + 384
5 libsystem_c.dylib 0x188038ec4 exit + 24
6 UIKitCore 0x1b4e4ed2c -[UIApplication terminateWithSuccess] + 466
7 UIKitCore 0x1b470adb4 __98-[__UICanvasLifecycleMonitor_Compatability deactivateEventsOnly:withContext:forceExit:completion:]_block_invoke.261 + 344
8 UIKitCore 0x1b4e52dec _runAfterCACommitDeferredBlocks + 296
9 UIKitCore 0x1b4e4193c _cleanUpAfterCAFlushAndRunDeferredBlocks + 352
10 UIKitCore 0x1b4e6e7ac _afterCACommitHandler + 116
11 CoreFoundation 0x1884d25f8 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 32
12 CoreFoundation 0x1884cd320 __CFRunLoopDoObservers + 412
13 CoreFoundation 0x1884cd89c __CFRunLoopRun + 1228
14 CoreFoundation 0x1884cd0b0 CFRunLoopRunSpecific + 436
15 GraphicsServices 0x18a6cd79c GSEventRunModal + 104
16 UIKitCore 0x1b4e47978 UIApplicationMain + 212
17 AppName 0x1007fd1f4 main + 24 (AppDelegate.swift:24)
18 libdyld.dylib 0x187f928e0 start + 4
#1. com.apple.uikit.eventfetch-thread
0 libsystem_kernel.dylib 0x1880d30f4 mach_msg_trap + 8
1 libsystem_kernel.dylib 0x1880d25a0 mach_msg + 72
2 CoreFoundation 0x1884d2a10 __CFRunLoopServiceMachPort + 236
3 CoreFoundation 0x1884cd920 __CFRunLoopRun + 1360
4 CoreFoundation 0x1884cd0b0 CFRunLoopRunSpecific + 436
5 Foundation 0x188e9afac -[NSRunLoop(NSRunLoop) runMode:beforeDate:] + 300
6 Foundation 0x188e9ae3c -[NSRunLoop(NSRunLoop) runUntilDate:] + 96
7 UIKitCore 0x1b4f2d494 -[UIEventFetcher threadMain] + 136
8 Foundation 0x188fc76a4 __NSThread__start__ + 984
9 libsystem_pthread.dylib 0x1881602c0 _pthread_body + 128
10 libsystem_pthread.dylib 0x188160220 _pthread_start + 44
11 libsystem_pthread.dylib 0x188163cdc thread_start + 4
#2. GAIThread
0 libsystem_kernel.dylib 0x1880d30f4 mach_msg_trap + 8
1 libsystem_kernel.dylib 0x1880d25a0 mach_msg + 72
2 CoreFoundation 0x1884d2a10 __CFRunLoopServiceMachPort + 236
3 CoreFoundation 0x1884cd920 __CFRunLoopRun + 1360
4 CoreFoundation 0x1884cd0b0 CFRunLoopRunSpecific + 436
5 Foundation 0x188e9afac -[NSRunLoop(NSRunLoop) runMode:beforeDate:] + 300
6 Foundation 0x188ed646c -[NSRunLoop(NSRunLoop) run] + 88
7 AppName 0x100bc9d14 +[GAI threadMain:] + 4345896212
8 Foundation 0x188fc76a4 __NSThread__start__ + 984
9 libsystem_pthread.dylib 0x1881602c0 _pthread_body + 128
10 libsystem_pthread.dylib 0x188160220 _pthread_start + 44
11 libsystem_pthread.dylib 0x188163cdc thread_start + 4
#3. com.apple.CFSocket.private
0 libsystem_kernel.dylib 0x1880de328 __select + 8
1 CoreFoundation 0x1884db6f4 __CFSocketManager + 620
2 libsystem_pthread.dylib 0x1881602c0 _pthread_body + 128
3 libsystem_pthread.dylib 0x188160220 _pthread_start + 44
4 libsystem_pthread.dylib 0x188163cdc thread_start + 4
#4. com.twitter.crashlytics.ios.MachExceptionServer
0 AppName 0x100aded58 CLSProcessRecordAllThreads + 4344933720
1 AppName 0x100adf140 CLSProcessRecordAllThreads + 4344934720
2 AppName 0x100ace9bc CLSHandler + 4344867260
3 AppName 0x100ac9d9c CLSMachExceptionServer + 4344847772
4 libsystem_pthread.dylib 0x1881602c0 _pthread_body + 128
5 libsystem_pthread.dylib 0x188160220 _pthread_start + 44
6 libsystem_pthread.dylib 0x188163cdc thread_start + 4
#5. AVAudioSession Notify Thread
0 libsystem_kernel.dylib 0x1880d30f4 mach_msg_trap + 8
1 libsystem_kernel.dylib 0x1880d25a0 mach_msg + 72
2 CoreFoundation 0x1884d2a10 __CFRunLoopServiceMachPort + 236
3 CoreFoundation 0x1884cd920 __CFRunLoopRun + 1360
4 CoreFoundation 0x1884cd0b0 CFRunLoopRunSpecific + 436
5 AVFAudio 0x18e3b5334 GenericRunLoopThread::Entry(void*) + 156
6 AVFAudio 0x18e3dfc60 CAPThread::Entry(CAPThread*) + 88
7 libsystem_pthread.dylib 0x1881602c0 _pthread_body + 128
8 libsystem_pthread.dylib 0x188160220 _pthread_start + 44
9 libsystem_pthread.dylib 0x188163cdc thread_start + 4
#6. com.apple.NSURLConnectionLoader
0 libsystem_kernel.dylib 0x1880d30f4 mach_msg_trap + 8
1 libsystem_kernel.dylib 0x1880d25a0 mach_msg + 72
2 CoreFoundation 0x1884d2a10 __CFRunLoopServiceMachPort + 236
3 CoreFoundation 0x1884cd920 __CFRunLoopRun + 1360
4 CoreFoundation 0x1884cd0b0 CFRunLoopRunSpecific + 436
5 CFNetwork 0x188ae674c -[__CoreSchedulingSetRunnable runForever] + 216
6 Foundation 0x188fc76a4 __NSThread__start__ + 984
7 libsystem_pthread.dylib 0x1881602c0 _pthread_body + 128
8 libsystem_pthread.dylib 0x188160220 _pthread_start + 44
9 libsystem_pthread.dylib 0x188163cdc thread_start + 4
#7. Thread
0 libsystem_kernel.dylib 0x1880dffd8 poll + 8
1 CustomSDK 0x103661de8 _lws_plat_service_tsi + 236
2 CustomSDK 0x1036a3554 websocket_worker + 60
3 libsystem_pthread.dylib 0x1881602c0 _pthread_body + 128
4 libsystem_pthread.dylib 0x188160220 _pthread_start + 44
5 libsystem_pthread.dylib 0x188163cdc thread_start + 4
#8. Thread
0 libsystem_kernel.dylib 0x1880de9d4 __ulock_wait + 8
1 libdispatch.dylib 0x187f50c20 _dispatch_ulock_wait + 56
2 libdispatch.dylib 0x187f50d58 _dispatch_thread_event_wait_slow$VARIANT$armv81 + 48
3 libdispatch.dylib 0x187f628a8 __DISPATCH_WAIT_FOR_QUEUE__ + 336
4 libdispatch.dylib 0x187f624a8 _dispatch_sync_f_slow + 140
5 AppName 0x100c397e0 -[VLCEventManager startEventLoop] + 220 (VLCEventManager.m:220)
6 AppName 0x100c3916c EventDispatcherMainLoop + 97 (VLCEventManager.m:97)
7 libsystem_pthread.dylib 0x1881602c0 _pthread_body + 128
8 libsystem_pthread.dylib 0x188160220 _pthread_start + 44
9 libsystem_pthread.dylib 0x188163cdc thread_start + 4
#9. Thread
0 libsystem_kernel.dylib 0x1880d30f4 mach_msg_trap + 8
1 libsystem_kernel.dylib 0x1880d25a0 mach_msg + 72
2 CoreFoundation 0x1884d2a10 __CFRunLoopServiceMachPort + 236
3 CoreFoundation 0x1884cd920 __CFRunLoopRun + 1360
4 CoreFoundation 0x1884cd0b0 CFRunLoopRunSpecific + 436
5 CustomSDK 0x103634e60 -[P2PCamera worker] + 88
6 Foundation 0x188fc76a4 __NSThread__start__ + 984
7 libsystem_pthread.dylib 0x1881602c0 _pthread_body + 128
8 libsystem_pthread.dylib 0x188160220 _pthread_start + 44
9 libsystem_pthread.dylib 0x188163cdc thread_start + 4
#10. Thread
0 libsystem_kernel.dylib 0x1880de328 __select + 8
1 CustomSDK 0x103776534 pj_sock_select + 84
2 CustomSDK 0x103772340 pj_ioqueue_poll + 196
3 CustomSDK 0x103699bc4 _pjice_worker_thread + 172
4 CustomSDK 0x10377329c thread_main + 84
5 libsystem_pthread.dylib 0x1881602c0 _pthread_body + 128
6 libsystem_pthread.dylib 0x188160220 _pthread_start + 44
7 libsystem_pthread.dylib 0x188163cdc thread_start + 4
#11. Thread
0 libsystem_kernel.dylib 0x1880de328 __select + 8
1 CustomSDK 0x103776534 pj_sock_select + 84
2 CustomSDK 0x103772340 pj_ioqueue_poll + 196
3 CustomSDK 0x103699bc4 _pjice_worker_thread + 172
4 CustomSDK 0x10377329c thread_main + 84
5 libsystem_pthread.dylib 0x1881602c0 _pthread_body + 128
6 libsystem_pthread.dylib 0x188160220 _pthread_start + 44
7 libsystem_pthread.dylib 0x188163cdc thread_start + 4
#12. Thread
0 libsystem_kernel.dylib 0x1880de328 __select + 8
1 CustomSDK 0x103776534 pj_sock_select + 84
2 CustomSDK 0x103772340 pj_ioqueue_poll + 196
3 CustomSDK 0x103699bc4 _pjice_worker_thread + 172
4 CustomSDK 0x10377329c thread_main + 84
5 libsystem_pthread.dylib 0x1881602c0 _pthread_body + 128
6 libsystem_pthread.dylib 0x188160220 _pthread_start + 44
7 libsystem_pthread.dylib 0x188163cdc thread_start + 4
#13. Thread
0 libsystem_kernel.dylib 0x1880de400 __semwait_signal + 8
1 libsystem_c.dylib 0x18805556c nanosleep + 212
2 libsystem_c.dylib 0x18805536c sleep + 44
3 CustomSDK 0x103697a08 _port_forward_conn_thread + 132
4 libsystem_pthread.dylib 0x1881602c0 _pthread_body + 128
5 libsystem_pthread.dylib 0x188160220 _pthread_start + 44
6 libsystem_pthread.dylib 0x188163cdc thread_start + 4
#14. Thread
0 libsystem_kernel.dylib 0x1880de328 __select + 8
1 CustomSDK 0x103697e88 _port_forward_io_thread + 740
2 libsystem_pthread.dylib 0x1881602c0 _pthread_body + 128
3 libsystem_pthread.dylib 0x188160220 _pthread_start + 44
4 libsystem_pthread.dylib 0x188163cdc thread_start + 4
#15. Thread
0 libsystem_kernel.dylib 0x1880de328 __select + 8
1 AppName 0x101be7740 BasicTaskScheduler::SingleStep(unsigned int) + 91 (BasicTaskScheduler.cpp:91)
2 AppName 0x101be70d0 BasicTaskScheduler0::doEventLoop(char volatile*) + 79 (BasicTaskScheduler0.cpp:79)
3 AppName 0x101d6086c Demux(demux_t*) + 1420 (live555.cpp:1420)
4 libsystem_pthread.dylib 0x188160220 _pthread_start + 44
5 libsystem_pthread.dylib 0x188163cdc thread_start + 4
#16. Thread
0 libsystem_kernel.dylib 0x1880ddee4 __psynch_cvwait + 8
1 libsystem_pthread.dylib 0x18815d4d8 _pthread_cond_wait$VARIANT$armv81 + 680
2 AppName 0x100cc08a8 vlc_cond_timedwait + 263 (thread.c:263)
3 AppName 0x100cbff40 vlc_timer_thread + 85 (timer.c:85)
4 libsystem_pthread.dylib 0x1881602c0 _pthread_body + 128
5 libsystem_pthread.dylib 0x188160220 _pthread_start + 44
6 libsystem_pthread.dylib 0x188163cdc thread_start + 4
#17. Thread
0 libsystem_kernel.dylib 0x1880d3130 semaphore_wait_trap + 8
1 AppName 0x100c93ad4 aout_DecPlay + 212 (dec.c:212)
2 libsystem_pthread.dylib 0x188160220 _pthread_start + 44
3 libsystem_pthread.dylib 0x188163cdc thread_start + 4
#18. Thread
0 libsystem_kernel.dylib 0x1880ddee4 __psynch_cvwait + 8
1 libsystem_pthread.dylib 0x18815d4a4 _pthread_cond_wait$VARIANT$armv81 + 628
2 AppName 0x100c78220 DecoderThread + 1596 (decoder.c:1596)
3 libsystem_pthread.dylib 0x188160220 _pthread_start + 44
4 libsystem_pthread.dylib 0x188163cdc thread_start + 4
#19. AURemoteIO::IOThread
0 libsystem_kernel.dylib 0x1880d30f4 mach_msg_trap + 8
1 libsystem_kernel.dylib 0x1880d25a0 mach_msg + 72
2 AudioToolbox 0x18c401890 AURemoteIO::IOThread::Run() + 256
3 AudioToolbox 0x18c406800 AURemoteIO::IOThread::Entry(void*) + 76
4 AudioToolbox 0x18c7d94f8 CAPThread::Entry(CAPThread*) + 88
5 libsystem_pthread.dylib 0x1881602c0 _pthread_body + 128
6 libsystem_pthread.dylib 0x188160220 _pthread_start + 44
7 libsystem_pthread.dylib 0x188163cdc thread_start + 4
#20. Thread
0 libsystem_kernel.dylib 0x1880deb74 __workq_kernreturn + 8
1 libsystem_pthread.dylib 0x1881611f8 _pthread_wqthread + 532
2 libsystem_pthread.dylib 0x188163cd4 start_wqthread + 4
#21. Thread
0 libsystem_kernel.dylib 0x1880deb74 __workq_kernreturn + 8
1 libsystem_pthread.dylib 0x188161138 _pthread_wqthread + 340
2 libsystem_pthread.dylib 0x188163cd4 start_wqthread + 4
#22. Crashed: com.apple.coreaudio.auremoteio
0 AudioToolbox 0x18c489058 SampleRateConverter::SetProperty(unsigned int, unsigned int, void const*) + 192
1 AudioToolbox 0x18c669580 AudioConverterSetProperty + 96
2 AudioToolbox 0x18c51c638 AUConverterBase::SetupConverter(unsigned int, bool) + 1340
3 AudioToolbox 0x18c3fe948 AURemoteIO::SetupConverter(unsigned int, bool) + 224
4 AudioToolbox 0x18c51aed8 AUConverterBase::SetupAllConverters(bool, unsigned int) + 104
5 AudioToolbox 0x18c400a0c AURemoteIO::IOFormatsChanged(int) + 1420
6 AudioToolbox 0x18c402afc __AURIOCallbackReceiver_IOFormatsChanged_block_invoke + 96
7 libdispatch.dylib 0x187f80a38 _dispatch_call_block_and_release + 24
8 libdispatch.dylib 0x187f817d4 _dispatch_client_callout + 16
9 libdispatch.dylib 0x187f5cdec _dispatch_lane_serial_drain$VARIANT$armv81 + 548
10 libdispatch.dylib 0x187f5d92c _dispatch_lane_invoke$VARIANT$armv81 + 408
11 libdispatch.dylib 0x187f65e08 _dispatch_workloop_worker_thread + 584
12 libsystem_pthread.dylib 0x188161114 _pthread_wqthread + 304
13 libsystem_pthread.dylib 0x188163cd4 start_wqthread + 4
#23. Thread
0 libsystem_kernel.dylib 0x1880deb74 __workq_kernreturn + 8
1 libsystem_pthread.dylib 0x188161138 _pthread_wqthread + 340
2 libsystem_pthread.dylib 0x188163cd4 start_wqthread + 4
#24. Thread
0 libsystem_kernel.dylib 0x1880deb74 __workq_kernreturn + 8
1 libsystem_pthread.dylib 0x1881611f8 _pthread_wqthread + 532
2 libsystem_pthread.dylib 0x188163cd4 start_wqthread + 4
#25. Thread
0 libsystem_kernel.dylib 0x1880deb74 __workq_kernreturn + 8
1 libsystem_pthread.dylib 0x1881611f8 _pthread_wqthread + 532
2 libsystem_pthread.dylib 0x188163cd4 start_wqthread + 4
#26. AURemoteIO::IOThread
0 libsystem_kernel.dylib 0x1880d30f4 mach_msg_trap + 8
1 libsystem_kernel.dylib 0x1880d25a0 mach_msg + 72
2 AudioToolbox 0x18c401890 AURemoteIO::IOThread::Run() + 256
3 AudioToolbox 0x18c406800 AURemoteIO::IOThread::Entry(void*) + 76
4 AudioToolbox 0x18c7d94f8 CAPThread::Entry(CAPThread*) + 88
5 libsystem_pthread.dylib 0x1881602c0 _pthread_body + 128
6 libsystem_pthread.dylib 0x188160220 _pthread_start + 44
7 libsystem_pthread.dylib 0x188163cdc thread_start + 4
Post not yet marked as solved
I have an AVMutableAudioMix and use MTAudioProcessingTap to process the audio data.But After I pass the buffer to AVAudioEngine and to render it with renderOffline,the audio has no any effects...How can I do it? Any idea?
Here is the code for MTAudioProcessingTapProcessCallback
var callback = MTAudioProcessingTapCallbacks(version: kMTAudioProcessingTapCallbacksVersion_0, clientInfo:UnsafeMutableRawPointer(Unmanaged.passUnretained(self.engine).toOpaque()), init: tapInit, finalize: tapFinalize, prepare: tapPrepare, unprepare: tapUnprepare) { tap, numberFrames, flags, bufferListInOut, numberFramesOut, flagsOut in
guard MTAudioProcessingTapGetSourceAudio(tap, numberFrames, bufferListInOut, flagsOut, nil, numberFramesOut) == noErr else {
preconditionFailure()
}
let storage = MTAudioProcessingTapGetStorage(tap)
let engine = Unmanaged<Engine>.fromOpaque(storage).takeUnretainedValue()
// render the audio with effect
engine.render(bufferPtr: bufferListInOut,numberOfFrames: numberFrames)
}
And here is the Engine code
class Engine {
let engine = AVAudioEngine()
let player = AVAudioPlayerNode()
let pitchEffect = AVAudioUnitTimePitch()
let reverbEffect = AVAudioUnitReverb()
let rateEffect = AVAudioUnitVarispeed()
let volumeEffect = AVAudioUnitEQ()
let format = AVAudioFormat(commonFormat: .pcmFormatFloat32, sampleRate: 44100, channels: 2, interleaved: false)!
init() {
engine.attach(player)
engine.attach(pitchEffect)
engine.attach(reverbEffect)
engine.attach(rateEffect)
engine.attach(volumeEffect)
engine.connect(player, to: pitchEffect, format: format)
engine.connect(pitchEffect, to: reverbEffect, format: format)
engine.connect(reverbEffect, to: rateEffect, format: format)
engine.connect(rateEffect, to: volumeEffect, format: format)
engine.connect(volumeEffect, to: engine.mainMixerNode, format: format)
try! engine.enableManualRenderingMode(.offline, format: format, maximumFrameCount: 4096)
reverbEffect.loadFactoryPreset(AVAudioUnitReverbPreset.largeRoom2)
reverbEffect.wetDryMix = 100
pitchEffect.pitch = 2100
try! engine.start()
player.play()
}
func render(bufferPtr:UnsafeMutablePointer<AudioBufferList>,numberOfFrames:CMItemCount) {
let buffer = AVAudioPCMBuffer(pcmFormat: format, frameCapacity: 4096)!
buffer.frameLength = AVAudioFrameCount(numberOfFrames)
buffer.mutableAudioBufferList.pointee = bufferPtr.pointee
self.player.scheduleBuffer(buffer) {
try! self.engine.renderOffline(AVAudioFrameCount(numberOfFrames), to: buffer)
}
}
}
I wrote the code below to pass my custom object Engine in MTAudioProcessingTapCallbacks
Here is code:
func getTap() -> MTAudioProcessingTap? {
var tap: Unmanaged<MTAudioProcessingTap>?
func onInit(tap:MTAudioProcessingTap,clientInfo:UnsafeMutableRawPointer?,tagStroageOut:UnsafeMutablePointer<UnsafeMutableRawPointer?>) {
let engine = Engine()
tagStroageOut.pointee = Unmanaged<Engine>.passUnretained(engine).toOpaque()
}
var callback = MTAudioProcessingTapCallbacks(version: kMTAudioProcessingTapCallbacksVersion_0, clientInfo:nil, init: onInit, finalize: nil, prepare: nil, unprepare: nil) { tap, numberFrames, flags, bufferListInOut, numberFramesOut, flagsOut in
guard MTAudioProcessingTapGetSourceAudio(tap, numberFrames, bufferListInOut, flagsOut, nil, numberFramesOut) == noErr else {
preconditionFailure()
}
let storage = MTAudioProcessingTapGetStorage(tap)
let engine = Unmanaged<Engine>.fromOpaque(storage).takeUnretainedValue()
// This line crashed :
// ClientProcessingTapManager (14): EXC_BAD_ACCESS (code=1, address=0x544453e46ea0)
engine.dealWith(bufferPtr: bufferListInOut)
}
guard MTAudioProcessingTapCreate(kCFAllocatorDefault, &callback, kMTAudioProcessingTapCreationFlag_PostEffects, &tap) == noErr else{
fatalError()
}
return tap?.takeRetainedValue()
}
}
How can I do it?
Post not yet marked as solved
I have an AVAudioEngine,but I don't know how to export the audio in AVAudioEngine to a file. Anyone can help?
Post not yet marked as solved
I'm trying to play an audio content built from NSData inside a library (.a). It works properly when my code is inside an app. But it is not working when in a library, I get no error and no sound playing.
NSError * errorAudio = nil;
NSError * errorFile;
// Clear all cache
NSArray* tmpDirectory = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:NSTemporaryDirectory() error:NULL];
for (NSString *file in tmpDirectory) {
[[NSFileManager defaultManager] removeItemAtPath:[NSString stringWithFormat:@"%@%@", NSTemporaryDirectory(), file] error:NULL];
}
// Set temporary directory and temporary file
NSURL * tmpDirURL = [NSURL fileURLWithPath:NSTemporaryDirectory() isDirectory:YES];
NSURL * soundFileURL = [[tmpDirURL URLByAppendingPathComponent:@"temp"] URLByAppendingPathExtension:@"wav"];
[[NSFileManager defaultManager] createDirectoryAtURL:tmpDirURL withIntermediateDirectories:NO attributes:nil error:&errorFile];
// Write NSData to temporary file
NSString *path= [soundFileURL path];
[audioToPlay writeToFile:path options:NSDataWritingAtomic error:&errorFile];
if (errorFile) {
// Error while writing NSData
} else {
// Init audio player
self.audioPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL:soundFileURL error:&errorAudio];
if (errorAudio) {
// Audio player could not be initialized
} else {
// Audio player was initialized correctly
[audioPlayer prepareToPlay];
[audioPlayer stop];
[audioPlayer setCurrentTime:0];
[audioPlayer play];
}
}
I don't check errorFile intros piece of code, but when debugging I can see that value is nil.
My header file
#import <AudioToolbox/AudioToolbox.h>
#import <AVFoundation/AVFoundation.h>
@property(nonatomic, strong) AVAudioPlayer * audioPlayer;
My m file
#import <AudioToolbox/AudioToolbox.h>
#import <AVFoundation/AVFoundation.h>
@synthesize audioPlayer;
I've been checking for dozens of posts but cannot find any solution, it always works properly in an app, but not in a library. Any help would be greatly appreciated.
Post not yet marked as solved
Why is there a tapping sound when I record audio in Garage Band? Same when I import and play an mp3 track. How can I stop it?
Post not yet marked as solved
When I use Audio Toolbox APIs to decode AAC audio, I am getting kAudioConverterErr_FormatNotSupported(1718449215) error. This works fine in BigSur(11.5.2) and previous versions.
prompt> ./ffmpeg -c:a aac_at -i audio24b_he_aac.aac -f s16le -acodec pcm_s16le output.pcm -v trace
ffmpeg version N-104401-gcd38fbf4f7 Copyright (c) 2000-2021 the FFmpeg developers
built with Apple clang version 13.0.0 (clang-1300.0.29.3)
configuration: --disable-x86asm
libavutil 57. 7.100 / 57. 7.100
libavcodec 59. 12.100 / 59. 12.100
libavformat 59. 6.100 / 59. 6.100
libavdevice 59. 0.101 / 59. 0.101
libavfilter 8. 15.100 / 8. 15.100
libswscale 6. 1.100 / 6. 1.100
libswresample 4. 0.100 / 4. 0.100
Splitting the commandline.
Reading option '-c:a' ... matched as option 'c' (codec name) with argument 'aac_at'.
Reading option '-i' ... matched as input url with argument 'audio24b_he_aac.aac'.
Reading option '-f' ... matched as option 'f' (force format) with argument 's16le'.
Reading option '-acodec' ... matched as option 'acodec' (force audio codec ('copy' to copy stream)) with argument 'pcm_s16le'.
Reading option 'output.pcm' ... matched as output url.
Reading option '-v' ... matched as option 'v' (set logging level) with argument 'trace'.
Finished splitting the commandline.
Parsing a group of options: global .
Applying option v (set logging level) with argument trace.
Successfully parsed a group of options.
Parsing a group of options: input url audio24b_he_aac.aac.
Applying option c:a (codec name) with argument aac_at.
Successfully parsed a group of options.
Opening an input file: audio24b_he_aac.aac.
[NULL @ 0x7f8cf4004d40] Opening 'audio24b_he_aac.aac' for reading
[file @ 0x7f8cf4005180] Setting default whitelist 'file,crypto,data'
Probing aac score:51 size:2048
[aac @ 0x7f8cf4004d40] Format aac probed with size=2048 and score=51
[aac @ 0x7f8cf4004d40] Before avformat_find_stream_info() pos: 0 bytes read:65696 seeks:4 nb_streams:1
[aac_at @ 0x7f8cf40057c0] AudioToolbox init error: 1718449215
[aac @ 0x7f8cf4004d40] All info found
[aac @ 0x7f8cf4004d40] Estimating duration from bitrate, this may be inaccurate
Following lines of code is failing.
status = AudioConverterNew(&in_format, &out_format, &at->converter);
if (status != 0) {
av_log(avctx, AV_LOG_ERROR, "AudioToolbox init error: %i\n", (int)status);
return AVERROR_UNKNOWN;
}
Is there any change with respect to these APIs in Monterey. I could not find any thing in the documentation or release notes.
Post not yet marked as solved
We are trying to record audio for time more than 6 hours. The app is working for 2 to 3 hours, but if I record it more than 4 or 5 hours, the recording is failing. I have. enough space on my device.We are using AVAudioRecorder.
Appreciate your help
Post not yet marked as solved
Good day community,
More than half a year we faced the crash with following callstack:
Crashed: AVAudioSession Notify Thread
EXC_BAD_ACCESS KERN_INVALID_ADDRESS 0x0000000000000000
0. libEmbeddedSystemAUs.dylib
InterruptionListener(void*, unsigned int, unsigned int, void const*)
1. libEmbeddedSystemAUs.dylib
InterruptionListener(void*, unsigned int, unsigned int, void const*)
arrow_right
2. AudioToolbox
AudioSessionPropertyListeners::CallPropertyListeners(unsigned int, unsigned int, void const*) + 596
3. AudioToolbox
HandleAudioSessionCFTypePropertyChangedMessage(unsigned int, unsigned int, void*, unsigned int) + 1144
4. AudioToolbox
ProcessDeferredMessage(unsigned int, __CFData const*, unsigned int, unsigned int) + 2452
5. AudioToolbox
ASCallbackReceiver_AudioSessionPingMessage + 632
6. AudioToolbox
_XAudioSessionPingMessage + 44
7. libAudioToolboxUtility.dylib
mshMIGPerform + 264
8. CoreFoundation
__CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 56
9. CoreFoundation
__CFRunLoopDoSource1 + 444
10. CoreFoundation
__CFRunLoopRun + 1888
11. CoreFoundation
CFRunLoopRunSpecific + 424
12. AVFAudio
GenericRunLoopThread::Entry(void*) + 156
13. AVFAudio
CAPThread::Entry(CAPThread*) + 204
14. libsystem_pthread.dylib
_pthread_start + 156
15. libsystem_pthread.dylib
thread_start + 8
We use Wwise audio framework as audio playback API. We did reported the problem to Audiokinetic's support, but it seems that the problem is not there.
Also we used FMOD sound engine earlier, but we had the same issue.
At this time we have around 100 crash events every day, which makes us upset. Looks like it started from iOS 13.
My main problem is that I don't communicate with AudioToolbox or AVFAudio API directly but use thirdparty sound engines instead.
I believe I am not the only who faced this problem.
Also there is a discussion at https://forum.unity.com/threads/ios-12-crash-audiotoolbox.719675/
The last message deserves special attention:
https://zhuanlan.zhihu.com/p/370791950
where Jeffrey Zhuang made a research. This might be helpful for Apple's support team.
Any help is highly appreciated.
Best regards,
Sergey.
Post not yet marked as solved
AudioUnit is kAudioUnitSubType_VoiceProcessingIO
ExceptionHandling 0x7fff3bde6f31 -[NSExceptionHandler _handleException:mask:] + 364
ExceptionHandling 0x7fff3bde6cac NSExceptionHandlerUncaughtSignalHandler + 35
libsystem_platform.dylib 0x7fff203bad7d _sigtramp + 29
0x0000000000000000 0x7000043de580 0x0 + 123145373476224
CoreAudio 0x7fff220a1ee9 _ZN9HALDevice4DuckEfPK14AudioTimeStampf + 921
CoreAudio 0x7fff21c08598 AudioDeviceDuck + 843
AudioDSP 0x13ed3161f _Z14DuckOtherAudiojff + 51
AudioDSP 0x13ee64a3b _ZN16AUVoiceProcessor22DestroyAggregateDeviceEv + 829
AudioDSP 0x13ee65d59 _ZN16AUVoiceProcessorD2Ev + 415
AudioDSP 0x13ef43342 _ZN13ComponentBase8AP_CloseEPv + 30
AudioToolboxCore 0x7fff217b5c8c _ZN19APComponentInstance15disposeInstanceEv + 40
AudioToolboxCore 0x7fff218b92ef AudioComponentInstanceDispose + 40