core/tags/track: Move track_add() out of the tags namespace

Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
This commit is contained in:
Anna Schumaker 2015-09-28 16:03:58 -04:00
parent c8061e2868
commit 83a945d3da
4 changed files with 15 additions and 28 deletions

View File

@ -95,7 +95,7 @@ static void tag_track(struct library *library, const std::string &filepath)
tag = ref.tag();
audio = ref.audioProperties();
track = tags :: add_track(
track = track_add(
album_find(tag->album().stripWhiteSpace().to8Bit(true), tag->year()),
artist_find(tag->artist().stripWhiteSpace().to8Bit(true)),
genre_find(tag->genre().stripWhiteSpace().to8Bit(true)),

View File

@ -152,10 +152,10 @@ void tags :: init_track_db()
db_load(&track_db);
}
struct track *tags :: add_track(struct album *album, struct artist *artist,
struct genre *genre, struct library *library,
const std::string &filepath, const std::string &name,
unsigned int length, unsigned int track)
struct track *track_add(struct album *album, struct artist *artist,
struct genre *genre, struct library *library,
const std::string &filepath, const std::string &name,
unsigned int length, unsigned int track)
{
std::string path = filepath.substr(library->primary_key().size() + 1);
if (db_get(&track_db, make_key(library, path).c_str()))

View File

@ -120,24 +120,6 @@ namespace tags
/** Called to read the track_db from disk. */
void init_track_db();
/**
* Called to create a new Track tag.
*
* @param album The album containing this track.
* @param artist The artist performing this track.
* @param genre The genre describing this track.
* @param library The library containing this track.
* @param filepath The path of this track, relative to the library root.
* @param name The name (title) of this track.
* @param length The length of this track (in seconds).
* @param track The track number of this track.
* @return A new Track tag, or NULL if this Track is already in
* the track_db.
*/
struct track *add_track(struct album *, struct artist *, struct genre *,
struct library *, const std::string &,
const std::string &, unsigned int, unsigned int);
/**
* Called to remove a Track tag from the database.
*
@ -165,6 +147,11 @@ namespace tags
}
/* Called to add a track tag to the database. */
struct track *track_add(struct album *, struct artist *, struct genre *,
struct library *, const std::string &,
const std::string &, unsigned int, unsigned int);
/* Called to get a track tag with a specific index. */
struct track *track_get(const unsigned int);

View File

@ -122,18 +122,18 @@ static void test_track_tag_lookup()
unsigned int index;
struct track *a, *b;
a = tags :: add_track(album, artist, genre, library,
a = track_add(album, artist, genre, library,
MUSIC_DIR + "/Hyrule Symphony/13 - Legend of Zelda Medley.mp3",
"Legend of Zelda Medley", 288, 13);
test_not_equal(a, (struct track *)NULL);
verify_track_tag(a, 1);
b = tags :: add_track(album, artist, genre, library,
b = track_add(album, artist, genre, library,
MUSIC_DIR + "/Hyrule Symphony/13 - Legend of Zelda Medley.mp3",
"Legend of Zelda Medley", 288, 13);
test_equal(b, (struct track *)NULL);
b = tags :: add_track(album, artist, genre, library,
b = track_add(album, artist, genre, library,
MUSIC_DIR + "/Hyrule Symphony/12 - Ocarina Medley.mp3",
"Ocarina Medley", 232, 12);
test_not_equal(b, a);
@ -160,7 +160,7 @@ static void test_track_tag_lookup()
test_equal(tags :: track_size(), b->index() + 1);
a = tags :: add_track(album, artist, genre, library,
a = track_add(album, artist, genre, library,
MUSIC_DIR + "/Hyrule Symphony/13 - Legend of Zelda Medley.mp3",
"Legend of Zelda Medley", 288, 13);
test_not_equal(a, (struct track *)NULL);
@ -176,7 +176,7 @@ static void test_track_tag_locale()
{
time_t rawtime = time(NULL);
struct tm *now = localtime(&rawtime);
struct track *track = tags :: add_track(album, artist, genre, library,
struct track *track = track_add(album, artist, genre, library,
MUSIC_DIR + "/Hyrule Symphony/6 - Kakariko Village.mp3",
"Kakariko Village", 186, 6);
gchar *date;