2015-12-17 10:32:01 -05:00
|
|
|
/*
|
2014-06-29 10:36:00 -04:00
|
|
|
* Copyright 2014 (c) Anna Schumaker.
|
|
|
|
*/
|
|
|
|
#include <core/audio.h>
|
|
|
|
#include <core/core.h>
|
2016-04-30 10:11:48 -04:00
|
|
|
#include <core/idle.h>
|
2015-12-10 13:59:21 -05:00
|
|
|
#include <core/playlist.h>
|
2016-03-29 08:39:00 -04:00
|
|
|
#include <core/settings.h>
|
2015-11-12 10:42:21 -05:00
|
|
|
#include <core/tags/tags.h>
|
2014-06-29 10:36:00 -04:00
|
|
|
|
|
|
|
|
2016-08-12 14:00:11 -04:00
|
|
|
static bool core_defragment(void *data)
|
|
|
|
{
|
|
|
|
if (tags_defragment()) {
|
|
|
|
playlist_save();
|
|
|
|
audio_save();
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2015-12-17 10:00:42 -05:00
|
|
|
void core_init(int *argc, char ***argv, struct core_init_data *init)
|
2014-06-29 10:36:00 -04:00
|
|
|
{
|
2016-07-28 16:15:29 -04:00
|
|
|
#ifdef CONFIG_TESTING
|
2016-09-06 08:15:26 -04:00
|
|
|
if (init->idle_async == false)
|
|
|
|
idle_init_sync();
|
|
|
|
else
|
2016-07-28 16:15:29 -04:00
|
|
|
#endif /* CONFIG_TESTING */
|
2016-09-06 08:15:26 -04:00
|
|
|
idle_init();
|
2016-03-29 08:39:00 -04:00
|
|
|
settings_init();
|
2015-11-12 10:24:27 -05:00
|
|
|
tags_init();
|
2016-09-17 09:30:11 -04:00
|
|
|
playlist_init(init->playlist_ops, init->playlist_cb);
|
2015-12-15 10:23:15 -05:00
|
|
|
audio_init(argc, argv, init->audio_ops);
|
2016-08-12 14:00:11 -04:00
|
|
|
|
|
|
|
idle_schedule(IDLE_SYNC, core_defragment, NULL);
|
2014-06-29 10:36:00 -04:00
|
|
|
}
|
2015-11-12 10:45:30 -05:00
|
|
|
|
2015-12-17 10:06:40 -05:00
|
|
|
void core_deinit()
|
2015-11-12 10:45:30 -05:00
|
|
|
{
|
2015-12-15 10:46:48 -05:00
|
|
|
audio_deinit();
|
2015-12-11 09:21:10 -05:00
|
|
|
playlist_deinit();
|
2015-11-12 10:45:30 -05:00
|
|
|
tags_deinit();
|
2016-03-29 08:39:00 -04:00
|
|
|
settings_deinit();
|
2016-04-30 10:11:48 -04:00
|
|
|
idle_deinit();
|
2015-11-12 10:45:30 -05:00
|
|
|
}
|