replace timeval and time_t with boost::posix_time::ptime
This commit is contained in:
@@ -139,6 +139,13 @@ AC_CHECK_LIB(boost_locale$BOOST_LIB_SUFFIX, main, LDFLAGS="$LDFLAGS -lboost_loca
|
|||||||
AC_MSG_ERROR([no boost.locale library found])
|
AC_MSG_ERROR([no boost.locale library found])
|
||||||
)
|
)
|
||||||
|
|
||||||
|
dnl =================================
|
||||||
|
dnl = checking for boost.posix_time =
|
||||||
|
dnl =================================
|
||||||
|
AC_CHECK_HEADERS([boost/date_time/posix_time/posix_time.hpp], ,
|
||||||
|
AC_MSG_ERROR(boost/date_time/posix_time/posix_time.hpp is missing)
|
||||||
|
)
|
||||||
|
|
||||||
dnl ============================
|
dnl ============================
|
||||||
dnl = checking for boost.regex =
|
dnl = checking for boost.regex =
|
||||||
dnl ============================
|
dnl ============================
|
||||||
|
|||||||
@@ -2593,7 +2593,7 @@ void seek()
|
|||||||
Statusbar::lock();
|
Statusbar::lock();
|
||||||
|
|
||||||
unsigned songpos = Status::State::elapsedTime();
|
unsigned songpos = Status::State::elapsedTime();
|
||||||
timeval t = Timer;
|
auto t = Timer;
|
||||||
|
|
||||||
int old_timeout = wFooter->getTimeout();
|
int old_timeout = wFooter->getTimeout();
|
||||||
wFooter->setTimeout(500);
|
wFooter->setTimeout(500);
|
||||||
@@ -2605,9 +2605,10 @@ void seek()
|
|||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
Status::trace();
|
Status::trace();
|
||||||
myPlaylist->UpdateTimer();
|
|
||||||
|
|
||||||
unsigned howmuch = Config.incremental_seeking ? (Timer.tv_sec-t.tv_sec)/2+Config.seek_time : Config.seek_time;
|
unsigned howmuch = Config.incremental_seeking
|
||||||
|
? (Timer-t).seconds()/2+Config.seek_time
|
||||||
|
: Config.seek_time;
|
||||||
|
|
||||||
Key input = Key::read(*wFooter);
|
Key input = Key::read(*wFooter);
|
||||||
auto k = Bindings.get(input);
|
auto k = Bindings.get(input);
|
||||||
|
|||||||
@@ -25,7 +25,6 @@
|
|||||||
#ifdef ENABLE_CLOCK
|
#ifdef ENABLE_CLOCK
|
||||||
|
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <sys/time.h>
|
|
||||||
|
|
||||||
#include "global.h"
|
#include "global.h"
|
||||||
#include "playlist.h"
|
#include "playlist.h"
|
||||||
@@ -115,20 +114,20 @@ void Clock::update()
|
|||||||
myPlaylist->switchTo();
|
myPlaylist->switchTo();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::tm *time = std::localtime(&Global::Timer.tv_sec);
|
auto time = boost::posix_time::to_tm(Global::Timer);
|
||||||
|
|
||||||
mask = 0;
|
mask = 0;
|
||||||
Set(time->tm_sec % 10, 0);
|
Set(time.tm_sec % 10, 0);
|
||||||
Set(time->tm_sec / 10, 4);
|
Set(time.tm_sec / 10, 4);
|
||||||
Set(time->tm_min % 10, 10);
|
Set(time.tm_min % 10, 10);
|
||||||
Set(time->tm_min / 10, 14);
|
Set(time.tm_min / 10, 14);
|
||||||
Set(time->tm_hour % 10, 20);
|
Set(time.tm_hour % 10, 20);
|
||||||
Set(time->tm_hour / 10, 24);
|
Set(time.tm_hour / 10, 24);
|
||||||
Set(10, 7);
|
Set(10, 7);
|
||||||
Set(10, 17);
|
Set(10, 17);
|
||||||
|
|
||||||
char buf[64];
|
char buf[64];
|
||||||
std::strftime(buf, 64, "%x", time);
|
std::strftime(buf, 64, "%x", &time);
|
||||||
attron(COLOR_PAIR(int(Config.main_color)));
|
attron(COLOR_PAIR(int(Config.main_color)));
|
||||||
mvprintw(w.getStarty()+w.getHeight(), w.getStartX()+(w.getWidth()-strlen(buf))/2, "%s", buf);
|
mvprintw(w.getStarty()+w.getHeight(), w.getStartX()+(w.getWidth()-strlen(buf))/2, "%s", buf);
|
||||||
attroff(COLOR_PAIR(int(Config.main_color)));
|
attroff(COLOR_PAIR(int(Config.main_color)));
|
||||||
|
|||||||
@@ -36,6 +36,6 @@ bool ShowMessages = false;
|
|||||||
bool SeekingInProgress = false;
|
bool SeekingInProgress = false;
|
||||||
|
|
||||||
std::string VolumeState;
|
std::string VolumeState;
|
||||||
timeval Timer;
|
boost::posix_time::ptime Timer;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,8 +21,7 @@
|
|||||||
#ifndef NCMPCPP_GLOBAL_H
|
#ifndef NCMPCPP_GLOBAL_H
|
||||||
#define NCMPCPP_GLOBAL_H
|
#define NCMPCPP_GLOBAL_H
|
||||||
|
|
||||||
#include <sys/time.h>
|
#include <boost/date_time/posix_time/posix_time.hpp>
|
||||||
|
|
||||||
#include "mpdpp.h"
|
#include "mpdpp.h"
|
||||||
#include "screen.h"
|
#include "screen.h"
|
||||||
|
|
||||||
@@ -57,7 +56,7 @@ extern bool SeekingInProgress;
|
|||||||
extern std::string VolumeState;
|
extern std::string VolumeState;
|
||||||
|
|
||||||
// global timer
|
// global timer
|
||||||
extern timeval Timer;
|
extern boost::posix_time::ptime Timer;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -22,7 +22,6 @@
|
|||||||
#include <clocale>
|
#include <clocale>
|
||||||
#include <csignal>
|
#include <csignal>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <sys/time.h>
|
|
||||||
|
|
||||||
#include <boost/locale.hpp>
|
#include <boost/locale.hpp>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
@@ -160,15 +159,14 @@ int main(int argc, char **argv)
|
|||||||
wFooter->setGetStringHelper(Statusbar::Helpers::getString);
|
wFooter->setGetStringHelper(Statusbar::Helpers::getString);
|
||||||
|
|
||||||
// initialize global timer
|
// initialize global timer
|
||||||
gettimeofday(&Timer, 0);
|
Timer = boost::posix_time::microsec_clock::local_time();
|
||||||
|
|
||||||
// go to playlist
|
// go to playlist
|
||||||
myPlaylist->switchTo();
|
myPlaylist->switchTo();
|
||||||
myPlaylist->UpdateTimer();
|
|
||||||
|
|
||||||
// local variables
|
// local variables
|
||||||
Key input(0, Key::Standard);
|
Key input(0, Key::Standard);
|
||||||
timeval past = { 0, 0 };
|
boost::posix_time::ptime past = boost::posix_time::from_time_t(0);
|
||||||
// local variables end
|
// local variables end
|
||||||
|
|
||||||
mouseinterval(0);
|
mouseinterval(0);
|
||||||
@@ -237,14 +235,13 @@ int main(int argc, char **argv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// header stuff
|
// header stuff
|
||||||
if (((Timer.tv_sec == past.tv_sec && Timer.tv_usec >= past.tv_usec+500000) || Timer.tv_sec > past.tv_sec)
|
if ((myScreen == myPlaylist || myScreen == myBrowser || myScreen == myLyrics)
|
||||||
&& (myScreen == myPlaylist || myScreen == myBrowser || myScreen == myLyrics)
|
&& (Timer - past > boost::posix_time::milliseconds(500))
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
drawHeader();
|
drawHeader();
|
||||||
past = Timer;
|
past = Timer;
|
||||||
}
|
}
|
||||||
// header stuff end
|
|
||||||
|
|
||||||
if (input != Key::noOp)
|
if (input != Key::noOp)
|
||||||
myScreen->refreshWindow();
|
myScreen->refreshWindow();
|
||||||
@@ -272,7 +269,7 @@ int main(int argc, char **argv)
|
|||||||
|
|
||||||
# ifdef ENABLE_VISUALIZER
|
# ifdef ENABLE_VISUALIZER
|
||||||
// visualizer sets timeout to 40ms, but since only it needs such small
|
// visualizer sets timeout to 40ms, but since only it needs such small
|
||||||
// value, we should restore defalt one after switching to another screen.
|
// value, we should restore default one after switching to another screen.
|
||||||
if (wFooter->getTimeout() < 500
|
if (wFooter->getTimeout() < 500
|
||||||
&& !(myScreen == myVisualizer || myLockedScreen == myVisualizer || myInactiveScreen == myVisualizer)
|
&& !(myScreen == myVisualizer || myLockedScreen == myVisualizer || myInactiveScreen == myVisualizer)
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -97,6 +97,17 @@ std::wstring Playlist::title()
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Playlist::update()
|
||||||
|
{
|
||||||
|
if (Config.playlist_disable_highlight_delay.time_duration::seconds() > 0
|
||||||
|
&& w.isHighlighted()
|
||||||
|
&& Global::Timer - itsTimer > Config.playlist_disable_highlight_delay)
|
||||||
|
{
|
||||||
|
w.setHighlighting(false);
|
||||||
|
w.refresh();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void Playlist::enterPressed()
|
void Playlist::enterPressed()
|
||||||
{
|
{
|
||||||
if (!w.empty())
|
if (!w.empty())
|
||||||
@@ -260,12 +271,7 @@ void Playlist::Reverse()
|
|||||||
void Playlist::EnableHighlighting()
|
void Playlist::EnableHighlighting()
|
||||||
{
|
{
|
||||||
w.setHighlighting(true);
|
w.setHighlighting(true);
|
||||||
UpdateTimer();
|
itsTimer = Global::Timer;
|
||||||
}
|
|
||||||
|
|
||||||
void Playlist::UpdateTimer()
|
|
||||||
{
|
|
||||||
std::time(&itsTimer);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string Playlist::TotalLength()
|
std::string Playlist::TotalLength()
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ struct Playlist: Screen<NC::Menu<MPD::Song>>, Filterable, HasSongs, Searchable,
|
|||||||
virtual std::wstring title() OVERRIDE;
|
virtual std::wstring title() OVERRIDE;
|
||||||
virtual ScreenType type() OVERRIDE { return ScreenType::Playlist; }
|
virtual ScreenType type() OVERRIDE { return ScreenType::Playlist; }
|
||||||
|
|
||||||
virtual void update() OVERRIDE { }
|
virtual void update() OVERRIDE;
|
||||||
|
|
||||||
virtual void enterPressed() OVERRIDE;
|
virtual void enterPressed() OVERRIDE;
|
||||||
virtual void spacePressed() OVERRIDE;
|
virtual void spacePressed() OVERRIDE;
|
||||||
@@ -71,8 +71,6 @@ struct Playlist: Screen<NC::Menu<MPD::Song>>, Filterable, HasSongs, Searchable,
|
|||||||
void Reverse();
|
void Reverse();
|
||||||
|
|
||||||
void EnableHighlighting();
|
void EnableHighlighting();
|
||||||
void UpdateTimer();
|
|
||||||
time_t Timer() const { return itsTimer; }
|
|
||||||
|
|
||||||
void SetSelectedItemsPriority(int prio);
|
void SetSelectedItemsPriority(int prio);
|
||||||
|
|
||||||
@@ -101,7 +99,7 @@ private:
|
|||||||
size_t itsRemainingTime;
|
size_t itsRemainingTime;
|
||||||
size_t itsScrollBegin;
|
size_t itsScrollBegin;
|
||||||
|
|
||||||
time_t itsTimer;
|
boost::posix_time::ptime itsTimer;
|
||||||
|
|
||||||
MPD::Status m_status;
|
MPD::Status m_status;
|
||||||
unsigned m_old_playlist_version;
|
unsigned m_old_playlist_version;
|
||||||
|
|||||||
@@ -18,7 +18,6 @@
|
|||||||
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. *
|
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. *
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
|
|
||||||
#include <sys/time.h>
|
|
||||||
#include <iomanip>
|
#include <iomanip>
|
||||||
|
|
||||||
#include "global.h"
|
#include "global.h"
|
||||||
@@ -75,10 +74,10 @@ std::wstring ServerInfo::title()
|
|||||||
|
|
||||||
void ServerInfo::update()
|
void ServerInfo::update()
|
||||||
{
|
{
|
||||||
static timeval past = { 0, 0 };
|
Statusbar::printf("%1%, %2%", Global::Timer, m_timer);
|
||||||
if (Global::Timer.tv_sec <= past.tv_sec)
|
if (Global::Timer - m_timer < boost::posix_time::seconds(1))
|
||||||
return;
|
return;
|
||||||
past = Global::Timer;
|
m_timer = Global::Timer;
|
||||||
|
|
||||||
MPD::Statistics stats = Mpd.getStatistics();
|
MPD::Statistics stats = Mpd.getStatistics();
|
||||||
if (stats.empty())
|
if (stats.empty())
|
||||||
|
|||||||
@@ -48,6 +48,8 @@ protected:
|
|||||||
private:
|
private:
|
||||||
void SetDimensions();
|
void SetDimensions();
|
||||||
|
|
||||||
|
boost::posix_time::ptime m_timer;
|
||||||
|
|
||||||
MPD::StringList itsURLHandlers;
|
MPD::StringList itsURLHandlers;
|
||||||
MPD::StringList itsTagTypes;
|
MPD::StringList itsTagTypes;
|
||||||
|
|
||||||
|
|||||||
@@ -188,13 +188,13 @@ void Configuration::SetDefaults()
|
|||||||
crossfade_time = 5;
|
crossfade_time = 5;
|
||||||
seek_time = 1;
|
seek_time = 1;
|
||||||
volume_change_step = 1;
|
volume_change_step = 1;
|
||||||
playlist_disable_highlight_delay = 5;
|
playlist_disable_highlight_delay = boost::posix_time::seconds(5);
|
||||||
message_delay_time = 4;
|
message_delay_time = 4;
|
||||||
lyrics_db = 0;
|
lyrics_db = 0;
|
||||||
regex_type = boost::regex::literal | boost::regex::icase;
|
regex_type = boost::regex::literal | boost::regex::icase;
|
||||||
lines_scrolled = 2;
|
lines_scrolled = 2;
|
||||||
search_engine_default_search_mode = 0;
|
search_engine_default_search_mode = 0;
|
||||||
visualizer_sync_interval = 30;
|
visualizer_sync_interval = boost::posix_time::seconds(30);
|
||||||
locked_screen_width_part = 0.5;
|
locked_screen_width_part = 0.5;
|
||||||
selected_item_prefix_length = 0;
|
selected_item_prefix_length = 0;
|
||||||
selected_item_suffix_length = 0;
|
selected_item_suffix_length = 0;
|
||||||
@@ -212,6 +212,7 @@ void Configuration::SetDefaults()
|
|||||||
}
|
}
|
||||||
|
|
||||||
Configuration::Configuration()
|
Configuration::Configuration()
|
||||||
|
: playlist_disable_highlight_delay(0), visualizer_sync_interval(0)
|
||||||
{
|
{
|
||||||
# ifdef WIN32
|
# ifdef WIN32
|
||||||
ncmpcpp_directory = GetHomeDirectory() + "ncmpcpp/";
|
ncmpcpp_directory = GetHomeDirectory() + "ncmpcpp/";
|
||||||
@@ -338,8 +339,7 @@ void Configuration::Read()
|
|||||||
}
|
}
|
||||||
else if (name == "playlist_disable_highlight_delay")
|
else if (name == "playlist_disable_highlight_delay")
|
||||||
{
|
{
|
||||||
if (boost::lexical_cast<int>(v) >= 0)
|
playlist_disable_highlight_delay = boost::posix_time::seconds(boost::lexical_cast<int>(v));
|
||||||
playlist_disable_highlight_delay = boost::lexical_cast<int>(v);
|
|
||||||
}
|
}
|
||||||
else if (name == "message_delay_time")
|
else if (name == "message_delay_time")
|
||||||
{
|
{
|
||||||
@@ -762,7 +762,7 @@ void Configuration::Read()
|
|||||||
{
|
{
|
||||||
unsigned interval = boost::lexical_cast<unsigned>(v);
|
unsigned interval = boost::lexical_cast<unsigned>(v);
|
||||||
if (interval)
|
if (interval)
|
||||||
visualizer_sync_interval = interval;
|
visualizer_sync_interval = boost::posix_time::seconds(interval);
|
||||||
}
|
}
|
||||||
else if (name == "browser_sort_mode")
|
else if (name == "browser_sort_mode")
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -21,6 +21,7 @@
|
|||||||
#ifndef NCMPCPP_SETTINGS_H
|
#ifndef NCMPCPP_SETTINGS_H
|
||||||
#define NCMPCPP_SETTINGS_H
|
#define NCMPCPP_SETTINGS_H
|
||||||
|
|
||||||
|
#include <boost/date_time/posix_time/posix_time_types.hpp>
|
||||||
#include <boost/regex.hpp>
|
#include <boost/regex.hpp>
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
@@ -171,7 +172,6 @@ struct Configuration
|
|||||||
int crossfade_time;
|
int crossfade_time;
|
||||||
int seek_time;
|
int seek_time;
|
||||||
int volume_change_step;
|
int volume_change_step;
|
||||||
int playlist_disable_highlight_delay;
|
|
||||||
int message_delay_time;
|
int message_delay_time;
|
||||||
int lyrics_db;
|
int lyrics_db;
|
||||||
|
|
||||||
@@ -179,7 +179,9 @@ struct Configuration
|
|||||||
|
|
||||||
unsigned lines_scrolled;
|
unsigned lines_scrolled;
|
||||||
unsigned search_engine_default_search_mode;
|
unsigned search_engine_default_search_mode;
|
||||||
unsigned visualizer_sync_interval;
|
|
||||||
|
boost::posix_time::seconds playlist_disable_highlight_delay;
|
||||||
|
boost::posix_time::seconds visualizer_sync_interval;
|
||||||
|
|
||||||
double locked_screen_width_part;
|
double locked_screen_width_part;
|
||||||
|
|
||||||
|
|||||||
@@ -18,8 +18,6 @@
|
|||||||
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. *
|
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. *
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
|
|
||||||
#include <sys/time.h>
|
|
||||||
|
|
||||||
#include "browser.h"
|
#include "browser.h"
|
||||||
#include "charset.h"
|
#include "charset.h"
|
||||||
#include "global.h"
|
#include "global.h"
|
||||||
@@ -49,7 +47,7 @@ using Global::VolumeState;
|
|||||||
|
|
||||||
namespace {//
|
namespace {//
|
||||||
|
|
||||||
timeval past = { 0, 0 };
|
boost::posix_time::ptime past = boost::posix_time::from_time_t(0);
|
||||||
|
|
||||||
size_t playing_song_scroll_begin = 0;
|
size_t playing_song_scroll_begin = 0;
|
||||||
size_t first_line_scroll_begin = 0;
|
size_t first_line_scroll_begin = 0;
|
||||||
@@ -135,10 +133,11 @@ void Status::handleServerError(MPD::ServerError &e)
|
|||||||
|
|
||||||
void Status::trace()
|
void Status::trace()
|
||||||
{
|
{
|
||||||
gettimeofday(&Timer, 0);
|
Timer = boost::posix_time::microsec_clock::local_time();
|
||||||
if (Mpd.Connected())
|
if (Mpd.Connected())
|
||||||
{
|
{
|
||||||
if (State::player() == MPD::psPlay && Global::Timer.tv_sec > past.tv_sec)
|
if (State::player() == MPD::psPlay
|
||||||
|
&& Global::Timer - past > boost::posix_time::seconds(1))
|
||||||
{
|
{
|
||||||
// update elapsed time/bitrate of the current song
|
// update elapsed time/bitrate of the current song
|
||||||
Status::Changes::elapsedTime(true);
|
Status::Changes::elapsedTime(true);
|
||||||
@@ -147,16 +146,6 @@ void Status::trace()
|
|||||||
}
|
}
|
||||||
|
|
||||||
applyToVisibleWindows(&BaseScreen::update);
|
applyToVisibleWindows(&BaseScreen::update);
|
||||||
|
|
||||||
if (isVisible(myPlaylist)
|
|
||||||
&& Timer.tv_sec == myPlaylist->Timer()+Config.playlist_disable_highlight_delay
|
|
||||||
&& myPlaylist->main().isHighlighted()
|
|
||||||
&& Config.playlist_disable_highlight_delay)
|
|
||||||
{
|
|
||||||
myPlaylist->main().setHighlighting(false);
|
|
||||||
myPlaylist->main().refresh();
|
|
||||||
}
|
|
||||||
|
|
||||||
Statusbar::tryRedraw();
|
Statusbar::tryRedraw();
|
||||||
|
|
||||||
Mpd.idle();
|
Mpd.idle();
|
||||||
|
|||||||
@@ -30,8 +30,8 @@ using Global::wFooter;
|
|||||||
|
|
||||||
namespace {//
|
namespace {//
|
||||||
|
|
||||||
timeval statusbarLockTime;
|
boost::posix_time::ptime statusbarLockTime;
|
||||||
int statusbarLockDelay = -1;
|
boost::posix_time::seconds statusbarLockDelay(-1);
|
||||||
|
|
||||||
bool statusbarBlockUpdate = false;
|
bool statusbarBlockUpdate = false;
|
||||||
bool progressbarBlockUpdate = false;
|
bool progressbarBlockUpdate = false;
|
||||||
@@ -97,7 +97,7 @@ void Statusbar::lock()
|
|||||||
void Statusbar::unlock()
|
void Statusbar::unlock()
|
||||||
{
|
{
|
||||||
statusbarAllowUnlock = true;
|
statusbarAllowUnlock = true;
|
||||||
if (statusbarLockDelay < 0)
|
if (statusbarLockDelay.is_negative())
|
||||||
{
|
{
|
||||||
if (Config.statusbar_visibility)
|
if (Config.statusbar_visibility)
|
||||||
statusbarBlockUpdate = false;
|
statusbarBlockUpdate = false;
|
||||||
@@ -122,10 +122,10 @@ bool Statusbar::isUnlocked()
|
|||||||
void Statusbar::tryRedraw()
|
void Statusbar::tryRedraw()
|
||||||
{
|
{
|
||||||
using Global::Timer;
|
using Global::Timer;
|
||||||
if (statusbarLockDelay > 0
|
if (statusbarLockDelay > boost::posix_time::seconds(0)
|
||||||
&& Timer.tv_sec >= statusbarLockTime.tv_sec+statusbarLockDelay)
|
&& Timer - statusbarLockTime > statusbarLockDelay)
|
||||||
{
|
{
|
||||||
statusbarLockDelay = -1;
|
statusbarLockDelay = boost::posix_time::seconds(-1);
|
||||||
|
|
||||||
if (Config.statusbar_visibility)
|
if (Config.statusbar_visibility)
|
||||||
statusbarBlockUpdate = !statusbarAllowUnlock;
|
statusbarBlockUpdate = !statusbarAllowUnlock;
|
||||||
@@ -149,12 +149,12 @@ NC::Window &Statusbar::put()
|
|||||||
return *wFooter;
|
return *wFooter;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Statusbar::print(int time, const std::string &message)
|
void Statusbar::print(int delay, const std::string &message)
|
||||||
{
|
{
|
||||||
if (statusbarAllowUnlock)
|
if (statusbarAllowUnlock)
|
||||||
{
|
{
|
||||||
statusbarLockTime = Global::Timer;
|
statusbarLockTime = Global::Timer;
|
||||||
statusbarLockDelay = time;
|
statusbarLockDelay = boost::posix_time::seconds(delay);
|
||||||
if (Config.statusbar_visibility)
|
if (Config.statusbar_visibility)
|
||||||
statusbarBlockUpdate = true;
|
statusbarBlockUpdate = true;
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -94,7 +94,7 @@ private:
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// displays message in statusbar for a given period of time
|
/// displays message in statusbar for a given period of time
|
||||||
void print(int time, const std::string &message);
|
void print(int delay, const std::string& message);
|
||||||
|
|
||||||
/// displays message in statusbar for period of time set in configuration file
|
/// displays message in statusbar for period of time set in configuration file
|
||||||
inline void print(const std::string &message)
|
inline void print(const std::string &message)
|
||||||
@@ -118,14 +118,14 @@ void printf(FormatT &&fmt, ArgT &&arg, Args&&... args)
|
|||||||
|
|
||||||
/// displays formatted message in statusbar for a given period of time
|
/// displays formatted message in statusbar for a given period of time
|
||||||
template <typename FormatT>
|
template <typename FormatT>
|
||||||
void printf(int time, FormatT &&fmt)
|
void printf(int delay, FormatT &&fmt)
|
||||||
{
|
{
|
||||||
print(time, boost::format(std::forward<FormatT>(fmt)).str());
|
print(delay, boost::format(std::forward<FormatT>(fmt)).str());
|
||||||
}
|
}
|
||||||
template <typename FormatT, typename ArgT, typename... Args>
|
template <typename FormatT, typename ArgT, typename... Args>
|
||||||
void printf(int time, FormatT &&fmt, ArgT &&arg, Args&&... args)
|
void printf(int delay, FormatT &&fmt, ArgT &&arg, Args&&... args)
|
||||||
{
|
{
|
||||||
printf(time, boost::format(std::forward<FormatT>(fmt)) % std::forward<ArgT>(arg),
|
printf(delay, boost::format(std::forward<FormatT>(fmt)) % std::forward<ArgT>(arg),
|
||||||
std::forward<Args>(args)...
|
std::forward<Args>(args)...
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,8 +28,6 @@
|
|||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <limits>
|
#include <limits>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <sys/time.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
|
|
||||||
#include "global.h"
|
#include "global.h"
|
||||||
#include "settings.h"
|
#include "settings.h"
|
||||||
@@ -64,7 +62,6 @@ void Visualizer::switchTo()
|
|||||||
SwitchTo::execute(this);
|
SwitchTo::execute(this);
|
||||||
w.clear();
|
w.clear();
|
||||||
SetFD();
|
SetFD();
|
||||||
m_timer = { 0, 0 };
|
|
||||||
if (m_fifo >= 0)
|
if (m_fifo >= 0)
|
||||||
Global::wFooter->setTimeout(WindowTimeout);
|
Global::wFooter->setTimeout(WindowTimeout);
|
||||||
drawHeader();
|
drawHeader();
|
||||||
@@ -95,7 +92,7 @@ void Visualizer::update()
|
|||||||
if (data < 0) // no data available in fifo
|
if (data < 0) // no data available in fifo
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (m_output_id != -1 && Global::Timer.tv_sec > m_timer.tv_sec+Config.visualizer_sync_interval)
|
if (m_output_id != -1 && Global::Timer - m_timer > Config.visualizer_sync_interval)
|
||||||
{
|
{
|
||||||
Mpd.DisableOutput(m_output_id);
|
Mpd.DisableOutput(m_output_id);
|
||||||
usleep(50000);
|
usleep(50000);
|
||||||
|
|||||||
@@ -25,6 +25,7 @@
|
|||||||
|
|
||||||
#ifdef ENABLE_VISUALIZER
|
#ifdef ENABLE_VISUALIZER
|
||||||
|
|
||||||
|
#include <boost/date_time/posix_time/posix_time_types.hpp>
|
||||||
#include "interfaces.h"
|
#include "interfaces.h"
|
||||||
#include "screen.h"
|
#include "screen.h"
|
||||||
#include "window.h"
|
#include "window.h"
|
||||||
@@ -69,7 +70,7 @@ private:
|
|||||||
# endif // HAVE_FFTW3_H
|
# endif // HAVE_FFTW3_H
|
||||||
|
|
||||||
int m_output_id;
|
int m_output_id;
|
||||||
timeval m_timer;
|
boost::posix_time::ptime m_timer;
|
||||||
|
|
||||||
int m_fifo;
|
int m_fifo;
|
||||||
unsigned m_samples;
|
unsigned m_samples;
|
||||||
|
|||||||
Reference in New Issue
Block a user