MP4::Atom *meta = path[path.size() - 2];
AtomList::Iterator index = meta->children.find(ilst);
+
+ // check if there is an atom before 'ilst', and possibly use it as padding
if(index != meta->children.begin()) {
AtomList::Iterator prevIndex = index;
prevIndex--;
length += prev->length;
}
}
- if(index != meta->children.end()) {
- AtomList::Iterator nextIndex = index;
- nextIndex++;
+ // check if there is an atom after 'ilst', and possibly use it as padding
+ AtomList::Iterator nextIndex = index;
+ nextIndex++;
+ if(nextIndex != meta->children.end()) {
MP4::Atom *next = *nextIndex;
if(next->name == "free") {
length += next->length;
CPPUNIT_TEST(testProperties);
CPPUNIT_TEST(testFreeForm);
CPPUNIT_TEST(testUpdateStco);
+ CPPUNIT_TEST(testSaveExisingWhenIlstIsLast);
CPPUNIT_TEST_SUITE_END();
public:
deleteFile(filename);
}
+ void testSaveExisingWhenIlstIsLast()
+ {
+ string filename = copyFile("ilst-is-last", ".m4a");
+
+ MP4::File *f = new MP4::File(filename.c_str());
+ CPPUNIT_ASSERT_EQUAL(String("82,164"), f->tag()->itemListMap()["----:com.apple.iTunes:replaygain_track_minmax"].toStringList()[0]);
+ CPPUNIT_ASSERT_EQUAL(String("Pearl Jam"), f->tag()->artist());
+ f->tag()->setComment("foo");
+ f->save();
+ delete f;
+
+ f = new MP4::File(filename.c_str());
+ CPPUNIT_ASSERT_EQUAL(String("82,164"), f->tag()->itemListMap()["----:com.apple.iTunes:replaygain_track_minmax"].toStringList()[0]);
+ CPPUNIT_ASSERT_EQUAL(String("Pearl Jam"), f->tag()->artist());
+ CPPUNIT_ASSERT_EQUAL(String("foo"), f->tag()->comment());
+
+ deleteFile(filename);
+ }
+
};
CPPUNIT_TEST_SUITE_REGISTRATION(TestMP4);