improve elapsed time handling
this also throws away hack that was used to count elapsed time locally while polling mpd, it's not needed anymore.
This commit is contained in:
@@ -217,22 +217,13 @@ void Connection::UpdateStatus()
|
|||||||
if (supportsIdle)
|
if (supportsIdle)
|
||||||
{
|
{
|
||||||
// sync local elapsed time counter with mpd
|
// sync local elapsed time counter with mpd
|
||||||
|
unsigned old_elapsed = itsElapsed;
|
||||||
itsElapsed = mpd_status_get_elapsed_time(itsCurrentStatus);
|
itsElapsed = mpd_status_get_elapsed_time(itsCurrentStatus);
|
||||||
|
itsChanges.ElapsedTime = itsElapsed != old_elapsed;
|
||||||
time(&itsElapsedTimer[0]);
|
time(&itsElapsedTimer[0]);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
itsElapsed = mpd_status_get_elapsed_time(itsCurrentStatus);
|
||||||
time(&itsElapsedTimer[0]);
|
|
||||||
if (itsElapsedTimer[0] > itsElapsedTimer[1])
|
|
||||||
{
|
|
||||||
unsigned mpd_elapsed = mpd_status_get_elapsed_time(itsCurrentStatus);
|
|
||||||
if (itsElapsed < mpd_elapsed-2 || itsElapsed+1 > mpd_elapsed)
|
|
||||||
itsElapsed = mpd_elapsed;
|
|
||||||
else if (Mpd.GetState() == psPlay)
|
|
||||||
++itsElapsed;
|
|
||||||
time(&itsElapsedTimer[1]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!itsOldStatus)
|
if (!itsOldStatus)
|
||||||
{
|
{
|
||||||
@@ -267,6 +258,9 @@ void Connection::UpdateStatus()
|
|||||||
itsChanges.Playlist = mpd_status_get_queue_version(itsOldStatus)
|
itsChanges.Playlist = mpd_status_get_queue_version(itsOldStatus)
|
||||||
!= mpd_status_get_queue_version(itsCurrentStatus);
|
!= mpd_status_get_queue_version(itsCurrentStatus);
|
||||||
|
|
||||||
|
itsChanges.ElapsedTime = mpd_status_get_elapsed_time(itsOldStatus)
|
||||||
|
!= mpd_status_get_elapsed_time(itsCurrentStatus);
|
||||||
|
|
||||||
itsChanges.Database = mpd_status_get_update_id(itsOldStatus)
|
itsChanges.Database = mpd_status_get_update_id(itsOldStatus)
|
||||||
&& !mpd_status_get_update_id(itsCurrentStatus);
|
&& !mpd_status_get_update_id(itsCurrentStatus);
|
||||||
|
|
||||||
@@ -291,9 +285,6 @@ void Connection::UpdateStatus()
|
|||||||
itsChanges.SongID = mpd_status_get_song_id(itsOldStatus)
|
itsChanges.SongID = mpd_status_get_song_id(itsOldStatus)
|
||||||
!= mpd_status_get_song_id(itsCurrentStatus);
|
!= mpd_status_get_song_id(itsCurrentStatus);
|
||||||
|
|
||||||
itsChanges.ElapsedTime = mpd_status_get_elapsed_time(itsOldStatus)
|
|
||||||
!= mpd_status_get_elapsed_time(itsCurrentStatus);
|
|
||||||
|
|
||||||
itsChanges.Crossfade = mpd_status_get_crossfade(itsOldStatus)
|
itsChanges.Crossfade = mpd_status_get_crossfade(itsOldStatus)
|
||||||
!= mpd_status_get_crossfade(itsCurrentStatus);
|
!= mpd_status_get_crossfade(itsCurrentStatus);
|
||||||
|
|
||||||
|
|||||||
@@ -126,7 +126,8 @@ namespace MPD
|
|||||||
|
|
||||||
bool isPlaying() const { return GetState() > psStop; }
|
bool isPlaying() const { return GetState() > psStop; }
|
||||||
|
|
||||||
PlayerState GetState() const{ return itsCurrentStatus ? PlayerState(mpd_status_get_state(itsCurrentStatus)) : psUnknown; }
|
PlayerState GetState() const { return itsCurrentStatus ? PlayerState(mpd_status_get_state(itsCurrentStatus)) : psUnknown; }
|
||||||
|
PlayerState GetOldState() const { return itsOldStatus ? PlayerState(mpd_status_get_state(itsOldStatus)) : psUnknown; }
|
||||||
bool GetRepeat() const { return itsCurrentStatus ? mpd_status_get_repeat(itsCurrentStatus) : 0; }
|
bool GetRepeat() const { return itsCurrentStatus ? mpd_status_get_repeat(itsCurrentStatus) : 0; }
|
||||||
bool GetRandom() const { return itsCurrentStatus ? mpd_status_get_random(itsCurrentStatus) : 0; }
|
bool GetRandom() const { return itsCurrentStatus ? mpd_status_get_random(itsCurrentStatus) : 0; }
|
||||||
bool GetSingle() const { return itsCurrentStatus ? mpd_status_get_single(itsCurrentStatus) : 0; }
|
bool GetSingle() const { return itsCurrentStatus ? mpd_status_get_single(itsCurrentStatus) : 0; }
|
||||||
|
|||||||
@@ -321,13 +321,13 @@ void NcmpcppStatusChanged(Connection *, StatusChanges changed, void *)
|
|||||||
WindowTitle(utf_to_locale_cpy(np.toString(Config.song_window_title_format)));
|
WindowTitle(utf_to_locale_cpy(np.toString(Config.song_window_title_format)));
|
||||||
player_state = Config.new_design ? "[playing]" : "Playing: ";
|
player_state = Config.new_design ? "[playing]" : "Playing: ";
|
||||||
Playlist::ReloadRemaining = 1;
|
Playlist::ReloadRemaining = 1;
|
||||||
changed.ElapsedTime = 1;
|
if (Mpd.GetOldState() == psStop) // show track info in status immediately
|
||||||
|
changed.ElapsedTime = 1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case psPause:
|
case psPause:
|
||||||
{
|
{
|
||||||
player_state = Config.new_design ? "[paused] " : "[Paused] ";
|
player_state = Config.new_design ? "[paused] " : "[Paused] ";
|
||||||
changed.ElapsedTime = 1;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case psStop:
|
case psStop:
|
||||||
@@ -355,11 +355,8 @@ void NcmpcppStatusChanged(Connection *, StatusChanges changed, void *)
|
|||||||
}
|
}
|
||||||
if (Config.new_design)
|
if (Config.new_design)
|
||||||
{
|
{
|
||||||
if (!myPlaylist->isPlaying())
|
*wHeader << XY(0, 1) << fmtBold << player_state << fmtBoldEnd;
|
||||||
{
|
wHeader->Refresh();
|
||||||
*wHeader << XY(0, 1) << fmtBold << player_state << fmtBoldEnd;
|
|
||||||
wHeader->Refresh();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else if (!block_statusbar_update && Config.statusbar_visibility && player_state.empty())
|
else if (!block_statusbar_update && Config.statusbar_visibility && player_state.empty())
|
||||||
*wFooter << XY(0, 1) << wclrtoeol;
|
*wFooter << XY(0, 1) << wclrtoeol;
|
||||||
|
|||||||
Reference in New Issue
Block a user