changeset 863:973d9b624987 trunk

[svn] - add mseek support to wav.c (without libsndfile version) too.
author yaz
date Thu, 15 Mar 2007 22:36:55 -0700
parents baa22cb0216d
children e00028eb356c
files ChangeLog src/wav/wav.c src/wav/wav.h
diffstat 3 files changed, 26 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Thu Mar 15 22:09:36 2007 -0700
+++ b/ChangeLog	Thu Mar 15 22:36:55 2007 -0700
@@ -1,3 +1,14 @@
+2007-03-16 05:09:36 +0000  Yoshiki Yazawa <yaz@cc.rim.or.jp>
+  revision [1824]
+  - add mseek support.
+  - fix a major bug which consumes CPU time heavily.
+  
+  trunk/src/wav/Makefile      |    2 +-
+  trunk/src/wav/wav-sndfile.c |   38 +++++++++++++++++++++++---------------
+  trunk/src/wav/wav-sndfile.h |    2 +-
+  3 files changed, 25 insertions(+), 17 deletions(-)
+
+
 2007-03-15 15:04:47 +0000  Yoshiki Yazawa <yaz@cc.rim.or.jp>
   revision [1822]
   - refine watchdog thread.
--- a/src/wav/wav.c	Thu Mar 15 22:09:36 2007 -0700
+++ b/src/wav/wav.c	Thu Mar 15 22:36:55 2007 -0700
@@ -65,6 +65,7 @@
     NULL,
     NULL,
     wav_fmts,
+    mseek,
 };
 
 WaveFile *wav_file = NULL;
@@ -296,10 +297,10 @@
         else
             xmms_usleep(10000);
         if (wav_file->seek_to != -1) {
-            wav_file->position = wav_file->seek_to * rate;
+            wav_file->position = (unsigned long)((gint64)wav_file->seek_to * (gint64)rate / 1000L);
             vfs_fseek(wav_file->file,
                       wav_file->position + wav_file->data_offset, SEEK_SET);
-            playback->output->flush(wav_file->seek_to * 1000);
+            playback->output->flush(wav_file->seek_to);
             wav_file->seek_to = -1;
         }
 
@@ -447,9 +448,9 @@
 }
 
 static void
-seek(InputPlayback * data, gint time)
+mseek(InputPlayback * data, gulong millisecond)
 {
-    wav_file->seek_to = time;
+    wav_file->seek_to = millisecond;
 
     wav_file->eof = FALSE;
 
@@ -457,6 +458,13 @@
         xmms_usleep(10000);
 }
 
+static void
+seek(InputPlayback * data, gint time)
+{
+    gulong millisecond = time * 1000;
+    mseek(data, millisecond);
+}
+
 static int
 get_time(InputPlayback *playback)
 {
--- a/src/wav/wav.h	Thu Mar 15 22:09:36 2007 -0700
+++ b/src/wav/wav.h	Thu Mar 15 22:36:55 2007 -0700
@@ -48,7 +48,8 @@
     short format_tag, channels, block_align, bits_per_sample, eof;
     long samples_per_sec, avg_bytes_per_sec;
     unsigned long position, length;
-    int seek_to, data_offset, going;
+    glong seek_to;
+    int data_offset, going;
     pid_t pid;
 } WaveFile;
 
@@ -60,5 +61,6 @@
 static void wav_pause(InputPlayback * data, short p);
 static int get_time(InputPlayback * data);
 static void get_song_info(char *filename, char **title, int *length);
+static void mseek(InputPlayback * data, gulong millisecond);
 
 #endif