I am working on an iOS MPEG-DASH player and I have an issue with seeking feature.
ExtAudioFileSeek(::) documentation said
Sets the file’s read position to the specified sample frame number. A subsequent call to the ExtAudioFileRead(::_:) function returns samples from precisely this location, even if it is located in the middle of a packet.
Unfortunately, the AudioToolbox.AudioFile_ReadProc
loop does not seek straight to the right frame and goes trough all file segments, requesting 16 and 27682 bytes packages.
It takes a lot of time (especially for long tracks) and force to download all intermediate segments (that should not be required)
This also cause the app to crash when long tracks with high sound quality are being played.
Here my log trace. I converted frame index to "mega" for more readability.
[PlayerEngine] - Trying to seek at 16.870537 %
[AudioSource] - Pausing AudioOutputUnit
[AudioSource] - AudioOutputUnit successfully stopped
[AudioOutputUnit] - Trying to seek at frame 31.006805M
[AudioOutputUnit] - Successfully sought at frame 31.006805M
[AudioInputUnit] - Audio frames have been flushed
[AudioInputUnit] - Seek to frame 31.006806M pending
[AudioConverter] - Converted frame buffer has been flush
[AudioSource] - Resuming AudioOutputUnit
[AudioSource] - AudioOutputUnit successfully resumed
[PlayerEngine] - Successfully sought at 16.870537 %
[AudioInputUnit] - Seeking to frame 31.006805M
[CoreAudioDecoder] - Trying to seek at frame 31.006805M
[CoreAudioDecoder] - Seek on frame 31.006806M done successfully
[CoreAudioDecoder] - AudioToolbox.AudioFile_ReadProc : inClientData, inPosition:1.315635M, requestCount:16
(...)
[CoreAudioDecoder] - AudioToolbox.AudioFile_ReadProc : inClientData, inPosition:1.331687M, requestCount:27682
Is it a bug on AudioToolBox or is there a way to fix it ?
Thanks a lot !