From c6a63a3a2f82866f5015b7b6f68fea2cf26f4fe3 Mon Sep 17 00:00:00 2001 From: Tsuda Kageyu Date: Mon, 5 Jan 2015 18:20:31 +0900 Subject: [PATCH] Implement missing AIFF::File::hasID3v2Tag(). --- taglib/riff/aiff/aifffile.cpp | 12 ++++++++++-- tests/test_aiff.cpp | 20 ++++++++++++++++++++ 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/taglib/riff/aiff/aifffile.cpp b/taglib/riff/aiff/aifffile.cpp index d20c148b..2f79920c 100644 --- a/taglib/riff/aiff/aifffile.cpp +++ b/taglib/riff/aiff/aifffile.cpp @@ -39,7 +39,8 @@ public: FilePrivate() : properties(0), tag(0), - tagChunkID("ID3 ") + tagChunkID("ID3 "), + hasID3v2(false) { } @@ -53,6 +54,8 @@ public: Properties *properties; ID3v2::Tag *tag; ByteVector tagChunkID; + + bool hasID3v2; }; //////////////////////////////////////////////////////////////////////////////// @@ -100,7 +103,6 @@ PropertyMap RIFF::AIFF::File::setProperties(const PropertyMap &properties) return d->tag->setProperties(properties); } - RIFF::AIFF::Properties *RIFF::AIFF::File::audioProperties() const { return d->properties; @@ -119,10 +121,15 @@ bool RIFF::AIFF::File::save() } setChunkData(d->tagChunkID, d->tag->render()); + d->hasID3v2 = true; return true; } +bool RIFF::AIFF::File::hasID3v2Tag() const +{ + return d->hasID3v2; +} //////////////////////////////////////////////////////////////////////////////// // private members @@ -134,6 +141,7 @@ void RIFF::AIFF::File::read(bool readProperties, Properties::ReadStyle propertie if(chunkName(i) == "ID3 " || chunkName(i) == "id3 ") { d->tagChunkID = chunkName(i); d->tag = new ID3v2::Tag(this, chunkOffset(i)); + d->hasID3v2 = true; } else if(chunkName(i) == "COMM" && readProperties) d->properties = new Properties(chunkData(i), propertiesStyle); diff --git a/tests/test_aiff.cpp b/tests/test_aiff.cpp index 495049b2..4df8d893 100644 --- a/tests/test_aiff.cpp +++ b/tests/test_aiff.cpp @@ -13,6 +13,7 @@ class TestAIFF : public CppUnit::TestFixture { CPPUNIT_TEST_SUITE(TestAIFF); CPPUNIT_TEST(testReading); + CPPUNIT_TEST(testSaveID3v2); CPPUNIT_TEST(testAiffCProperties); CPPUNIT_TEST(testFuzzedFile1); CPPUNIT_TEST(testFuzzedFile2); @@ -26,6 +27,25 @@ public: CPPUNIT_ASSERT_EQUAL(705, f.audioProperties()->bitrate()); } + void testSaveID3v2() + { + ScopedFileCopy copy("empty", ".aiff"); + string newname = copy.fileName(); + + { + RIFF::AIFF::File f(newname.c_str()); + CPPUNIT_ASSERT(!f.hasID3v2Tag()); + f.tag()->setTitle(L"TitleXXX"); + f.save(); + } + + { + RIFF::AIFF::File f(newname.c_str()); + CPPUNIT_ASSERT(f.hasID3v2Tag()); + CPPUNIT_ASSERT_EQUAL(String(L"TitleXXX"), f.tag()->title()); + } + } + void testAiffCProperties() { RIFF::AIFF::File f(TEST_FILE_PATH_C("alaw.aifc")); -- 2.40.0