[vlc-devel] commit: Do not mix time() and mdate() ( Rafaël Carré )

git version control git at videolan.org
Sun Mar 30 16:37:13 CEST 2008


vlc | branch: master | Rafaël Carré <funman at videolan.org> | Sun Mar 30 13:23:42 2008 +0200| [b5cb69656ada4cd40852d4ffc225ad1384ea2dcf]

Do not mix time() and mdate()

Signed-off-by: Ilkka Ollakka <ileoo at videolan.org>

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=b5cb69656ada4cd40852d4ffc225ad1384ea2dcf
---

 modules/misc/audioscrobbler.c |    9 +++++----
 1 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/modules/misc/audioscrobbler.c b/modules/misc/audioscrobbler.c
index c27c937..69dd745 100644
--- a/modules/misc/audioscrobbler.c
+++ b/modules/misc/audioscrobbler.c
@@ -65,6 +65,7 @@ typedef struct audioscrobbler_song_t
     int         i_l;                /**< track length     */
     char        *psz_m;             /**< musicbrainz id   */
     time_t      date;               /**< date since epoch */
+    mtime_t     i_start;            /**< playing start    */
 } audioscrobbler_song_t;
 
 struct intf_sys_t
@@ -546,7 +547,8 @@ static int ItemChange( vlc_object_t *p_this, const char *psz_var,
     }
 
     p_sys->time_total_pauses = 0;
-    time( &p_sys->p_current_song.date );
+    time( &p_sys->p_current_song.date );        /* to be sent to last.fm */
+    p_sys->p_current_song.i_start = mdate();    /* only used locally */
 
     var_AddCallback( p_input, "state", PlayingChange, p_intf );
     p_sys->b_state_cb = VLC_TRUE;
@@ -573,9 +575,8 @@ static void AddToQueue ( intf_thread_t *p_this )
         goto end;
 
     /* wait for the user to listen enough before submitting */
-    played_time = mdate();
-    played_time -= p_sys->p_current_song.date;
-    played_time -= p_sys->time_total_pauses;
+    played_time = mdate() - p_sys->p_current_song.i_start -
+                            p_sys->time_total_pauses;
     played_time /= 1000000; /* µs → s */
 
     if( ( played_time < 240 ) &&




More information about the vlc-devel mailing list