Mercurial > audlegacy-plugins
changeset 862:baa22cb0216d trunk
[svn] - add mseek support.
- fix a major bug which consumes CPU time heavily.
author | yaz |
---|---|
date | Thu, 15 Mar 2007 22:09:36 -0700 |
parents | 59a876be8550 |
children | 973d9b624987 |
files | ChangeLog src/wav/Makefile src/wav/wav-sndfile.c src/wav/wav-sndfile.h |
diffstat | 4 files changed, 33 insertions(+), 17 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog Thu Mar 15 08:04:47 2007 -0700 +++ b/ChangeLog Thu Mar 15 22:09:36 2007 -0700 @@ -1,3 +1,11 @@ +2007-03-15 15:04:47 +0000 Yoshiki Yazawa <yaz@cc.rim.or.jp> + revision [1822] + - refine watchdog thread. + + trunk/src/cue/cuesheet.c | 17 +++++++---------- + 1 file changed, 7 insertions(+), 10 deletions(-) + + 2007-03-15 11:43:58 +0000 Yoshiki Yazawa <yaz@cc.rim.or.jp> revision [1820] - support "Repeat".
--- a/src/wav/Makefile Thu Mar 15 08:04:47 2007 -0700 +++ b/src/wav/Makefile Thu Mar 15 22:09:36 2007 -0700 @@ -9,7 +9,7 @@ LIBADD = -L/usr/local/lib $(SNDFILE_LIBS) $(GTK_LIBS) $(GLIB_LIBS) $(PANGO_LIBS) -CFLAGS += $(PICFLAGS) $(GTK_CFLAGS) $(GLIB_CFLAGS) $(PANGO_CFLAGS) -I../../intl -I../.. +CFLAGS += $(PICFLAGS) $(GTK_CFLAGS) $(GLIB_CFLAGS) $(PANGO_CFLAGS) -I../../intl -I../.. -Wall OBJECTS = ${SOURCES:.c=.o}
--- a/src/wav/wav-sndfile.c Thu Mar 15 08:04:47 2007 -0700 +++ b/src/wav/wav-sndfile.c Thu Mar 15 22:09:36 2007 -0700 @@ -51,7 +51,7 @@ static int song_length; static int bit_rate = 0; -static int seek_time = -1; +static glong seek_time = -1; static GThread *decode_thread; static GMutex *decode_start_mutex; @@ -83,7 +83,13 @@ NULL, get_song_info, NULL, - NULL + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + file_mseek, }; int @@ -152,12 +158,7 @@ GTimeVal sleeptime; g_get_current_time(&sleeptime); - sleeptime.tv_usec += 10000; - if (sleeptime.tv_usec >= 1000000) - { - sleeptime.tv_sec += 1; - sleeptime.tv_usec -= 1000000; - } + g_time_val_add(&sleeptime, 10000); g_mutex_lock(decode_mutex); @@ -166,8 +167,7 @@ if (samples > 0 && playback->playing == TRUE) { - while ((playback->output->buffer_free () < - (samples * sizeof (short))) && + while ((playback->output->buffer_free () < samples) && playback->playing == TRUE) { g_cond_timed_wait(decode_cond, @@ -195,10 +195,11 @@ } /* Do seek if seek_time is valid. */ - if (seek_time > 0) + if (seek_time >= 0) { - sf_seek (sndfile, seek_time * sfinfo.samplerate, SEEK_SET); - playback->output->flush (seek_time * 1000); + sf_seek (sndfile, (sf_count_t)((gint64)seek_time * (gint64)sfinfo.samplerate / 1000L), + SEEK_SET); + playback->output->flush (seek_time); seek_time = -1; } @@ -292,18 +293,25 @@ } static void -file_seek (InputPlayback *playback, int time) +file_mseek (InputPlayback *playback, gulong millisecond) { if (! sfinfo.seekable) return; - seek_time = time; + seek_time = (glong)millisecond; while (seek_time != -1) xmms_usleep (80000); } static void +file_seek (InputPlayback *playback, int time) +{ + gulong millisecond = time * 1000; + file_mseek(playback, millisecond); +} + +static void get_song_info (char *filename, char **title, int *length) { (*length) = get_song_length(filename);
--- a/src/wav/wav-sndfile.h Thu Mar 15 08:04:47 2007 -0700 +++ b/src/wav/wav-sndfile.h Thu Mar 15 22:09:36 2007 -0700 @@ -29,9 +29,9 @@ static void play_start (InputPlayback *playback); static void play_stop (InputPlayback *playback); static void file_seek (InputPlayback *playback, int time); -static int get_time (InputPlayback *playback); static void get_song_info (char *filename, char **title, int *length); static void wav_about (void); static void play_pause (InputPlayback *playback, gshort p); +static void file_mseek (InputPlayback *playback, gulong millisecond); #endif