From c6725884bc155da431889468c86c546f0f64f9a1 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Wed, 29 Jan 2014 20:16:43 +0100 Subject: db/update: convert to OO API Move global variables into the new classes. That may allow multiple update threads for multiple databases one day. --- src/Main.cxx | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'src/Main.cxx') diff --git a/src/Main.cxx b/src/Main.cxx index ab70c875c..2c5d183ea 100644 --- a/src/Main.cxx +++ b/src/Main.cxx @@ -23,7 +23,7 @@ #include "CommandLine.hxx" #include "PlaylistFile.hxx" #include "PlaylistGlobal.hxx" -#include "db/update/UpdateGlue.hxx" +#include "db/update/Service.hxx" #include "MusicChunk.hxx" #include "StateFile.hxx" #include "PlayerThread.hxx" @@ -448,10 +448,13 @@ int mpd_main(int argc, char *argv[]) } decoder_plugin_init_all(); - update_global_init(); const bool create_db = !glue_db_init_and_load(); + instance->update = db_is_simple() + ? new UpdateService(*main_loop) + : nullptr; + glue_sticker_init(); command_init(); @@ -490,7 +493,7 @@ int mpd_main(int argc, char *argv[]) if (create_db) { /* the database failed to load: recreate the database */ - unsigned job = update_enqueue("", true); + unsigned job = instance->update->Enqueue("", true); if (job == 0) FatalError("directory update failed"); } @@ -504,8 +507,9 @@ int mpd_main(int argc, char *argv[]) if (config_get_bool(CONF_AUTO_UPDATE, false)) { #ifdef ENABLE_INOTIFY - if (mapper_has_music_directory()) - mpd_inotify_init(*main_loop, + if (mapper_has_music_directory() && + instance->update != nullptr) + mpd_inotify_init(*main_loop, *instance->update, config_get_unsigned(CONF_AUTO_UPDATE_DEPTH, G_MAXUINT)); #else @@ -558,6 +562,8 @@ int mpd_main(int argc, char *argv[]) } #endif + delete instance->update; + const clock_t start = clock(); DatabaseGlobalDeinit(); FormatDebug(main_domain, @@ -575,7 +581,6 @@ int mpd_main(int argc, char *argv[]) mapper_finish(); delete instance->partition; command_finish(); - update_global_finish(); decoder_plugin_deinit_all(); #ifdef ENABLE_ARCHIVE archive_plugin_deinit_all(); -- cgit v1.2.3