13

I have an app in the App Store which uses AudioUnit for recording audio.

About once a week or so I am seeing that for some users in the wild the call to AudioUnitInitialize fails with the error code 561017449 which is also 0x21707269 or "irp!".

What does this error code mean? I've been unable to find it documented. Also:

~$ macerror 561017449
Unknown error (561017449) at /usr/bin/macerror5.16 line 40, <DATA> line 1.

There have been few instances of this issue, but so far there appears to be no pattern of commonality as far as device and OS version goes.

I'm not including code as I don't think that will be helpful just yet. The code is working on variety of devices already. At this time I'm most interested in learning details about this specific error.

Thanks!

Chuck Batson
  • 2,165
  • 1
  • 17
  • 15

2 Answers2

24

This is defined in AVAudioSession.h:

AVAudioSessionErrorInsufficientPriority = '!pri', /* 0x21707269, 561017449 */

and is described as "The app was not allowed to set the audio category because another app (Phone, etc.) is controlling it."

Chuck Batson
  • 2,165
  • 1
  • 17
  • 15
  • I can't find this in the AVAudioSession.h I see !? It is iOS SDK 7.0 Surprisingly can't even find if it has been deprecated and what is the alternate. – Ozair Kafray Mar 19 '15 at 06:46
  • 1
    Ok, It seems it would have been added in the latest iOS SDK, that is 8, as I see it is in the [AVAudioSessionErrorCodes](https://developer.apple.com/library/prerelease/ios/documentation/AVFoundation/Reference/AVAudioSession_ClassReference/index.html#//apple_ref/c/tdef/AVAudioSessionErrorCode) documentation: – Ozair Kafray Mar 19 '15 at 07:03
  • 2
    The crash may occur when you are trying to call `start` or `prepare` on AVAudioEngine instance and you are making a phone call. – Palli Jul 27 '17 at 10:13
  • 1
    My app crashes because of this. How can I prevent it from crashing? I mean what procedures should I follow when getting '561017449' status in AudioUnitInitialize()? – AndaluZ Jun 05 '18 at 09:24
  • 1
    @AndaluZ That's hard to answer without more detail. In general, if you receive this error, you will need to disable the use of audio in your app. This error indicates that the AU has *not* been initialized and therefore cannot be used for subsequent calls. – Chuck Batson Jun 06 '18 at 19:08
  • I was starting audio (ringtone) in my own app and immediately after that CallKit started (also playing the same ringtone) which than causes this error, because one of them possessed the AudioEngine. Since I removed ringtone player on my app, I don't get the error anymore. @ChuckBatson thnx for your comment. – AndaluZ Jun 07 '18 at 08:28
  • any other solution? Thanks, sometime other app controller audio then u can get this error – famfamfam Feb 06 '21 at 12:31
  • @famfamfam It's been years since I was immersed in this stuff, so I'm a bit rusty. There is no "solution" per se; the OS has declined to initialize the AU for use, likely because audio is already in use elsewhere. You could perhaps retry periodically (every few seconds or so?) until you receive success but I've not personally tried this approach. – Chuck Batson Feb 08 '21 at 03:51
  • 2
    In the iOS 16.1 SDK, AVAudioSession.h says the following on lines 189–193 in a doc comment on `setActive`: "Apps may activate a AVAudioSessionCategoryPlayback session when another app is hosting a call (to start a SharePlay activity for example). However, they are not permitted to capture the microphone of the active call, so attempts to activate a session with category AVAudioSessionCategoryRecord or AVAudioSessionCategoryPlayAndRecord will fail with error AVAudioSessionErrorCodeInsufficientPriority." — essentially, you may see this error when trying to record while another app is recording. – towynlin Dec 05 '22 at 22:15
2

After wasting a lot of time I found that this issue is occurring in my device(iPad) just after debugging my current code in it without uninstalling the existing live app. The record and play permission was creating the issue. So uninstalling then installing a fresh build magically does the job for me.