changeset 2417:0427c5d07a66

added mseek support to flacng. patch by Piotr Garus. thanks Piotr!
author Yoshiki Yazawa <yaz@cc.rim.or.jp>
date Fri, 22 Feb 2008 17:25:46 +0900
parents 372c4e0943ed
children 699b5e756bc4
files src/flacng/plugin.c src/flacng/plugin.h
diffstat 2 files changed, 14 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/src/flacng/plugin.c	Wed Feb 20 14:05:47 2008 +0100
+++ b/src/flacng/plugin.c	Fri Feb 22 17:25:46 2008 +0900
@@ -39,6 +39,7 @@
     .play_file = flac_play_file,
     .stop = flac_stop,
     .pause = flac_pause,
+    .mseek = flac_mseek,
     .seek = flac_seek,
     .get_song_info = flac_get_song_info,
     .get_song_tuple = flac_get_song_tuple,	// get a tuple
@@ -55,7 +56,7 @@
 callback_info* test_info;
 callback_info* main_info;
 gboolean plugin_initialized = FALSE;
-gint seek_to = -1;
+glong seek_to = -1;
 static GThread* thread = NULL;
 
 /* === */
@@ -436,9 +437,9 @@
          * Do we have to seek to somewhere?
          */
         if (-1 != seek_to) {
-            _DEBUG("Seek requested to %d seconds", seek_to);
+            _DEBUG("Seek requested to %d miliseconds", seek_to);
 
-            seek_sample = seek_to * main_info->stream.samplerate;
+            seek_sample = (unsigned long)((gint64)seek_to * (gint64) main_info->stream.samplerate / 1000L );
             _DEBUG("Seek requested to sample %d", seek_sample);
             if (FALSE == FLAC__stream_decoder_seek_absolute(main_decoder, seek_sample)) {
                 _ERROR("Could not seek to sample %d!", seek_sample);
@@ -446,7 +447,7 @@
                 /*
                  * Flush the buffers
                  */
-                flac_ip.output->flush(seek_to * 1000);
+                flac_ip.output->flush(seek_to);
             }
             seek_to = -1;
         }
@@ -574,7 +575,7 @@
 
 /* --- */
 
-void flac_seek(InputPlayback* input, gint time) {
+void flac_mseek(InputPlayback* input, gulong milisecond) {
 
     _ENTER;
 
@@ -583,8 +584,8 @@
         _LEAVE;
     }
 
-    _DEBUG("Requesting seek to %d", time);
-    seek_to = time;
+    _DEBUG("Requesting seek to %d", milisecond);
+    seek_to = milisecond;
 
     while (-1 != seek_to) {
         g_usleep(10000);
@@ -593,6 +594,11 @@
     _LEAVE;
 }
 
+void flac_seek(InputPlayback* input, gint time) {
+    gulong milisecond = time * 1000;
+    flac_mseek(input, milisecond);
+}
+
 /* --- */
 
 void flac_get_song_info(gchar* filename, gchar** title, gint* length) {
--- a/src/flacng/plugin.h	Wed Feb 20 14:05:47 2008 +0100
+++ b/src/flacng/plugin.h	Fri Feb 22 17:25:46 2008 +0900
@@ -9,6 +9,7 @@
 void flac_play_file (InputPlayback* input);
 void flac_stop(InputPlayback* input);
 void flac_pause(InputPlayback* input, gshort p);
+void flac_mseek(InputPlayback* input, gulong milisecond);
 void flac_seek(InputPlayback* input, gint time);
 void flac_get_song_info(gchar* filename, gchar** title, gint* length);
 Tuple *flac_get_song_tuple(gchar* filename);