count elapsed time locally (experimental)

this eliminates really annoying stalling of counter
but let's see if there are some side effects of it.
This commit is contained in:
Andrzej Rybczak
2009-04-12 18:22:41 +02:00
parent c8f99be7d0
commit 104cd0a6e8

View File

@@ -182,6 +182,7 @@ void NcmpcppStatusChanged(Connection *Mpd, StatusChanges changed, void *)
{
static size_t playing_song_scroll_begin = 0;
static string player_state;
static int elapsed;
static MPD::Song np;
int sx, sy;
@@ -367,8 +368,11 @@ void NcmpcppStatusChanged(Connection *Mpd, StatusChanges changed, void *)
changed.ElapsedTime = 1;
}
}
if (changed.ElapsedTime)
static time_t now, past = 0;
time(&now);
if ((now > past && Mpd->GetState() == psPlay) || changed.SongID)
{
time(&past);
if (np.Empty())
{
np = Mpd->GetCurrentSong();
@@ -376,7 +380,11 @@ void NcmpcppStatusChanged(Connection *Mpd, StatusChanges changed, void *)
}
if (!np.Empty() && !player_state.empty())
{
int elapsed = Mpd->GetElapsedTime();
int mpd_elapsed = Mpd->GetElapsedTime();
if (elapsed < mpd_elapsed-2 || elapsed+1 > mpd_elapsed)
elapsed = mpd_elapsed;
else
elapsed++;
if (!block_statusbar_update && Config.statusbar_visibility)
{