# HG changeset patch # User Yoshiki Yazawa # Date 1203668746 -32400 # Node ID 0427c5d07a668cce4e0c8606bf31faacd66dc02f # Parent 372c4e0943ed031debd821fccc7b92c503d4aff9 added mseek support to flacng. patch by Piotr Garus. thanks Piotr! diff -r 372c4e0943ed -r 0427c5d07a66 src/flacng/plugin.c --- 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) { diff -r 372c4e0943ed -r 0427c5d07a66 src/flacng/plugin.h --- 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);