Options: convert lyrics_timeout to std::chrono::steady_clock::duration
authorMax Kellermann <max@musicpd.org>
Wed, 26 Sep 2018 23:41:35 +0000 (01:41 +0200)
committerMax Kellermann <max@musicpd.org>
Wed, 26 Sep 2018 23:41:35 +0000 (01:41 +0200)
src/LyricsPage.cxx
src/Options.hxx
src/conf.cxx

index a4ddc74..b5da4ef 100644 (file)
@@ -258,7 +258,7 @@ LyricsPage::OnTimeout(const boost::system::error_code &error) noexcept
        loader = nullptr;
 
        screen_status_printf(_("Lyrics timeout occurred after %d seconds"),
-                            options.lyrics_timeout);
+                            (int)std::chrono::duration_cast<std::chrono::seconds>(options.lyrics_timeout).count());
 }
 
 void
@@ -276,9 +276,9 @@ LyricsPage::Load(const struct mpd_song *_song)
        loader = lyrics_load(get_io_service(),
                             artist, title, PluginCallback, this);
 
-       if (options.lyrics_timeout != 0) {
+       if (options.lyrics_timeout > std::chrono::steady_clock::duration::zero()) {
                boost::system::error_code error;
-               loader_timeout.expires_from_now(std::chrono::seconds(options.lyrics_timeout),
+               loader_timeout.expires_from_now(options.lyrics_timeout,
                                                error);
                loader_timeout.async_wait(std::bind(&LyricsPage::OnTimeout, this,
                                                     std::placeholders::_1));
index b1e358d..3618294 100644 (file)
@@ -48,7 +48,7 @@ struct Options {
        int hide_cursor;
        int seek_time = 1;
 #ifdef ENABLE_LYRICS_SCREEN
-       int lyrics_timeout = DEFAULT_LYRICS_TIMEOUT;
+       std::chrono::steady_clock::duration lyrics_timeout = std::chrono::minutes(1);
        bool lyrics_autosave = false;
        bool lyrics_show_plugin = false;
        std::string text_editor;
index 371bf79..ca0e7a9 100644 (file)
@@ -522,7 +522,7 @@ parse_line(char *line)
                                     * 1000 /* seconds -> milliseconds */;
        else if (!strcasecmp(CONF_LYRICS_TIMEOUT, name))
 #ifdef ENABLE_LYRICS_SCREEN
-               options.lyrics_timeout = atoi(GetStringValue(value).c_str());
+               options.lyrics_timeout = std::chrono::seconds(atoi(GetStringValue(value).c_str()));
 #else
        {}
 #endif