iOS 16 RemoteIO: Input data proc returned inconsistent 2 packets

I am getting an error in iOS 16. This error doesn't appear in previous iOS versions. I am using RemoteIO to playback live audio at 4000 hz. The error is the following:

Input data proc returned inconsistent 2 packets for 186 bytes; at 2 bytes per packet, that is actually 93 packets

This is how the audio format and the callback is set:

// Set the Audio format
AudioStreamBasicDescription audioFormat;        
audioFormat.mSampleRate         = 4000;
audioFormat.mFormatID           = kAudioFormatLinearPCM;
audioFormat.mFormatFlags        = kAudioFormatFlagIsSignedInteger | kAudioFormatFlagIsPacked;
audioFormat.mFramesPerPacket    = 1;
audioFormat.mChannelsPerFrame   = 1;
audioFormat.mBitsPerChannel     = 16;
audioFormat.mBytesPerPacket     = 2;
audioFormat.mBytesPerFrame      = 2;

AURenderCallbackStruct callbackStruct;
// Set output callback
callbackStruct.inputProc = playbackCallback;
callbackStruct.inputProcRefCon = (__bridge void * _Nullable)(self);
status = AudioUnitSetProperty(audioUnit,
                              kAudioUnitProperty_SetRenderCallback,
                              kAudioUnitScope_Global,
                              kOutputBus,
                              &callbackStruct,
                              sizeof(callbackStruct));

Note that the mSampleRate I set is 4000 Hz. In iOS 15 I get 0.02322 seconds of buffer duration (IOBufferDuration) and 93 frames in each callback. This is expected, because:

number of frames * buffer duration = sampling rate
93 * 0.02322 = 4000 Hz

However, in iOS 16 I am getting the aforementioned error in the callback.

Input data proc returned inconsistent 2 packets for 186 bytes; at 2 bytes per packet, that is actually 93 packets

Since the number of frames is equal to the number of packets, I am getting 1 or 2 frames in the callback and the buffer duration is of 0.02322 seconds. This didn't affect the playback of the "raw" signal, but it did affect the playback of the "processed" signal.

number of frames * buffer duration = sampling rate
2 * 0.02322 = 0.046 Hz

That doesn't make any sense. This error appears for different sampling rates (8000, 16000, 32000), but not for 44100. However I would like to keep 4000 as my sampling rate.

I have also tried to set the sampling rate by using the setPreferredSampleRate(_:) function of AVAudioSession, but the attempt didn't succeed. The sampling rate was still 44100 after calling that function.

Any help on this issue would be appreciated.

I am experiencing a similar issue …. The callback only has one or two frames, whereas on identical hardware running ios15 there were hundreds typically, with identical code. This is at 44100 samples per second. The problem is confined to real devices: behavior in the emulators running ios16 is as it was for ios15.

Has something changed in how the render callbacks operate in hardware?

I'm having a similar issue with my apps which have an audio input feature.

One of them uses 44100 as a sample rate and got the error on iOS / iPadOS 16. In that case, AVAudioSession.shared.sampleRate seems to be 48000, and changing the sample rate to 48000 resolved the error.

Another one uses 11025 as a sample rate. This app needs to use a lower sample rate than 44100 / 48000, but I'm not sure how to workaround.

Hello, have you solved the problem? Our device SampleRate is fixed at 8000. After iOS16, my audio can no longer reduce noise

any news on that issue ? has anyone manage to overcome this problem related to ios 16 ?

I had the same problem recently, on ios16, but the audio data seems ok

I'm seeing the same error, only on iOS16. [AudioConverter] CompositeAudioConverter.cpp:1239 Input data proc returned inconsistent 1 packets for 1884 bytes; at 4 bytes per packet, that is actually 471 packets There are too many same error messages and difficult to debug..

Hey it's been 5 months and there is still no updates on whether on not this is at the very least being looked into. I have users complaining that they are unable to use certain devices as input due to the sample rate mismatch and this error causing horrible crackly audio. This is tested and working fine on iOS 15 but broken on iOS 16.

I am using RemoteIO to playback audio from external audio sources to an AirPlay output. While this works for most USB audio inputs, iOS tries to force USB inputs classified as a "USB Microphone" to 48000 Hz when I strictly need to use 44100 Hz for AirPlay. While it is fine because it is the sample rate I need in my case, it also forces other USB audio devices to 44100 Hz.

As mentioned above, calling setPreferredSampleRate does not work and it will always stay at the 48000 Hz or 44100 Hz forced by iOS 16. And again, this was working perfectly fine in iOS 15.

Anyone have any solutions in the meantime?

[AudioConverter] CompositeAudioConverter.cpp:1239 Input data proc returned inconsistent 124 packets for 3764 bytes; at 4 bytes per packet, that is actually 941 packets

I'm also dealing with this (AudioTools app) typically using the built-in mic. It seems that I can no longer run RemoteIO at any other than the current hardware sample rate, and I also can't change the sample rate. Here we are a few months from iOS 17 initial beta and this is still not working right in iOS 16.

This is still happening on iOS 17 developer beta 1 when built with Xcode 15.0 beta 1. Any updates? Just a reminder that this once worked just fine on iOS 15 and below...

这个问题解决了吗,我在iOS 17.0.3仍然遇到了相同的问题,从iOS 16开始。

iOS 16 RemoteIO: Input data proc returned inconsistent 2 packets
 
 
Q