core/tags/track: Convert file to C
Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
This commit is contained in:
parent
b5caf6faed
commit
a5963a553e
|
@ -6,10 +6,10 @@
|
|||
#include <core/deck.h>
|
||||
extern "C" {
|
||||
#include <core/filter.h>
|
||||
#include <core/tags/tags.h>
|
||||
}
|
||||
#include <core/library.h>
|
||||
#include <core/playlist.h>
|
||||
#include <core/tags/tags.h>
|
||||
|
||||
|
||||
void core :: init()
|
||||
|
|
|
@ -1,12 +1,10 @@
|
|||
/**
|
||||
/*
|
||||
* Copyright 2014 (c) Anna Schumaker.
|
||||
*/
|
||||
extern "C" {
|
||||
#include <core/tags/album.h>
|
||||
#include <core/tags/artist.h>
|
||||
#include <core/tags/genre.h>
|
||||
#include <core/tags/library.h>
|
||||
}
|
||||
#include <core/tags/tags.h>
|
||||
#include <core/tags/track.h>
|
||||
|
|
@ -1,14 +1,12 @@
|
|||
/**
|
||||
/*
|
||||
* Copyright 2014 (c) Anna Schumaker.
|
||||
*/
|
||||
extern "C" {
|
||||
#include <core/filter.h>
|
||||
#include <core/string.h>
|
||||
#include <taglib/tag_c.h>
|
||||
}
|
||||
#include <core/tags/track.h>
|
||||
|
||||
#include <glib.h>
|
||||
#include <taglib/tag_c.h>
|
||||
|
||||
|
||||
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)
|
|
@ -4,7 +4,9 @@
|
|||
#ifndef OCARINA_CORE_AUDIO_H
|
||||
#define OCARINA_CORE_AUDIO_H
|
||||
|
||||
extern "C" {
|
||||
#include <core/tags/track.h>
|
||||
}
|
||||
#include <string>
|
||||
#include <stdint.h>
|
||||
|
||||
|
|
|
@ -6,8 +6,8 @@
|
|||
|
||||
extern "C" {
|
||||
#include <core/file.h>
|
||||
}
|
||||
#include <core/tags/track.h>
|
||||
}
|
||||
|
||||
#include <vector>
|
||||
#include <list>
|
||||
|
|
|
@ -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 <core/database.h>
|
||||
#include <core/date.h>
|
||||
#include <core/tags/album.h>
|
||||
#include <core/tags/artist.h>
|
||||
#include <core/tags/genre.h>
|
||||
#include <core/tags/library.h>
|
||||
}
|
||||
|
||||
#include <string>
|
||||
|
||||
|
||||
/**
|
||||
* 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. */
|
||||
|
|
|
@ -4,9 +4,9 @@
|
|||
#include <core/audio.h>
|
||||
extern "C" {
|
||||
#include <core/filter.h>
|
||||
#include <core/tags/tags.h>
|
||||
}
|
||||
#include <core/library.h>
|
||||
#include <core/tags/tags.h>
|
||||
#include "test.h"
|
||||
|
||||
struct track *TRACK_NULL = NULL;
|
||||
|
|
|
@ -4,9 +4,9 @@
|
|||
#include <core/deck.h>
|
||||
extern "C" {
|
||||
#include <core/filter.h>
|
||||
#include <core/tags/tags.h>
|
||||
}
|
||||
#include <core/library.h>
|
||||
#include <core/tags/tags.h>
|
||||
#include "test.h"
|
||||
|
||||
static Queue *Q_NULL = NULL;
|
||||
|
|
|
@ -4,9 +4,9 @@
|
|||
extern "C" {
|
||||
#include <core/filter.h>
|
||||
#include <core/idle.h>
|
||||
#include <core/tags/tags.h>
|
||||
}
|
||||
#include <core/library.h>
|
||||
#include <core/tags/tags.h>
|
||||
#include "test.h"
|
||||
|
||||
static Queue *Q_NULL = NULL;
|
||||
|
|
|
@ -3,10 +3,10 @@
|
|||
*/
|
||||
extern "C" {
|
||||
#include <core/filter.h>
|
||||
#include <core/tags/tags.h>
|
||||
}
|
||||
#include <core/library.h>
|
||||
#include <core/playlist.h>
|
||||
#include <core/tags/tags.h>
|
||||
#include "test.h"
|
||||
|
||||
static index_entry *IDX_NULL = NULL;
|
||||
|
|
|
@ -5,8 +5,8 @@
|
|||
extern "C" {
|
||||
#include <core/filter.h>
|
||||
#include <core/random.h>
|
||||
}
|
||||
#include <core/tags/tags.h>
|
||||
}
|
||||
#include "test.h"
|
||||
|
||||
|
||||
|
|
|
@ -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")
|
||||
|
|
|
@ -1,16 +1,13 @@
|
|||
/**
|
||||
/*
|
||||
* Copyright 2014 (c) Anna Schumaker.
|
||||
*/
|
||||
extern "C" {
|
||||
#include <core/filter.h>
|
||||
#include <core/string.h>
|
||||
}
|
||||
#include <core/tags/tags.h>
|
||||
#include <core/tags/track.h>
|
||||
#include "../test.h"
|
||||
#include <tests/test.h>
|
||||
#include <locale.h>
|
||||
|
||||
#include <set>
|
||||
#include <sstream>
|
||||
|
||||
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);
|
Loading…
Reference in New Issue