return d->hasID3v2;
}
-
////////////////////////////////////////////////////////////////////////////////
// private members
////////////////////////////////////////////////////////////////////////////////
// Look for TrueAudio metadata
if(readProperties) {
- if(d->ID3v2Location >= 0) {
+
+ long streamLength;
+
+ if(d->hasID3v1)
+ streamLength = d->ID3v1Location;
+ else
+ streamLength = length();
+
+ if(d->hasID3v2) {
seek(d->ID3v2Location + d->ID3v2OriginalSize);
- d->properties = new Properties(readBlock(TrueAudio::HeaderSize),
- length() - d->ID3v2OriginalSize);
+ streamLength -= (d->ID3v2Location + d->ID3v2OriginalSize);
}
else {
seek(0);
- d->properties = new Properties(readBlock(TrueAudio::HeaderSize),
- length());
}
+
+ d->properties = new Properties(readBlock(TrueAudio::HeaderSize), streamLength);
}
}
{
CPPUNIT_TEST_SUITE(TestTrueAudio);
CPPUNIT_TEST(testReadPropertiesWithoutID3v2);
+ CPPUNIT_TEST(testReadPropertiesWithTags);
CPPUNIT_TEST_SUITE_END();
public:
CPPUNIT_ASSERT_EQUAL(1, f.audioProperties()->ttaVersion());
}
+ void testReadPropertiesWithTags()
+ {
+ TrueAudio::File f(TEST_FILE_PATH_C("tagged.tta"));
+ CPPUNIT_ASSERT(f.audioProperties());
+ CPPUNIT_ASSERT_EQUAL(3, f.audioProperties()->length());
+ CPPUNIT_ASSERT_EQUAL(3, f.audioProperties()->lengthInSeconds());
+ CPPUNIT_ASSERT_EQUAL(3685, f.audioProperties()->lengthInMilliseconds());
+ CPPUNIT_ASSERT_EQUAL(173, f.audioProperties()->bitrate());
+ CPPUNIT_ASSERT_EQUAL(2, f.audioProperties()->channels());
+ CPPUNIT_ASSERT_EQUAL(44100, f.audioProperties()->sampleRate());
+ CPPUNIT_ASSERT_EQUAL(16, f.audioProperties()->bitsPerSample());
+ CPPUNIT_ASSERT_EQUAL(162496U, f.audioProperties()->sampleFrames());
+ CPPUNIT_ASSERT_EQUAL(1, f.audioProperties()->ttaVersion());
+ }
+
};
CPPUNIT_TEST_SUITE_REGISTRATION(TestTrueAudio);