core/tags/album: Add pointer to genre tag
Albums tend to have a single genre for all tracks, so it makes more sense for an album to point to genre information. Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
This commit is contained in:
parent
629f81da17
commit
65b547f60b
|
@ -171,6 +171,7 @@ static struct album *__album_alloc(gchar *name, unsigned int year)
|
|||
album->al_name = name;
|
||||
album->al_tokens = g_str_tokenize_and_fold(name, NULL, &album->al_alts);
|
||||
album->al_artist = NULL;
|
||||
album->al_genre = NULL;
|
||||
|
||||
if (!album_artwork_exists(album))
|
||||
idle_schedule(IDLE_ASYNC, IDLE_FUNC(__album_fetch_artwork), album);
|
||||
|
|
|
@ -72,6 +72,8 @@ struct db_entry *track_alloc(const gchar *key)
|
|||
|
||||
if (track->tr_album->al_artist == NULL)
|
||||
track->tr_album->al_artist = track->tr_artist;
|
||||
if (track->tr_album->al_genre == NULL)
|
||||
track->tr_album->al_genre = track->tr_genre;
|
||||
|
||||
unplayed_count++;
|
||||
track->tr_count = 0;
|
||||
|
@ -140,6 +142,8 @@ static struct db_entry *track_read(struct file *file)
|
|||
|
||||
if (track->tr_album->al_artist == NULL)
|
||||
track->tr_album->al_artist = track->tr_artist;
|
||||
if (track->tr_album->al_genre == NULL)
|
||||
track->tr_album->al_genre = track->tr_genre;
|
||||
|
||||
track->tr_title = file_readl(file);
|
||||
track->tr_tokens = g_str_tokenize_and_fold(track->tr_title, NULL,
|
||||
|
|
|
@ -23,6 +23,7 @@ struct album {
|
|||
gchar **al_tokens; /* This album's tokenized strings. */
|
||||
gchar **al_alts; /* This album's alternate ascii tokens. */
|
||||
struct artist *al_artist;
|
||||
struct genre *al_genre;
|
||||
struct db_entry al_dbe;
|
||||
};
|
||||
|
||||
|
|
|
@ -21,6 +21,8 @@ static void test_verify_tags(struct track *track)
|
|||
test_equal(track->tr_album->al_year, 1998);
|
||||
test_equal(track->tr_artist->ar_name, "Koji Kondo");
|
||||
test_equal(track->tr_genre->ge_name, "Game");
|
||||
test_equal((void *)track->tr_album->al_artist, (void *)track->tr_artist);
|
||||
test_equal((void *)track->tr_album->al_genre, (void *)track->tr_genre);
|
||||
test_equal(track->tr_library->li_path, "tests/Music");
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue