From 43255a7f63af65d88bbead4c0d6429ef2008ada8 Mon Sep 17 00:00:00 2001
From: Warren Dukes <warren.dukes@gmail.com>
Date: Thu, 10 Jun 2004 21:42:20 +0000
Subject: [PATCH] since stuff like vorbis streams report actual time into
 stream, not time played, for previous add a hack where we record the
 difference in time between previous presses

git-svn-id: https://svn.musicpd.org/mpd/trunk@1440 09075e82-0dd4-0310-85a5-a0d7c8717e4f
---
 TODO                          |  4 ----
 src/inputPlugins/ogg_plugin.c |  3 ++-
 src/playlist.c                | 10 ++++++----
 3 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/TODO b/TODO
index 1d55edf5a..5f8dc8c93 100644
--- a/TODO
+++ b/TODO
@@ -2,10 +2,6 @@
 
 *) Fix charset errors so they don't goto stderr/out
 
-*) compute time of vorbis from actual number of samples played
-
-*) remove previous hack for streams
-
 Post-1.0
 --------
 1) crosslink "list" stuff, for example, artists are crosslinked to alubms and 
diff --git a/src/inputPlugins/ogg_plugin.c b/src/inputPlugins/ogg_plugin.c
index c5197f132..b50ea5ea1 100644
--- a/src/inputPlugins/ogg_plugin.c
+++ b/src/inputPlugins/ogg_plugin.c
@@ -318,7 +318,8 @@ int ogg_decode(OutputBuffer * cb, DecoderControl * dc, InputStream * inStream)
 			sendDataToOutputBuffer(cb, inStream, dc, 
 						inStream->seekable,  
                                         	chunk, chunkpos, 
-						ov_time_tell(&vf), 
+						ov_pcm_tell(&vf)/
+						dc->audioFormat.sampleRate,
 						bitRate);
 					
 			if(dc->stop) break;
diff --git a/src/playlist.c b/src/playlist.c
index 31dc31fc5..a18f85dee 100644
--- a/src/playlist.c
+++ b/src/playlist.c
@@ -1165,14 +1165,16 @@ int setPlaylistRandomStatus(FILE * fp, int status) {
 }
 
 int previousSongInPlaylist(FILE * fp) {
+	static time_t lastTime = 0;
+	time_t diff = time(NULL) - lastTime;
+
+	lastTime += diff;
+
 	if(playlist_state!=PLAYLIST_STATE_PLAY) return 0;
 
 	syncPlaylistWithQueue(0);
 
-   	if (getPlayerElapsedTime()>PLAYLIST_PREV_UNLESS_ELAPSED &&
-                        playlist.songs[playlist.order[playlist.current]]->type
-                        != SONG_TYPE_URL) 
-        {
+   	if (diff && getPlayerElapsedTime() > PLAYLIST_PREV_UNLESS_ELAPSED) {
 		return playPlaylistOrderNumber(fp,playlist.current);
    	}
    	else {