Commits

shuerhaaken committed 473b2d7

add missing wavpack test; fix crash with wavpack reading

Comments (0)

Files changed (4)

+commit 18a367faa8629ea44e8bcb29c3b24c76ddbb22bf
+Author: Jörn Magens <shuerhaaken@googlemail.com>
+Date:   Tue Apr 2 11:31:14 2013 +0200
+
+    update reference to debian package download
+
+commit 2ba5053345c9462d70acfdadde3873c94fda6ca9
+Author: Jörn Magens <shuerhaaken@googlemail.com>
+Date:   Tue Apr 2 11:29:52 2013 +0200
+
+    add reference to debian package download
+
+commit 831afdea9a15981963535b49232451aee80034ae
+Author: Tal Hadad <tal_hd@hotmail.com>
+Date:   Tue Apr 2 11:22:24 2013 +0200
+
+    update packaging data
+
+commit 4973845c9bad42d7ecbdbcc76a63aba45c21b76b
+Author: Jörn Magens <shuerhaaken@googlemail.com>
+Date:   Tue Mar 26 09:34:47 2013 +0100
+
+    fix fsf adress; remove empty deps file; post release version increment
+
 commit 720d7b8ecdc278111ee461f39f70ebee0e9cff5f
 Author: Jörn Magens <shuerhaaken@googlemail.com>
 Date:   Mon Mar 25 09:14:23 2013 +0100

libtaginfo/wavpackinfo.cc

 
 
 WavPackInfo::WavPackInfo(const String &filename) : Info(filename) {
-    if(!file_name.isEmpty() && !create_file_ref())
+    taglib_apetag = NULL;
+    if(!file_name.isEmpty() && !create_file_ref()) {
         printf("Error creating file ref! %s\n", filename.toCString(false));
-    if(taglib_fileref && !taglib_fileref->isNull()) {
-        taglib_apetag = ((TagLib::WavPack::File *) taglib_fileref->file())->APETag();
-        if(!taglib_apetag || taglib_apetag->isEmpty()) { // Use fallback for id3v1 or extended header
-            //printf("Use fallback! %s\n", filename.c_str());
+    }
+    if(taglib_file) {
+        taglib_apetag = ((TagLib::WavPack::File *) taglib_file)->APETag(true);
+        if(!taglib_apetag || taglib_apetag->isEmpty()) {
             taglib_tag = ((TagLib::WavPack::File *) taglib_file)->tag();
             if(!taglib_tag) {
                 printf("Cant get tag object from '%s'\n", file_name.toCString(false));
         }
     }
     else {
+        printf("Cant get id3 tag from '%s'\n", file_name.toCString(false));
         taglib_apetag = NULL;
         valid = false;
     }
 
 
 bool WavPackInfo::create_file_ref() {
-    if(!file_name.isEmpty())
-        taglib_fileref = new TagLib::FileRef(file_name.toCString(false), true, TagLib::AudioProperties::Fast);
-    else
+    if(file_name.isEmpty())
         return false;
-    
-    if(taglib_fileref && !taglib_fileref->isNull()) {
-        taglib_tag = taglib_fileref->tag();
-        if(!taglib_tag) {
-            printf("Cant get tag object from '%s'\n", file_name.toCString(false));
-            return false;
-        }
+    taglib_file = new TagLib::WavPack::File(file_name.toCString(false), true, TagLib::AudioProperties::Fast);
+    if(taglib_file) {
         return true;
     }
     else {
+        printf("TagLib::File creation failed for '%s'\n", file_name.toCString(false));
         return false;
     }
 }

tests/Makefile.am

     write_speex/test \
     write_tta/test \
     write_wav/test \
+    write_wv/test \
     write_wma/test \
     ctest_read/test \
     ctest_write/test \
 write_wav_test_SOURCES          = write_wav/main.cc
 write_wav_test_LDADD            = $(taginfo_ldadd)
 
+write_wv_test_SOURCES           = write_wv/main.cc
+write_wv_test_LDADD             = $(taginfo_ldadd)
+
 ctest_read_test_SOURCES         = ctest_read/main.c
 ctest_read_test_LDADD           = $(top_builddir)/bindings/c/libtaginfo_c.la
 

tests/write_wv/main.cc

+#include "taginfo.h"
+#include <stdio.h>
+#include <iostream>
+#include <fstream>
+
+#define TESTNAME "xyz 1 23"
+
+using namespace TagInfo;
+
+
+int main(void) {
+    Info * info;
+    std::string val = TESTDIR "samples/sample.wv";
+    //std::cout << std::endl << "val: " << val << std::endl;
+    
+    std::string target("/tmp/out_01.wv");
+    
+    std::ifstream  src(val.c_str());
+    std::ofstream  dst(target.c_str());
+    dst << src.rdbuf();
+    info = Info::create_tag_info(target);
+    if(info) {
+        info->set_title(TESTNAME);
+        info->set_album_artist("äöé");
+        info->set_is_compilation(true);
+        info->set_comments("Cömmmééèntß");
+        info->set_year(1978);
+        info->write();
+    }
+    delete info;
+    info = NULL;
+    
+    info = Info::create_tag_info(target);
+    if(info) {
+        if(info->read()) {
+            if(info->get_title() == TESTNAME &&
+               info->get_album_artist() == "äöé" &&
+               info->get_year() == 1978 &&
+               info->get_comments() == "Cömmmééèntß" &&
+               info->get_is_compilation() == true) {
+                delete info;
+                if(remove(target.c_str()) != 0 )
+                    return EXIT_FAILURE;
+                return EXIT_SUCCESS;
+            }
+        }
+        delete info;
+        if(remove(target.c_str()) != 0 )
+            return EXIT_FAILURE;
+        return EXIT_FAILURE;
+    }
+    else {
+        delete info;
+        if(remove(target.c_str()) != 0 )
+            return EXIT_FAILURE;
+        return EXIT_FAILURE;
+    }
+}