1

I'm having trouble using AudioKit in an iOS app that also use AVPlayer (for video). In my project I have one page with an AVPlayer video and a button that segues to a second page with a record and play button that uses AudioKit. If I don't start the video the AKNodeRecorder is working as expected, but if the video is played before recording the app crashes with the following message:

2018-04-13 13:18:10.576116+0200 AVPlayer_vs_AudioKit[1854:580107] [mcmx] 338: input bus 0 sample rate is 0

2018-04-13 13:18:10.576361+0200 AVPlayer_vs_AudioKit[1854:580107] [avae] AVAEInternal.h:103:_AVAE_CheckNoErr:

[AVAudioEngineGraph.mm:1839:InstallTapOnNode: (err = AUGraphParser::InitializeActiveNodesInInputChain(ThisGraph, *inputNode)): error -10875

2018-04-13 13:18:10.576691+0200 AVPlayer_vs_AudioKit[1854:580107] *** Terminating app due to uncaught exception 'com.apple.coreaudio.avfaudio', reason: 'error -10875'

*** First throw call stack:

(0x183a3ed8c 0x182bf85ec 0x183a3ebf8 0x1893671a0 0x189383f58 0x189393410 0x18940c5e8 0x1893fc6e8 0x104e7db90 0x104d7d170 0x104d7d714 0x18d76e6c8 0x18d88f8a4 0x18d77477c 0x18d8aa1dc 0x18d7f1a48 0x18d7e68f8 0x18d7e5238 0x18dfc6c0c 0x18dfc91b8 0x18dfc2258 0x1839e7404 0x1839e6c2c 0x1839e479c 0x183904da8 0x1858e7020 0x18d8e578c 0x104d801a4 0x183395fc0)

libc++abi.dylib: terminating with uncaught exception of type NSException

I use AudioKit 4.2.3 from cocoapods on XCode 9.3

My project can be downloaded here: https://www.dropbox.com/s/gxek91sccit88zv/AVPlayer_vs_AudioKit.zip?dl=0

Community
  • 1
  • 1
torof
  • 368
  • 1
  • 12
  • The project you linked fails to open. If it helps, `-10875` is `kAudioUnitErr_FailedInitialization`. Maybe there's some audio session configuration you need to do that `AVPlayer` was doing for you? #clutchingatstraws – Rhythmic Fistman Apr 14 '18 at 09:34
  • @Rhythmic Fistman The link seams to work at my end. I did't include the AudioKit library in the zip, but it can be installed by "pod install". – torof Apr 14 '18 at 13:25
  • My guess is that AudioKit and AVPlayer uses the sames libraries, and when AudioKit is initialized it tries to initialize something that has already been initialized by AVPlayer. It does not crash if I first record with AudioKit, then play the video, and record with AudioKit again. So I might be able to make a workaround where I start AudioKit when loading the page with the video. – torof Apr 14 '18 at 13:44
  • 1
    My bad, you have to open the project file before the workspace file so you can say "yes, open this file downloaded from the internet", otherwise xcode reports that the project can't be opened. – Rhythmic Fistman Apr 14 '18 at 15:00

1 Answers1

1

Configuring AudioKit's idea of an audio session early on to include recording fixes the problem, e.g. in application(didFinishLaunchingWithOptions:)

try! AKSettings.setSession(category: .playAndRecord, options: 0)
Rhythmic Fistman
  • 34,352
  • 5
  • 87
  • 159
  • Worked perfectly! Thank you so much for your help! – torof Apr 14 '18 at 20:06
  • @Rhythmic Fistman Could you also check this? https://stackoverflow.com/questions/55910290/avaudiosession-plays-sound-on-receiver-or-mic-dont-tap – Spring May 02 '19 at 20:44