]> granicus.if.org Git - taglib/commitdiff
Fix TTA audio properties reading.
authorLukáš Lalinský <lalinsky@gmail.com>
Fri, 23 Nov 2007 06:54:22 +0000 (06:54 +0000)
committerLukáš Lalinský <lalinsky@gmail.com>
Fri, 23 Nov 2007 06:54:22 +0000 (06:54 +0000)
git-svn-id: svn://anonsvn.kde.org/home/kde/trunk/kdesupport/taglib@740388 283d02a7-25f6-0310-bc7c-ecb5cbfe19da

taglib/trueaudio/trueaudiofile.cpp
taglib/trueaudio/trueaudioproperties.cpp
tests/CMakeLists.txt
tests/Makefile.am
tests/test_trueaudio.cpp [new file with mode: 0644]

index b91e3f9b9835cd98abd6be3e7aec02bf56113091..18b7a911698f83c405b90e5e5be5d14ab88fdf92 100644 (file)
@@ -273,9 +273,16 @@ void TrueAudio::File::read(bool readProperties, Properties::ReadStyle /* propert
   // Look for TrueAudio metadata
 
   if(readProperties) {
-    seek(d->ID3v2Location + d->ID3v2OriginalSize);
-    d->properties = new Properties(readBlock(TrueAudio::HeaderSize),
-                                   length() - d->ID3v2OriginalSize);
+    if(d->ID3v2Location >= 0) {
+      seek(d->ID3v2Location + d->ID3v2OriginalSize);
+      d->properties = new Properties(readBlock(TrueAudio::HeaderSize),
+                                     length() - d->ID3v2OriginalSize);
+    }
+    else {
+      seek(0);
+      d->properties = new Properties(readBlock(TrueAudio::HeaderSize),
+                                     length());
+    }
   }
 }
 
index ef7bdd5103dbbbd2abde7f5726ea40569d196f7f..ff65edf9f81ec4956067f290b633cc6f0987432c 100644 (file)
@@ -112,7 +112,7 @@ int TrueAudio::Properties::ttaVersion() const
 
 void TrueAudio::Properties::read()
 {
-  if(!d->data.startsWith("TrueAudio"))
+  if(!d->data.startsWith("TTA"))
     return;
 
   int pos = 3;
index 72040d0ff359ef176d5d8a18547a7bff1059ab68..88c08098e1043573bf17cf0bdfa5a63cf9da496b 100644 (file)
@@ -7,6 +7,7 @@ INCLUDE_DIRECTORIES(
   ${CMAKE_CURRENT_SOURCE_DIR}/../taglib/mpeg/id3v2
   ${CMAKE_CURRENT_SOURCE_DIR}/../taglib/mpeg/id3v2/frames
   ${CMAKE_CURRENT_SOURCE_DIR}/../taglib/mpeg
+  ${CMAKE_CURRENT_SOURCE_DIR}/../taglib/trueaudio
 )
 
 SET(test_runner_SRCS
@@ -15,6 +16,7 @@ SET(test_runner_SRCS
   test_map.cpp
   test_mpeg.cpp
   test_synchdata.cpp
+  test_trueaudio.cpp
   test_bytevector.cpp
   test_string.cpp
   test_fileref.cpp
index 1c24d94fd038fae62ea8aa8e1c50a81178134611..65191808b91d3be396c83638311e05872771ca53 100644 (file)
@@ -1,6 +1,7 @@
 INCLUDES = \
         -I$(top_srcdir)/taglib\
         -I$(top_srcdir)/taglib/toolkit \
+        -I$(top_srcdir)/taglib/trueaudio \
         -I$(top_srcdir)/taglib/mpeg \
         -I$(top_srcdir)/taglib/mpeg/id3v1 \
         -I$(top_srcdir)/taglib/mpeg/id3v2 \
@@ -12,6 +13,7 @@ test_runner_SOURCES = \
        test_map.cpp \
        test_mpeg.cpp \
        test_synchdata.cpp \
+       test_trueaudio.cpp \
        test_bytevector.cpp \
        test_string.cpp \
        test_fileref.cpp \
diff --git a/tests/test_trueaudio.cpp b/tests/test_trueaudio.cpp
new file mode 100644 (file)
index 0000000..b300eef
--- /dev/null
@@ -0,0 +1,26 @@
+#include <cppunit/extensions/HelperMacros.h>
+#include <string>
+#include <stdio.h>
+#include <trueaudiofile.h>
+
+using namespace std;
+using namespace TagLib;
+
+class TestTrueAudio : public CppUnit::TestFixture
+{
+  CPPUNIT_TEST_SUITE(TestTrueAudio);
+  CPPUNIT_TEST(testReadPropertiesWithoutID3v2);
+  CPPUNIT_TEST_SUITE_END();
+
+public:
+
+  void testReadPropertiesWithoutID3v2()
+  {
+    TrueAudio::File f("data/empty.tta");
+    CPPUNIT_ASSERT(f.audioProperties());
+    CPPUNIT_ASSERT_EQUAL(3, f.audioProperties()->length());
+  }
+
+};
+
+CPPUNIT_TEST_SUITE_REGISTRATION(TestTrueAudio);