2015-11-12 10:42:21 -05:00
|
|
|
/*
|
2014-11-16 10:08:12 -05:00
|
|
|
* Copyright 2014 (c) Anna Schumaker.
|
|
|
|
*/
|
2016-08-12 11:14:51 -04:00
|
|
|
#include <core/idle.h>
|
2014-11-16 14:47:51 -05:00
|
|
|
#include <core/tags/album.h>
|
2014-11-16 10:08:12 -05:00
|
|
|
#include <core/tags/artist.h>
|
2014-11-16 15:15:32 -05:00
|
|
|
#include <core/tags/genre.h>
|
2014-11-17 08:30:54 -05:00
|
|
|
#include <core/tags/library.h>
|
2014-11-16 10:08:12 -05:00
|
|
|
#include <core/tags/tags.h>
|
2014-12-02 08:16:22 -05:00
|
|
|
#include <core/tags/track.h>
|
2014-11-16 10:08:12 -05:00
|
|
|
|
2016-08-12 11:14:51 -04:00
|
|
|
static bool tags_upgrade_done(void *data)
|
|
|
|
{
|
|
|
|
if (album_db_upgrade_done())
|
|
|
|
track_db_commit();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2015-11-12 10:24:27 -05:00
|
|
|
void tags_init()
|
2014-11-16 10:08:12 -05:00
|
|
|
{
|
2015-10-22 13:06:12 -04:00
|
|
|
artist_db_init();
|
2015-09-28 08:18:39 -04:00
|
|
|
genre_db_init();
|
2016-08-12 11:14:51 -04:00
|
|
|
album_db_init();
|
2015-09-28 09:45:50 -04:00
|
|
|
library_db_init();
|
2015-10-25 04:46:56 -04:00
|
|
|
track_db_init();
|
2016-08-12 11:14:51 -04:00
|
|
|
|
|
|
|
idle_schedule(IDLE_SYNC, tags_upgrade_done, NULL);
|
2015-10-25 04:46:56 -04:00
|
|
|
}
|
|
|
|
|
2015-11-12 10:29:36 -05:00
|
|
|
void tags_deinit()
|
2015-10-25 04:46:56 -04:00
|
|
|
{
|
|
|
|
track_db_deinit();
|
|
|
|
library_db_deinit();
|
|
|
|
genre_db_deinit();
|
|
|
|
album_db_deinit();
|
2016-05-03 07:54:54 -04:00
|
|
|
artist_db_deinit();
|
2014-11-16 10:08:12 -05:00
|
|
|
}
|
2016-08-12 14:00:11 -04:00
|
|
|
|
|
|
|
bool tags_defragment(void *data)
|
|
|
|
{
|
|
|
|
bool album = album_db_defrag();
|
|
|
|
bool library = library_db_defrag();
|
|
|
|
bool track = track_db_defrag();
|
|
|
|
|
2016-09-26 15:40:54 -04:00
|
|
|
if (library)
|
|
|
|
track_db_rekey();
|
2016-08-12 14:00:11 -04:00
|
|
|
if (album || library || track)
|
|
|
|
track_db_commit();
|
|
|
|
return track;
|
|
|
|
}
|