diff options
author | Max Kellermann <max@duempel.org> | 2014-08-24 12:59:45 +0200 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2014-08-24 13:24:20 +0200 |
commit | 42af040fbd0cd2b9942f02ace3462ee8ac41d3ac (patch) | |
tree | 77501fc829969fe8bf07739329ca5431fbdded29 /src | |
parent | d383d617c2d16bda9f32fe31e0171a59f4601f89 (diff) | |
download | mpd-42af040fbd0cd2b9942f02ace3462ee8ac41d3ac.tar.gz mpd-42af040fbd0cd2b9942f02ace3462ee8ac41d3ac.tar.xz mpd-42af040fbd0cd2b9942f02ace3462ee8ac41d3ac.zip |
StateFile: configurable interval
Diffstat (limited to '')
-rw-r--r-- | src/Main.cxx | 5 | ||||
-rw-r--r-- | src/StateFile.cxx | 5 | ||||
-rw-r--r-- | src/StateFile.hxx | 7 | ||||
-rw-r--r-- | src/config/ConfigOption.hxx | 1 | ||||
-rw-r--r-- | src/config/ConfigTemplates.cxx | 1 |
5 files changed, 15 insertions, 4 deletions
diff --git a/src/Main.cxx b/src/Main.cxx index d8dbdb5d2..d8384abfb 100644 --- a/src/Main.cxx +++ b/src/Main.cxx @@ -279,7 +279,10 @@ glue_state_file_init(Error &error) #endif } - state_file = new StateFile(std::move(path_fs), + unsigned interval = config_get_unsigned(CONF_STATE_FILE_INTERVAL, + StateFile::DEFAULT_INTERVAL); + + state_file = new StateFile(std::move(path_fs), interval, *instance->partition, *instance->event_loop); state_file->Read(); diff --git a/src/StateFile.cxx b/src/StateFile.cxx index e0f0cedb1..7e9e35cc3 100644 --- a/src/StateFile.cxx +++ b/src/StateFile.cxx @@ -36,10 +36,11 @@ static constexpr Domain state_file_domain("state_file"); -StateFile::StateFile(AllocatedPath &&_path, +StateFile::StateFile(AllocatedPath &&_path, unsigned _interval, Partition &_partition, EventLoop &_loop) :TimeoutMonitor(_loop), path(std::move(_path)), path_utf8(path.ToUTF8()), + interval(_interval), partition(_partition), prev_volume_version(0), prev_output_version(0), prev_playlist_version(0) @@ -137,7 +138,7 @@ void StateFile::CheckModified() { if (!IsActive() && IsModified()) - ScheduleSeconds(2 * 60); + ScheduleSeconds(interval); } void diff --git a/src/StateFile.hxx b/src/StateFile.hxx index 4bacb3449..15ba13b97 100644 --- a/src/StateFile.hxx +++ b/src/StateFile.hxx @@ -34,6 +34,8 @@ class StateFile final : private TimeoutMonitor { const AllocatedPath path; const std::string path_utf8; + const unsigned interval; + Partition &partition; /** @@ -44,7 +46,10 @@ class StateFile final : private TimeoutMonitor { prev_playlist_version; public: - StateFile(AllocatedPath &&path, Partition &partition, EventLoop &loop); + static constexpr unsigned DEFAULT_INTERVAL = 2 * 60; + + StateFile(AllocatedPath &&path, unsigned interval, + Partition &partition, EventLoop &loop); void Read(); void Write(); diff --git a/src/config/ConfigOption.hxx b/src/config/ConfigOption.hxx index 506c9e9dc..8eb4c7eaf 100644 --- a/src/config/ConfigOption.hxx +++ b/src/config/ConfigOption.hxx @@ -32,6 +32,7 @@ enum ConfigOption { CONF_LOG_FILE, CONF_PID_FILE, CONF_STATE_FILE, + CONF_STATE_FILE_INTERVAL, CONF_RESTORE_PAUSED, CONF_USER, CONF_GROUP, diff --git a/src/config/ConfigTemplates.cxx b/src/config/ConfigTemplates.cxx index 8eaa22bdd..58ee56425 100644 --- a/src/config/ConfigTemplates.cxx +++ b/src/config/ConfigTemplates.cxx @@ -32,6 +32,7 @@ const ConfigTemplate config_templates[] = { { "log_file", false, false }, { "pid_file", false, false }, { "state_file", false, false }, + { "state_file_interval", false, false }, { "restore_paused", false, false }, { "user", false, false }, { "group", false, false }, |