From cf3746f301542a871a93e611faeb52154d87f3dd Mon Sep 17 00:00:00 2001 From: Andrzej Rybczak Date: Sun, 22 Mar 2009 15:10:04 +0100 Subject: [PATCH] always poll mpd twice per second --- src/ncmpcpp.cpp | 18 ++++++++++++++++++ src/playlist.cpp | 3 +++ src/status.cpp | 16 +++++++++++----- 3 files changed, 32 insertions(+), 5 deletions(-) diff --git a/src/ncmpcpp.cpp b/src/ncmpcpp.cpp index 8a018aa5..ee6e20aa 100644 --- a/src/ncmpcpp.cpp +++ b/src/ncmpcpp.cpp @@ -414,7 +414,10 @@ int main(int argc, char *argv[]) } # endif // HAVE_TAGLIB_H else + { Mpd->SetVolume(Mpd->GetVolume()+1); + Mpd->UpdateStatus(); + } } else if (Keypressed(input, Key.VolumeDown)) { @@ -433,7 +436,10 @@ int main(int argc, char *argv[]) } # endif // HAVE_TAGLIB_H else + { Mpd->SetVolume(Mpd->GetVolume()-1); + Mpd->UpdateStatus(); + } } else if (Keypressed(input, Key.Delete)) { @@ -545,14 +551,17 @@ int main(int argc, char *argv[]) else if (Keypressed(input, Key.Prev)) { Mpd->Prev(); + Mpd->UpdateStatus(); } else if (Keypressed(input, Key.Next)) { Mpd->Next(); + Mpd->UpdateStatus(); } else if (Keypressed(input, Key.Pause)) { Mpd->Pause(); + Mpd->UpdateStatus(); } else if (Keypressed(input, Key.SavePlaylist)) { @@ -609,6 +618,7 @@ int main(int argc, char *argv[]) else if (Keypressed(input, Key.Stop)) { Mpd->Stop(); + Mpd->UpdateStatus(); } else if (Keypressed(input, Key.MvSongUp)) { @@ -979,6 +989,7 @@ int main(int argc, char *argv[]) wFooter->Refresh(); } Mpd->Seek(songpos); + Mpd->UpdateStatus(); UnlockProgressbar(); UnlockStatusbar(); @@ -1068,6 +1079,7 @@ int main(int argc, char *argv[]) else if (Keypressed(input, Key.ToggleRepeat)) { Mpd->SetRepeat(!Mpd->GetRepeat()); + Mpd->UpdateStatus(); } else if (Keypressed(input, Key.ToggleRepeatOne)) { @@ -1077,14 +1089,17 @@ int main(int argc, char *argv[]) else if (Keypressed(input, Key.Shuffle)) { Mpd->Shuffle(); + Mpd->UpdateStatus(); } else if (Keypressed(input, Key.ToggleRandom)) { Mpd->SetRandom(!Mpd->GetRandom()); + Mpd->UpdateStatus(); } else if (Keypressed(input, Key.ToggleCrossfade)) { Mpd->SetCrossfade(Mpd->GetCrossfade() ? 0 : Config.crossfade_time); + Mpd->UpdateStatus(); } else if (Keypressed(input, Key.SetCrossfade)) { @@ -1097,6 +1112,7 @@ int main(int argc, char *argv[]) { Config.crossfade_time = cf; Mpd->SetCrossfade(cf); + Mpd->UpdateStatus(); } } else if (Keypressed(input, Key.EditTags)) @@ -1326,6 +1342,7 @@ int main(int argc, char *argv[]) else ShowMessage("Out of bounds, 1-99 possible for %, %d given.", newpos); } + Mpd->UpdateStatus(); } else if (Keypressed(input, Key.ReverseSelection)) { @@ -1530,6 +1547,7 @@ int main(int argc, char *argv[]) { Mpd->ClearPlaylist(); } + Mpd->UpdateStatus(); ShowMessage("Cleared playlist!"); } } diff --git a/src/playlist.cpp b/src/playlist.cpp index 43fdedc8..d55b65fc 100644 --- a/src/playlist.cpp +++ b/src/playlist.cpp @@ -115,7 +115,10 @@ std::string Playlist::Title() void Playlist::EnterPressed() { if (!w->Empty()) + { Mpd->PlayID(w->Current().GetID()); + Mpd->UpdateStatus(); + } } void Playlist::SpacePressed() diff --git a/src/status.cpp b/src/status.cpp index 3f025fe6..b2d773cc 100644 --- a/src/status.cpp +++ b/src/status.cpp @@ -103,18 +103,24 @@ void UnlockStatusbar() void TraceMpdStatus() { - static time_t now; + static timeval past, now; - if (Mpd->Connected()) + gettimeofday(&now, 0); + if (Mpd->Connected() + && ((now.tv_sec == past.tv_sec && now.tv_usec >= past.tv_usec+500000) || now.tv_sec > past.tv_sec) + ) + { Mpd->UpdateStatus(); + gettimeofday(&past, 0); + } + wFooter->Refresh(); - time(&now); - if (myScreen == myPlaylist && now == myPlaylist->Timer()+Config.playlist_disable_highlight_delay) + if (myScreen == myPlaylist && now.tv_sec == myPlaylist->Timer()+Config.playlist_disable_highlight_delay) myPlaylist->Main()->Highlighting(!Config.playlist_disable_highlight_delay); if (lock_statusbar_delay > 0) { - if (now >= time_of_statusbar_lock+lock_statusbar_delay) + if (now.tv_sec >= time_of_statusbar_lock+lock_statusbar_delay) { lock_statusbar_delay = -1;