diff --git a/core/core.cpp b/core/core.cpp index e57c75dd..ec7bd281 100644 --- a/core/core.cpp +++ b/core/core.cpp @@ -6,10 +6,10 @@ #include extern "C" { #include +#include } #include #include -#include void core :: init() diff --git a/core/tags/tags.cpp b/core/tags/tags.c similarity index 96% rename from core/tags/tags.cpp rename to core/tags/tags.c index de2ba9ea..09e1505f 100644 --- a/core/tags/tags.cpp +++ b/core/tags/tags.c @@ -1,12 +1,10 @@ -/** +/* * Copyright 2014 (c) Anna Schumaker. */ -extern "C" { #include #include #include #include -} #include #include diff --git a/core/tags/track.cpp b/core/tags/track.c similarity index 98% rename from core/tags/track.cpp rename to core/tags/track.c index 6010df38..8539d8f5 100644 --- a/core/tags/track.cpp +++ b/core/tags/track.c @@ -1,14 +1,12 @@ -/** +/* * Copyright 2014 (c) Anna Schumaker. */ -extern "C" { #include #include -#include -} #include #include +#include static struct database track_db; @@ -36,7 +34,7 @@ static gchar *__track_path(struct track *track) static struct track *__track_alloc() { - struct track *track = new struct track; + struct track *track = g_malloc(sizeof(struct track)); dbe_init(&track->tr_dbe, track); return track; @@ -97,7 +95,7 @@ static void track_free(struct db_entry *dbe) if (track->tr_library) track->tr_library->li_size--; - delete track; + g_free(track); } static void track_setup(struct db_entry *dbe) diff --git a/include/core/audio.h b/include/core/audio.h index 3d4a9d22..5979a063 100644 --- a/include/core/audio.h +++ b/include/core/audio.h @@ -4,7 +4,9 @@ #ifndef OCARINA_CORE_AUDIO_H #define OCARINA_CORE_AUDIO_H +extern "C" { #include +} #include #include diff --git a/include/core/queue.h b/include/core/queue.h index c03258eb..e5cbe522 100644 --- a/include/core/queue.h +++ b/include/core/queue.h @@ -6,8 +6,8 @@ extern "C" { #include -} #include +} #include #include diff --git a/include/core/tags/track.h b/include/core/tags/track.h index d730ef8e..02f1295c 100644 --- a/include/core/tags/track.h +++ b/include/core/tags/track.h @@ -1,25 +1,33 @@ -/** +/* * Copyright 2014 (c) Anna Schumaker. + * + * The Track tag is used to store information about tracks + * that have been added to the tag database. + * + * When writing a Track tag to disk, write as many fields as + * possible on one line before spilling over to a second: + * + * library number count + * | artist | year | length + * | | album| | month | | title + * | | | genre | | day| | | path + * | | | | | | | | | | | | + * ... 0 1 2 1 12 2015 10 15 13 232 Ocarina Medley | + * Hyrule Symphony/12 - Ocarina Medley.mp3 <--- + * ... 0 1 2 1 13 2015 10 15 10 288 Legend of Zelda Medley + * Hyrule Symphony/13 - Legend of Zelda Medly.mp3 */ #ifndef OCARINA_CORE_TAGS_TRACK_H #define OCARINA_CORE_TAGS_TRACK_H -extern "C" { #include #include #include #include #include #include -} - -#include -/** - * The Track tag is used to store information about tracks that - * have been added to the tag database. - */ struct track { struct album *tr_album; /* This track's associated album. */ struct artist *tr_artist; /* This track's associated artist. */ diff --git a/tests/core/audio.cpp b/tests/core/audio.cpp index 057a8738..07f8f138 100644 --- a/tests/core/audio.cpp +++ b/tests/core/audio.cpp @@ -4,9 +4,9 @@ #include extern "C" { #include +#include } #include -#include #include "test.h" struct track *TRACK_NULL = NULL; diff --git a/tests/core/deck.cpp b/tests/core/deck.cpp index e0bbe0b0..0f26f499 100644 --- a/tests/core/deck.cpp +++ b/tests/core/deck.cpp @@ -4,9 +4,9 @@ #include extern "C" { #include +#include } #include -#include #include "test.h" static Queue *Q_NULL = NULL; diff --git a/tests/core/library.cpp b/tests/core/library.cpp index 72ffc06f..84da5d4e 100644 --- a/tests/core/library.cpp +++ b/tests/core/library.cpp @@ -4,9 +4,9 @@ extern "C" { #include #include +#include } #include -#include #include "test.h" static Queue *Q_NULL = NULL; diff --git a/tests/core/playlist.cpp b/tests/core/playlist.cpp index 15befbea..fc4f6ebf 100644 --- a/tests/core/playlist.cpp +++ b/tests/core/playlist.cpp @@ -3,10 +3,10 @@ */ extern "C" { #include +#include } #include #include -#include #include "test.h" static index_entry *IDX_NULL = NULL; diff --git a/tests/core/queue.cpp b/tests/core/queue.cpp index 272bb59c..4180c58c 100644 --- a/tests/core/queue.cpp +++ b/tests/core/queue.cpp @@ -5,8 +5,8 @@ extern "C" { #include #include -} #include +} #include "test.h" diff --git a/tests/core/tags/Sconscript b/tests/core/tags/Sconscript index e4ff5169..461dceaf 100644 --- a/tests/core/tags/Sconscript +++ b/tests/core/tags/Sconscript @@ -17,7 +17,8 @@ res += [ TagTest("genre", "genre.c") ] res += [ TagTest("library", "library.c") ] env.UsePackage("taglib_c") -core_objs += [ env.Object("../../../core/tags/tags.cpp") ] -res += [ TagTest("track", "track.cpp") ] +core_objs += [ env.Object("../../../core/tags/tags.c") ] + +res += [ TagTest("track", "track.c") ] Return("res") diff --git a/tests/core/tags/track.cpp b/tests/core/tags/track.c similarity index 89% rename from tests/core/tags/track.cpp rename to tests/core/tags/track.c index 20471e45..cb718057 100644 --- a/tests/core/tags/track.cpp +++ b/tests/core/tags/track.c @@ -1,16 +1,13 @@ -/** +/* * Copyright 2014 (c) Anna Schumaker. */ -extern "C" { #include #include -} #include #include -#include "../test.h" +#include +#include -#include -#include static struct track *test_alloc(const gchar *key) { @@ -70,10 +67,10 @@ static void test_track() struct tm *now = localtime(&rawtime); struct library *library; struct track *track; + struct file f; gchar *date; - file f; - std::setlocale(LC_TIME, "C"); + setlocale(LC_TIME, "C"); filter_init(); tags_init(); file_init(&f, "track_tag", 0); @@ -127,19 +124,19 @@ static void test_track_filter() struct set search = SET_INIT(); filter_search("Title Theme", &search); - test_equal(set_size(&search), (size_t)1); - test_equal(set_has(&search, 0), true); + test_equal(set_size(&search), 1); + test_equal(set_has(&search, 0), (bool)true); filter_search("Koji Kondo", &search); - test_equal(set_size(&search), (size_t)1); - test_equal(set_has(&search, 0), true); + test_equal(set_size(&search), 1); + test_equal(set_has(&search, 0), (bool)true); filter_search("Hyrule Symphony", &search); - test_equal(set_size(&search), (size_t)1); - test_equal(set_has(&search, 0), true); + test_equal(set_size(&search), 1); + test_equal(set_has(&search, 0), (bool)true); filter_search("No Track", &search); - test_equal(set_size(&search), (size_t)0); + test_equal(set_size(&search), 0); set_deinit(&search); } @@ -171,9 +168,9 @@ static void test_track_db() track = track_add(library, path); test_verify_track(track); - test_equal(track_add(library, path), NULL); - test_equal(track_get(0), track); - test_equal(track_get(1), NULL); + test_equal((void *)track_add(library, path), NULL); + test_equal((void *)track_get(0), (void *)track); + test_equal((void *)track_get(1), NULL); test_equal(track_db_get()->db_size, 1); db_init(&track_db, "track.db", false, track_ops); @@ -189,15 +186,15 @@ static void test_track_db() test_equal(track_db_get()->db_size, 0); track = track_add(library, path); - test_not_equal(track, NULL); + test_not_equal((void *)track, NULL); track = track_add(library, "tests/Music/Hyrule Symphony/02 - Kokiri Forest.ogg"); - test_not_equal(track, NULL); + test_not_equal((void *)track, NULL); test_equal(track_db_get()->db_size, 2); track = track_add(library, "tests/Music/invalid_track"); - test_equal(track, NULL); + test_equal((void *)track, NULL); test_equal(track_db_get()->db_size, 2); track_remove_all(library);