Closed mqus closed 4 years ago
Nice sleuthing!
I mostly agree with your analysis.
I don't like the option of scanning unknown data until encountering a valid frame header. While it would be rare that a valid frame header appears in arbitrary data, it would be a very undesirable failure case.
I would be happy to return the current duration after encountering unexpected data. That is already what we do for unexpected end of file (even in the middle of an audio frame), and most bizarre frames reside after the audio data. Since this will be a breaking change anyway, I think the duration after an unexpected EoF should also go in the error.
I would be interested in files from 1/2/4, although I'll have to craft public domain ones for unit testing.
I debugged the remaining files and they had one the following cases:
I can send you some files, if you want to check it out yourself.
Thoughts on possible solutions:
header_buffer
one byte to the left at the end of the loop and then try to fill that one byte at the start before trying again. The probability of falsely matching an mp3 frame would be low because we already skip most of the troublemakers or encounter them at the end (id3v2, ape,etc). This would also make the padding-eater of #8 obsolete.failure::Error
can't be used for that because everything within it is inaccessible. Personally I'm just fine with a custom error type and a localbail!
macro and it probably wouldn't change or increase the existing code much.