Banshee bug 412273 should now be solved, as well as minor bugs that may show up in a few files here and there. To summarize the change, let me first present you with the Changelog:
2007-03-08 Brian Nickel <**********>
* src/TagLib/Mpc/File.cs: Inherit NonContainer.File
* src/TagLib/CombinedTag.cs: Add some useful features for NonContainer.*
* src/TagLib/Id3v1/Tag.cs: Add Tag.Size instead of repeated hardcoding of
* src/TagLib/Id3v2/Header.cs: Throw proper CorruptFileExceptions
* src/TagLib/Mpeg/File.cs: Inherit NonContainer.File
* src/TagLib/WavPack/File.cs: Inherit NonContainer.File
* src/TagLib/NonContainer/StartTag.cs: New generic abstracts for files
that can start/end with an assortment of tags. (FLAC, WV, MPC, MP3)
* src/TagLib/Ape/Tag.cs: Read backwards if a footer is found and forwards if
a header is found.
* src/TagLib/Ape/Footer.cs: FooterPresent and IsHeader were read
incorrectly. Also throw proper exceptions while reading.
* src/TagLib/Flac/File.cs: Inherit NonContainer.File
* src/TagLib/Flac/Block.cs: Removed from Flac.File, made public.
* src/TagLib/Mpeg4/File.cs: Remove old commented code.
* examples/ReadFromUri.mdp: Updates.
To solve this bug, I created a new namespace, TagLib.NonContainer, which provides an abstract file which does the following:
- Checks the very beginning of the file for a valid APE or ID3 tag, reads it, and then checks after that tag for another, until none is found.
- It then lets the child class read whatever it wants to at the beginning of the file. For most formats, this is just going to be the first header block, and for FLAC it’s a vorbis comment and embedded images.
- It then advanced to the end and searches backwards in similar manner.
- Same as 2, but at the end.
- Have the child class read the audio properties, if necessary.
So, now you can read ID3v2 tags at the end or APE tags at the front, not to mention fun combinations like (APE, APE, ID3v2, APE). The combinations are infinite! (sarcasm implied)
On the plus side, now the child classes are much cleaner and easier to work with internally.