我在 iOS 16 中收到错误。此错误不会出现在以前的 iOS 版本中。我正在使用 RemoteIO 以 4000 Hz 播放实时音频。错误如下:
输入数据过程返回不一致的2个186字节数据包;每个数据包 2 字节,实际上是 93 个数据包
这是音频格式和回调的设置方式:
// 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));
Run Code Online (Sandbox Code Playgroud)
请注意,我设置的 mSampleRate 为 4000 Hz。在 iOS 15 …