changeset 807:0f9c8d4d3ac4 trunk

[svn] - make use of new millisecond seek API.
author yaz
date Mon, 12 Mar 2007 11:03:24 -0700
parents 74abcb9cafae
children e8776388b02a
files ChangeLog src/madplug/decoder.c src/madplug/plugin.c src/madplug/plugin.h
diffstat 4 files changed, 24 insertions(+), 16 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Mon Mar 12 10:59:21 2007 -0700
+++ b/ChangeLog	Mon Mar 12 11:03:24 2007 -0700
@@ -1,3 +1,10 @@
+2007-03-12 17:59:21 +0000  William Pitcock <nenolod@sacredspiral.co.uk>
+  revision [1712]
+  - fork wma plugin
+  
+  0 files changed
+
+
 2007-03-12 16:12:26 +0000  Yoshiki Yazawa <yaz@cc.rim.or.jp>
   revision [1708]
   - should check data != NULL before clear data->playing.
--- a/src/madplug/decoder.c	Mon Mar 12 10:59:21 2007 -0700
+++ b/src/madplug/decoder.c	Mon Mar 12 11:03:24 2007 -0700
@@ -509,14 +509,14 @@
                 g_message("seeking: %d", info->seek);
 #endif
                 int new_position;
-                int seconds =
-                    mad_timer_count(info->duration, MAD_UNITS_SECONDS);
-                if (info->seek >= seconds)
-                    info->seek = seconds;
+                gulong milliseconds =
+                    mad_timer_count(info->duration, MAD_UNITS_MILLISECONDS);
+                if (info->seek >= milliseconds)
+                    info->seek = milliseconds;
 
-                mad_timer_set(&info->pos, info->seek, 0, 0);
+                mad_timer_set(&info->pos, 0, info->seek, 1000); // in millisecond
                 new_position =
-                    ((double) info->seek / (double) seconds) * info->size;
+                    ((double) info->seek / (double) milliseconds) * info->size;
 
                 if(new_position < 0)
                     new_position = 0;
@@ -644,12 +644,8 @@
                       info->playback->output->buffer_playing());
 #endif
             g_get_current_time(&sleeptime);
-            sleeptime.tv_usec += 500000;
-            if(sleeptime.tv_usec >= 1000000) {
-                sleeptime.tv_sec += 1;
-                sleeptime.tv_usec -= 1000000;
-            }
-
+            g_time_val_add(&sleeptime, 500000);
+            
             g_mutex_lock(mad_mutex);
             g_cond_timed_wait(mad_cond, mad_mutex, &sleeptime);
             if (!info->playback->playing) {
--- a/src/madplug/plugin.c	Mon Mar 12 10:59:21 2007 -0700
+++ b/src/madplug/plugin.c	Mon Mar 12 11:03:24 2007 -0700
@@ -460,15 +460,19 @@
     playback->output->pause(paused);
 }
 
-static void audmad_seek(InputPlayback *playback, int time)
+static void audmad_mseek(InputPlayback *playback, gulong millisecond)
 {
     g_mutex_lock(pb_mutex);
     info.playback = playback;
-    /* xmms gives us the desired seek time in seconds */
-    info.seek = time;
+    info.seek = millisecond;
     g_mutex_unlock(pb_mutex);
 }
 
+static void audmad_seek(InputPlayback *playback, gint time)
+{
+    audmad_mseek(playback, time * 1000);
+}
+
 /**
  * Scan the given file or URL.
  * Fills in the title string and the track length in milliseconds.
@@ -741,6 +745,7 @@
     mad_plugin->get_song_tuple = audmad_get_song_tuple;
     mad_plugin->is_our_file_from_vfs = audmad_is_our_fd;
     mad_plugin->vfs_extensions = fmts;
+    mad_plugin->mseek = audmad_mseek;
 
     return mad_plugin;
 }
--- a/src/madplug/plugin.h	Mon Mar 12 10:59:21 2007 -0700
+++ b/src/madplug/plugin.h	Mon Mar 12 11:03:24 2007 -0700
@@ -53,7 +53,7 @@
     InputPlayback *playback;
 
     /* flags */
-    gint seek;      /**< seek time in seconds */
+    gulong seek;      /**< seek time in milliseconds */
 
     /* state */
     guint current_frame;/**< current mp3 frame */