mirror of
https://github.com/taglib/taglib.git
synced 2025-06-04 01:28:21 -04:00
TrueAudio: A bit more accurate calculation of the stream length.
This commit is contained in:
parent
eb73612a2b
commit
2155b4fd50
@ -246,7 +246,6 @@ bool TrueAudio::File::hasID3v2Tag() const
|
||||
return d->hasID3v2;
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// private members
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
@ -284,16 +283,23 @@ void TrueAudio::File::read(bool readProperties, Properties::ReadStyle /* propert
|
||||
// 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);
|
||||
}
|
||||
}
|
||||
|
||||
|
BIN
tests/data/tagged.tta
Normal file
BIN
tests/data/tagged.tta
Normal file
Binary file not shown.
@ -11,6 +11,7 @@ class TestTrueAudio : public CppUnit::TestFixture
|
||||
{
|
||||
CPPUNIT_TEST_SUITE(TestTrueAudio);
|
||||
CPPUNIT_TEST(testReadPropertiesWithoutID3v2);
|
||||
CPPUNIT_TEST(testReadPropertiesWithTags);
|
||||
CPPUNIT_TEST_SUITE_END();
|
||||
|
||||
public:
|
||||
@ -30,6 +31,21 @@ 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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user