diff --git a/taglib/wavpack/wavpackfile.cpp b/taglib/wavpack/wavpackfile.cpp index 8d7463d3..1a5b417d 100644 --- a/taglib/wavpack/wavpackfile.cpp +++ b/taglib/wavpack/wavpackfile.cpp @@ -272,8 +272,19 @@ void WavPack::File::read(bool readProperties, Properties::ReadStyle /* propertie // Look for WavPack audio properties - if(readProperties) - d->properties = new Properties(this, length() - d->APESize); + if(readProperties) { + + long streamLength; + + if(d->hasAPE) + streamLength = d->APELocation; + else if(d->hasID3v1) + streamLength = d->ID3v1Location; + else + streamLength = length(); + + d->properties = new Properties(this, streamLength); + } } long WavPack::File::findAPE() diff --git a/tests/data/tagged.wv b/tests/data/tagged.wv new file mode 100644 index 00000000..333f8687 Binary files /dev/null and b/tests/data/tagged.wv differ diff --git a/tests/test_wavpack.cpp b/tests/test_wavpack.cpp index 357d4aaf..656d39a2 100644 --- a/tests/test_wavpack.cpp +++ b/tests/test_wavpack.cpp @@ -14,6 +14,7 @@ class TestWavPack : public CppUnit::TestFixture CPPUNIT_TEST_SUITE(TestWavPack); CPPUNIT_TEST(testNoLengthProperties); CPPUNIT_TEST(testMultiChannelProperties); + CPPUNIT_TEST(testTaggedProperties); CPPUNIT_TEST(testFuzzedFile); CPPUNIT_TEST_SUITE_END(); @@ -51,6 +52,22 @@ public: CPPUNIT_ASSERT_EQUAL(1031, f.audioProperties()->version()); } + void testTaggedProperties() + { + WavPack::File f(TEST_FILE_PATH_C("tagged.wv")); + CPPUNIT_ASSERT(f.audioProperties()); + CPPUNIT_ASSERT_EQUAL(3, f.audioProperties()->length()); + CPPUNIT_ASSERT_EQUAL(3, f.audioProperties()->lengthInSeconds()); + CPPUNIT_ASSERT_EQUAL(3550, f.audioProperties()->lengthInMilliseconds()); + CPPUNIT_ASSERT_EQUAL(172, f.audioProperties()->bitrate()); + CPPUNIT_ASSERT_EQUAL(2, f.audioProperties()->channels()); + CPPUNIT_ASSERT_EQUAL(16, f.audioProperties()->bitsPerSample()); + CPPUNIT_ASSERT_EQUAL(false, f.audioProperties()->isLossless()); + CPPUNIT_ASSERT_EQUAL(44100, f.audioProperties()->sampleRate()); + CPPUNIT_ASSERT_EQUAL(156556U, f.audioProperties()->sampleFrames()); + CPPUNIT_ASSERT_EQUAL(1031, f.audioProperties()->version()); + } + void testFuzzedFile() { WavPack::File f(TEST_FILE_PATH_C("infloop.wv"));