Open saitjr opened 8 years ago
I see this as well.
Placing a breakpoint in malloc_error_debug hasn't helped me at all, so I turned on Address Sanitizer. (edit schemes).
This causes an immediate break in
- (void)convertDataFromAudioBufferList:(AudioBufferList *)audioBufferList ...
at ..
[EZAudioUtilities checkResult:AudioConverterFillComplexBuffer(self.info->converterRef,
The issue is that for some reason when the lock screen is activated, the amount of frames goes from 1024 to 4096. And this triggers this offending line:
audioBufferList->mBuffers[i].mDataByteSize = frames * self.info->inputFormat.mBytesPerFrame;
Essentially, the bufferSize that was allocated was 4096, and the size is set to 16384 even though it is STILL only a buffer of 4096. This causes an overwrite of the buffer in AudioConverterFillComplexBuffer.
I'm not knowledgable enough to know if this is a bug in EZAudio, or a result of incorrect configuration of the properties that lead to the buffer initialization. It definitely seems EZAudio is wrong to blindly change the buffer size despite what it's ACTUAL capacity size it is.
I'm not sure what the proper fix for this is. You can work around it by multiplying 4 to the calculated buffer size in
EZAudioUtilities.m : audioBufferListWithNumberOfFrames
audioBufferList->mBuffers[i].mData = calloc(bufferSize * 4, 1);
Also see #303 which is unrelated to this, but related to lock screen.
That's work for me, thank you very much. And #303 is work for me too.
Please do not close this. My workaround is not a fix but an awful hack. We need to understand if this is a bug in EZAudio or a problem in setup of the properties that lead to buffer allocation, and this needs to be fixed.
Please reopen.
👌
This fix is causing crashes in my app, any idea what the actual fix is?
In the demo PlayFile, when I set BackgroundMode on and allow audio play in background :
environment : iPhone5s iOS 9.3.1
Run on simulator is totally fine. And there is no problem if I set AVAudioSession to PlayAndRecord.