3

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.

ndr
  • 52
  • 5
  • 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.. – tokentoken Feb 16 '23 at 00:25
  • Also seeing this here, although I get it at any SR other than 48000, with the internal mic as the source. Any progress on this? – Andrew Smith Mar 30 '23 at 20:03
  • This works -> https://stackoverflow.com/a/76842409/4685284 – Shahbaz Hashmi Aug 31 '23 at 08:15

0 Answers0