2018-04-10 02:53:12 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
#include <queues/task_queue.h>
|
|
|
|
|
|
|
|
#include "../../../core_info.h"
|
|
|
|
#include "../../../tasks/tasks_internal.h"
|
|
|
|
|
2018-04-10 03:16:33 +00:00
|
|
|
static bool loop_active = true;
|
|
|
|
|
|
|
|
static void main_msg_queue_push(const char *msg,
|
|
|
|
unsigned prio, unsigned duration,
|
|
|
|
bool flush)
|
|
|
|
{
|
|
|
|
fprintf(stderr, "MSGQ: %s\n", msg);
|
|
|
|
}
|
|
|
|
|
2019-02-03 23:49:35 +00:00
|
|
|
/*
|
2018-04-10 02:53:12 +00:00
|
|
|
* return codes -
|
|
|
|
* graceful exit: 1
|
|
|
|
* normal exit: 0
|
|
|
|
* error exit: -1
|
|
|
|
*/
|
|
|
|
|
2018-04-10 03:16:33 +00:00
|
|
|
static void main_db_cb(void *task_data, void *user_data, const char *err)
|
|
|
|
{
|
|
|
|
fprintf(stderr, "DB CB: %s\n", err);
|
|
|
|
loop_active = false;
|
|
|
|
}
|
|
|
|
|
2018-04-10 02:53:12 +00:00
|
|
|
int main(int argc, char *argv[])
|
|
|
|
{
|
|
|
|
const char *db_dir = NULL;
|
|
|
|
const char *core_info_dir = NULL;
|
|
|
|
const char *core_dir = NULL;
|
|
|
|
const char *input_dir = NULL;
|
|
|
|
const char *playlist_dir = NULL;
|
2018-04-10 03:26:47 +00:00
|
|
|
#if defined(_WIN32)
|
2018-04-10 02:53:12 +00:00
|
|
|
const char *exts = "dll";
|
2018-04-10 03:26:47 +00:00
|
|
|
#elif defined(__MACH__)
|
|
|
|
const char *exts = "dylib";
|
2018-04-10 03:20:19 +00:00
|
|
|
#else
|
|
|
|
const char *exts = "so";
|
|
|
|
#endif
|
2018-04-10 02:53:12 +00:00
|
|
|
|
|
|
|
if (argc < 6)
|
|
|
|
{
|
|
|
|
fprintf(stderr, "Usage: %s <database dir> <core dir> <core info dir> <input dir> <playlist dir>\n", argv[0]);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
db_dir = argv[1];
|
|
|
|
core_dir = argv[2];
|
|
|
|
core_info_dir = argv[3];
|
|
|
|
input_dir = argv[4];
|
|
|
|
playlist_dir = argv[5];
|
|
|
|
|
2018-04-10 03:16:33 +00:00
|
|
|
fprintf(stderr, "RDB database dir: %s\n", db_dir);
|
|
|
|
fprintf(stderr, "Core dir: %s\n", core_dir);
|
|
|
|
fprintf(stderr, "Core info dir: %s\n", core_info_dir);
|
|
|
|
fprintf(stderr, "Input dir: %s\n", input_dir);
|
|
|
|
fprintf(stderr, "Playlist dir: %s\n", playlist_dir);
|
2019-05-22 02:53:36 +00:00
|
|
|
#ifdef HAVE_THREADS
|
|
|
|
task_queue_init(true /* threaded enable */, main_msg_queue_push);
|
|
|
|
#else
|
2018-04-10 03:16:33 +00:00
|
|
|
task_queue_init(false /* threaded enable */, main_msg_queue_push);
|
2019-05-22 02:53:36 +00:00
|
|
|
#endif
|
2021-05-06 10:58:45 +00:00
|
|
|
core_info_init_list(core_info_dir, core_dir, exts, true, false);
|
2018-04-10 02:53:12 +00:00
|
|
|
|
2018-04-10 03:16:33 +00:00
|
|
|
task_push_dbscan(playlist_dir, db_dir, input_dir, true,
|
|
|
|
true, main_db_cb);
|
|
|
|
|
|
|
|
while (loop_active)
|
|
|
|
task_queue_check();
|
2018-04-10 02:53:12 +00:00
|
|
|
|
2018-04-10 03:16:33 +00:00
|
|
|
fprintf(stderr, "Exit loop\n");
|
2018-04-10 02:53:12 +00:00
|
|
|
|
|
|
|
core_info_deinit_list();
|
|
|
|
task_queue_deinit();
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|