799a8d34b5
I needed to bump the track comparison fields by one so I can use signed values to indicate sort order. I updated core/library.cpp to add and subtract one as needed. Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
111 lines
3.7 KiB
C
111 lines
3.7 KiB
C
/*
|
|
* 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
|
|
|
|
#include <core/containers/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>
|
|
|
|
|
|
enum compare_t {
|
|
COMPARE_ARTIST = 1, /* Compare tracks by artist name. */
|
|
COMPARE_ALBUM = 2, /* Compare tracks by album name. */
|
|
COMPARE_COUNT = 3, /* Compare tracks by play count. */
|
|
COMPARE_GENRE = 4, /* Compare tracks by genre. */
|
|
COMPARE_LENGTH = 5, /* Compare tracks by length. */
|
|
COMPARE_PLAYED = 6, /* Compare tracks by last played date. */
|
|
COMPARE_TITLE = 7, /* Compare tracks by title. */
|
|
COMPARE_TRACK = 8, /* Compare tracks by track number. */
|
|
COMPARE_YEAR = 9, /* Compare tracks by year. */
|
|
};
|
|
|
|
|
|
struct track {
|
|
struct album *tr_album; /* This track's associated album. */
|
|
struct artist *tr_artist; /* This track's associated artist. */
|
|
struct genre *tr_genre; /* This track's associated genre. */
|
|
struct library *tr_library; /* This track's associated library. */
|
|
|
|
unsigned int tr_count; /* This track's play count. */
|
|
unsigned int tr_length; /* This track's length, in seconds. */
|
|
unsigned int tr_track; /* This track's track number. */
|
|
|
|
struct date tr_date; /* This track's last-played date. */
|
|
gchar *tr_path; /* This track's path, relative to the library. */
|
|
gchar *tr_title; /* This track's title. */
|
|
gchar *tr_lower; /* This track's title (lowercased). */
|
|
|
|
struct db_entry tr_dbe;
|
|
};
|
|
|
|
#define TRACK(dbe) ((struct track *)DBE_DATA(dbe))
|
|
|
|
|
|
/* Called to initialize the track database. */
|
|
void track_db_init();
|
|
|
|
/* Called to clean up the track database. */
|
|
void track_db_deinit();
|
|
|
|
/* Called to commit the track database. */
|
|
void track_db_commit();
|
|
|
|
/* Called to access the track database. */
|
|
const struct database *track_db_get();
|
|
|
|
/* Called to add a track tag to the database. */
|
|
struct track *track_add(struct library *, const gchar *);
|
|
|
|
/* Called to remove a specific track tag. */
|
|
void track_remove(struct track *);
|
|
|
|
/* Called to remove all tracks associated with a specific library. */
|
|
void track_remove_all(struct library *);
|
|
|
|
/* Called to get a track tag with a specific index. */
|
|
struct track *track_get(const unsigned int);
|
|
|
|
/* Called to compare two track tags */
|
|
int track_compare(struct track *, struct track *, enum compare_t);
|
|
|
|
/*
|
|
* Called to find the full path of the track tag.
|
|
* This function returns a new string that MUST be freed with g_free().
|
|
*/
|
|
gchar *track_path(struct track *);
|
|
|
|
/* Called to mark a track tag as played. */
|
|
void track_played(struct track *);
|
|
|
|
/*
|
|
* Called to find the date that this track was last played.
|
|
* This function returns a new string that MUST be freed with g_free().
|
|
*/
|
|
gchar *track_last_play(struct track *);
|
|
|
|
#ifdef CONFIG_TESTING
|
|
const struct db_ops *test_track_ops();
|
|
#endif /* CONFIG_TESTING */
|
|
#endif /* OCARINA_CORE_TAGS_TRACK_H */
|