diff options
author | Max Kellermann <max@duempel.org> | 2009-04-25 14:08:31 +0200 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2009-04-25 14:08:31 +0200 |
commit | 616dc9d4659ca7486dfd252efeda0531766409cc (patch) | |
tree | 53de613dc715931919505809467215f9a56125bc /src/playlist_control.c | |
parent | d2010c0289f97a62ccd71d8ca2af5a4cd0fdcacc (diff) | |
download | mpd-616dc9d4659ca7486dfd252efeda0531766409cc.tar.gz mpd-616dc9d4659ca7486dfd252efeda0531766409cc.tar.xz mpd-616dc9d4659ca7486dfd252efeda0531766409cc.zip |
playlist_control: use GTimer in previousSongInPlaylist()
To determine whether to rewind the current song or to go to the
previous song, use a GTimer instead of manually diffing time(NULL).
Diffstat (limited to 'src/playlist_control.c')
-rw-r--r-- | src/playlist_control.c | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/src/playlist_control.c b/src/playlist_control.c index 4f51345c3..f1702149a 100644 --- a/src/playlist_control.c +++ b/src/playlist_control.c @@ -185,15 +185,11 @@ nextSongInPlaylist(struct playlist *playlist) void previousSongInPlaylist(struct playlist *playlist) { - static time_t lastTime; - time_t diff = time(NULL) - lastTime; - - lastTime += diff; - if (!playlist->playing) return; - if (diff && getPlayerElapsedTime() > PLAYLIST_PREV_UNLESS_ELAPSED) { + if (g_timer_elapsed(playlist->prev_elapsed, NULL) >= 1.0 && + getPlayerElapsedTime() > PLAYLIST_PREV_UNLESS_ELAPSED) { /* re-start playing the current song (just like the "prev" button on CD players) */ @@ -213,6 +209,8 @@ void previousSongInPlaylist(struct playlist *playlist) playPlaylistOrderNumber(playlist, playlist->current); } } + + g_timer_start(playlist->prev_elapsed); } enum playlist_result |