Do mpd status update after every call to noidle if appropriate

This commit is contained in:
Andrzej Rybczak
2017-01-06 02:10:41 +01:00
parent 0d8b2aee4b
commit e191959976
4 changed files with 15 additions and 1 deletions

View File

@@ -189,6 +189,11 @@ int Connection::noidle()
return flags;
}
void Connection::setNoidleCallback(NoidleCallback callback)
{
m_noidle_callback = std::move(callback);
}
Statistics Connection::getStatistics()
{
prechecks();
@@ -846,7 +851,9 @@ void Connection::checkConnection() const
void Connection::prechecks()
{
checkConnection();
noidle();
int flags = noidle();
if (flags && m_noidle_callback)
m_noidle_callback(flags);
}
void Connection::prechecksNoCommandsList()

View File

@@ -480,6 +480,8 @@ typedef Iterator<std::string> StringIterator;
struct Connection
{
typedef std::function<void(int)> NoidleCallback;
Connection();
void Connect();
@@ -582,6 +584,7 @@ struct Connection
void idle();
int noidle();
void setNoidleCallback(NoidleCallback callback);
private:
struct ConnectionDeleter {
@@ -595,6 +598,7 @@ private:
void prechecksNoCommandsList();
void checkErrors() const;
NoidleCallback m_noidle_callback;
std::unique_ptr<mpd_connection, ConnectionDeleter> m_connection;
bool m_command_list_active;

View File

@@ -106,6 +106,8 @@ int main(int argc, char **argv)
sigignore(SIGPIPE);
signal(SIGWINCH, sighandler);
Mpd.setNoidleCallback(Status::update);
NC::initScreen(Config.colors_enabled, Config.mouse_support);
Actions::OriginalStatusbarVisibility = Config.statusbar_visibility;