Hopefully will move to reading RAM directly. I think this was not always
adding data properly, as I got wrong output after decode. Makes more
sense as a vector, anyway.
If the offset points to an ID3 tag or the middle of a frame, that's fine -
it should just search forward to the next sync. FFmpeg just returns a
decode error, so we do this first.
If we just ask what we should add, that is meant to stay static until we
do actually add it.
This also reduces the max we ask for at a time, which better matches
correct behavior and might impact game behavior.
This method can automatically read audio information from file (as channels, sample rate etc) via ffmpeg,
and create accurate ffmpeg's codec context.
Especially used for unknown audio format but supported by ffmpeg.
readPos and available buffer is firstly updated in AuGetInfoToAddStreamData then notified in AuNotifyAddStreamData.
Since, some games as Dead and alive may not call NotifyAddStreamData after GetInfoToAddStreamData
Based on my implementation in sceAac https://github.com/hrydgard/ppsspp/pull/5836
I've created a class AuCtx included in My SimpleAudioDec.cpp/.h which aims at providing a standard easy implementation to support all codecs in ffmpeg.
Here, I also completely re-code sceMp3 file with this class to give an example how to use this class, and it has solved all mp3 issues I've observed in the current master.
Tests on different freq and channels mp3 audios as:
Miku custom BGM (48kHz, stereo), Hanayaka Nari Wa ga Ichizoku(32kHz, mono, a little fast but better than before now), downstreet panic (44.1kHz, stereo), and learn jp09(44.1kHz, stero) are just all right.
Especially, I am very glad to see that Miku's Custom BGMs have no repetition issues in first tone any more and no longer stopped in the first second neither. :)
We will come into a new age to fast support new audio formats from now on I hope :P