diff options
author | Max Kellermann <max@musicpd.org> | 2018-07-17 23:34:45 +0200 |
---|---|---|
committer | Max Kellermann <max@musicpd.org> | 2018-07-17 23:40:14 +0200 |
commit | 113141bf2a6b7a444477e140854ec58fc3fe4fb9 (patch) | |
tree | a0b9a195ea390790b23f84361b076e81f8192e89 /src | |
parent | bcc1e51097b0bfac30f2ffb0d81c5b8a7cfd874f (diff) |
StateFileConfig: add attribute "restore_paused"
Diffstat (limited to 'src')
-rw-r--r-- | src/StateFile.cxx | 2 | ||||
-rw-r--r-- | src/StateFileConfig.cxx | 3 | ||||
-rw-r--r-- | src/StateFileConfig.hxx | 2 | ||||
-rw-r--r-- | src/queue/PlaylistState.cxx | 9 | ||||
-rw-r--r-- | src/queue/PlaylistState.hxx | 4 |
5 files changed, 12 insertions, 8 deletions
diff --git a/src/StateFile.cxx b/src/StateFile.cxx index 14618bc6e..a106a509c 100644 --- a/src/StateFile.cxx +++ b/src/StateFile.cxx @@ -129,7 +129,7 @@ try { while ((line = file.ReadLine()) != nullptr) { success = read_sw_volume_state(line, partition.outputs) || audio_output_state_read(line, partition.outputs) || - playlist_state_restore(line, file, song_loader, + playlist_state_restore(config, line, file, song_loader, partition.playlist, partition.pc); #ifdef ENABLE_DATABASE diff --git a/src/StateFileConfig.cxx b/src/StateFileConfig.cxx index 4e6cc1067..e4d412b30 100644 --- a/src/StateFileConfig.cxx +++ b/src/StateFileConfig.cxx @@ -30,7 +30,8 @@ constexpr std::chrono::steady_clock::duration StateFileConfig::DEFAULT_INTERVAL; StateFileConfig::StateFileConfig(const ConfigData &config) :path(config.GetPath(ConfigOption::STATE_FILE)), interval(config.GetUnsigned(ConfigOption::STATE_FILE_INTERVAL, - DEFAULT_INTERVAL)) + DEFAULT_INTERVAL)), + restore_paused(config.GetBool(ConfigOption::RESTORE_PAUSED, false)) { #ifdef ANDROID if (path.IsNull()) { diff --git a/src/StateFileConfig.hxx b/src/StateFileConfig.hxx index 1faa20caf..c8e5fc0f4 100644 --- a/src/StateFileConfig.hxx +++ b/src/StateFileConfig.hxx @@ -34,6 +34,8 @@ struct StateFileConfig { std::chrono::steady_clock::duration interval; + bool restore_paused; + explicit StateFileConfig(const ConfigData &config); bool IsEnabled() const noexcept { diff --git a/src/queue/PlaylistState.cxx b/src/queue/PlaylistState.cxx index 20668c5b0..33e701aca 100644 --- a/src/queue/PlaylistState.cxx +++ b/src/queue/PlaylistState.cxx @@ -27,12 +27,11 @@ #include "PlaylistError.hxx" #include "Playlist.hxx" #include "SingleMode.hxx" +#include "StateFileConfig.hxx" #include "queue/QueueSave.hxx" #include "fs/io/TextFile.hxx" #include "fs/io/BufferedOutputStream.hxx" #include "player/Control.hxx" -#include "config/Global.hxx" -#include "config/Option.hxx" #include "util/CharUtil.hxx" #include "util/StringAPI.hxx" #include "util/StringCompare.hxx" @@ -128,7 +127,8 @@ playlist_state_load(TextFile &file, const SongLoader &song_loader, } bool -playlist_state_restore(const char *line, TextFile &file, +playlist_state_restore(const StateFileConfig &config, + const char *line, TextFile &file, const SongLoader &song_loader, struct playlist &playlist, PlayerControl &pc) { @@ -183,8 +183,7 @@ playlist_state_restore(const char *line, TextFile &file, if (!playlist.queue.IsValidPosition(current)) current = 0; - if (state == PlayerState::PLAY && - config_get_bool(ConfigOption::RESTORE_PAUSED, false)) + if (state == PlayerState::PLAY && config.restore_paused) /* the user doesn't want MPD to auto-start playback after startup; fall back to "pause" */ diff --git a/src/queue/PlaylistState.hxx b/src/queue/PlaylistState.hxx index 0b4faf026..8c08a607b 100644 --- a/src/queue/PlaylistState.hxx +++ b/src/queue/PlaylistState.hxx @@ -25,6 +25,7 @@ #ifndef MPD_PLAYLIST_STATE_HXX #define MPD_PLAYLIST_STATE_HXX +struct StateFileConfig; struct playlist; struct PlayerControl; class TextFile; @@ -36,7 +37,8 @@ playlist_state_save(BufferedOutputStream &os, const playlist &playlist, PlayerControl &pc); bool -playlist_state_restore(const char *line, TextFile &file, +playlist_state_restore(const StateFileConfig &config, + const char *line, TextFile &file, const SongLoader &song_loader, playlist &playlist, PlayerControl &pc); |