diff options
author | Lukáš Lalinský <lalinsky@gmail.com> | 2009-12-13 15:32:55 +0000 |
---|---|---|
committer | Lukáš Lalinský <lalinsky@gmail.com> | 2009-12-13 15:32:55 +0000 |
commit | 74c3c282c4271eee1095f53d1ce90b3a1ab105cb (patch) | |
tree | b84e457ce93e3e78ef930dd791e3799e4ad7ee6d | |
parent | 004551faec42f07ea2ff737bcc764f8b1f8ce2c1 (diff) |
Handle WM/TrackNumber with DWORD content
The default type for this attribute is String, but even MSDN suggests to
support also DWORD, because some applications write such files.
BUG:218526
git-svn-id: svn://anonsvn.kde.org/home/kde/trunk/kdesupport/taglib@1062026 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
-rw-r--r-- | taglib/asf/asftag.cpp | 9 | ||||
-rw-r--r-- | tests/test_asf.cpp | 27 |
2 files changed, 34 insertions, 2 deletions
diff --git a/taglib/asf/asftag.cpp b/taglib/asf/asftag.cpp index 6bea247f..f910ccb0 100644 --- a/taglib/asf/asftag.cpp +++ b/taglib/asf/asftag.cpp @@ -105,8 +105,13 @@ ASF::Tag::year() const unsigned int ASF::Tag::track() const { - if(d->attributeListMap.contains("WM/TrackNumber")) - return d->attributeListMap["WM/TrackNumber"][0].toString().toInt(); + if(d->attributeListMap.contains("WM/TrackNumber")) { + const ASF::Attribute attr = d->attributeListMap["WM/TrackNumber"][0]; + if(attr.type() == ASF::Attribute::DWordType) + return attr.toUInt(); + else + return attr.toString().toInt(); + } if(d->attributeListMap.contains("WM/Track")) return d->attributeListMap["WM/Track"][0].toUInt(); return 0; diff --git a/tests/test_asf.cpp b/tests/test_asf.cpp index 8de44ea4..16fae663 100644 --- a/tests/test_asf.cpp +++ b/tests/test_asf.cpp @@ -18,6 +18,7 @@ class TestASF : public CppUnit::TestFixture CPPUNIT_TEST(testSaveMultipleValues); CPPUNIT_TEST(testSaveStream); CPPUNIT_TEST(testSaveLanguage); + CPPUNIT_TEST(testDWordTrackNumber); CPPUNIT_TEST_SUITE_END(); public: @@ -55,6 +56,32 @@ public: delete f; } + void testDWordTrackNumber() + { + ScopedFileCopy copy("silence-1", ".wma"); + string newname = copy.fileName(); + + ASF::File *f = new ASF::File(newname.c_str()); + CPPUNIT_ASSERT(!f->tag()->attributeListMap().contains("WM/TrackNumber")); + f->tag()->setAttribute("WM/TrackNumber", (unsigned int)(123)); + f->save(); + delete f; + + f = new ASF::File(newname.c_str()); + CPPUNIT_ASSERT(f->tag()->attributeListMap().contains("WM/TrackNumber")); + CPPUNIT_ASSERT_EQUAL(ASF::Attribute::DWordType, f->tag()->attributeListMap()["WM/TrackNumber"].front().type()); + CPPUNIT_ASSERT_EQUAL(TagLib::uint(123), f->tag()->track()); + f->tag()->setTrack(234); + f->save(); + delete f; + + f = new ASF::File(newname.c_str()); + CPPUNIT_ASSERT(f->tag()->attributeListMap().contains("WM/TrackNumber")); + CPPUNIT_ASSERT_EQUAL(ASF::Attribute::UnicodeType, f->tag()->attributeListMap()["WM/TrackNumber"].front().type()); + CPPUNIT_ASSERT_EQUAL(TagLib::uint(234), f->tag()->track()); + delete f; + } + void testSaveStream() { ScopedFileCopy copy("silence-1", ".wma"); |