aboutsummaryrefslogtreecommitdiffstats
path: root/src/Main.cxx
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2014-01-29 20:16:43 +0100
committerMax Kellermann <max@duempel.org>2014-01-30 18:47:05 +0100
commitc6725884bc155da431889468c86c546f0f64f9a1 (patch)
tree61d89751ecc98db9600620ac1788f32dea9214e1 /src/Main.cxx
parenta31738f6f1473f4f621bc16513ed0c6024749389 (diff)
downloadmpd-c6725884bc155da431889468c86c546f0f64f9a1.tar.gz
mpd-c6725884bc155da431889468c86c546f0f64f9a1.tar.xz
mpd-c6725884bc155da431889468c86c546f0f64f9a1.zip
db/update: convert to OO API
Move global variables into the new classes. That may allow multiple update threads for multiple databases one day.
Diffstat (limited to 'src/Main.cxx')
-rw-r--r--src/Main.cxx17
1 files changed, 11 insertions, 6 deletions
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();