diff options
-rw-r--r-- | callbacks.c | 4 | ||||
-rw-r--r-- | main.c | 9 | ||||
-rw-r--r-- | messages.h | 1 | ||||
-rw-r--r-- | streamer.c | 21 | ||||
-rw-r--r-- | streamer.h | 4 |
5 files changed, 28 insertions, 11 deletions
diff --git a/callbacks.c b/callbacks.c index 47f7b538..fd97664d 100644 --- a/callbacks.c +++ b/callbacks.c @@ -37,6 +37,7 @@ #include "codec.h" #include "playback.h" #include "search.h" +#include "streamer.h" #include "cwav.h" #include "cvorbis.h" @@ -940,7 +941,8 @@ on_seekbar_button_release_event (GtkWidget *widget, if (time < 0) { time = 0; } - messagepump_push (M_SONGSEEK, 0, time * 1000, 0); + streamer_set_seek (time); +// messagepump_push (M_SONGSEEK, 0, time * 1000, 0); return FALSE; } @@ -183,15 +183,6 @@ psdl_thread (uintptr_t ctx) { gtkpl_randomsong (); GDK_THREADS_LEAVE(); break; - case M_SONGSEEK: - if (playlist_current.codec) { - p_pause (); - codec_lock (); - playlist_current.codec->seek (p1 / 1000.f); - codec_unlock (); - p_unpause (); - } - break; case M_ADDDIR: // long time processing gtkpl_add_dir (&main_playlist, (char *)ctx); @@ -27,7 +27,6 @@ enum { M_STOPSONG, M_PAUSESONG, M_PLAYRANDOM, - M_SONGSEEK, M_SONGCHANGED, // p1=from, p2=to M_ADDDIR, // ctx = pointer to string, which must be freed by f_free M_ADDFILES, // ctx = GSList pointer, must be freed with g_slist_free @@ -45,12 +45,19 @@ static uintptr_t mutex; static int nextsong = -1; static int nextsong_pstate = -1; +static float seekpos = -1; + void streamer_set_nextsong (int song, int pstate) { nextsong = song; nextsong_pstate = pstate; } +void +streamer_set_seek (float pos) { + seekpos = pos; +} + static int streamer_read_async (char *bytes, int size); @@ -95,6 +102,20 @@ streamer_thread (uintptr_t ctx) { usleep (3000); continue; } + + if (seekpos >= 0) { + float pos = seekpos; + seekpos = -1; + if (playlist_current.codec->seek (pos) >= 0) { + streamer_lock (); + streambuffer_fill = 0; + streamer_unlock (); + codec_lock (); + codecleft = 0; + codec_unlock (); + } + } + streamer_lock (); if (streambuffer_fill < STREAM_BUFFER_SIZE) { int sz = STREAM_BUFFER_SIZE - streambuffer_fill; @@ -38,10 +38,14 @@ streamer_unlock (void); // pstate indicates what to do with playback // -1 means "don't do anything" +// -2 means "end of playlist" // otherwise "set state to this value" void streamer_set_nextsong (int song, int pstate); +void +streamer_set_seek (float pos); + int streamer_get_fill_level (void); |