diff options
-rw-r--r-- | main.c | 1 | ||||
-rw-r--r-- | palsa.c | 4 | ||||
-rw-r--r-- | streamer.c | 14 | ||||
-rw-r--r-- | streamer.h | 5 |
4 files changed, 21 insertions, 3 deletions
@@ -350,6 +350,7 @@ player_thread (uintptr_t ctx) { gtkpl_add_files (&main_playlist, (GSList *)ctx); break; case M_OPENFILES: + p_stop (); gtkpl_add_files (&main_playlist, (GSList *)ctx); gtkpl_playsong (&main_playlist); break; @@ -342,6 +342,10 @@ palsa_thread (uintptr_t context) { static void palsa_callback (char *stream, int len) { + if (streamer_get_fill () < len) { + memset (stream, 0, len); + return; + } int bytesread = streamer_read (stream, len); int ivolume = volume * 1000; for (int i = 0; i < bytesread/2; i++) { @@ -342,6 +342,16 @@ streamer_read (char *bytes, int size) { } int -streamer_get_fill_level (void) { - return streambuffer_fill / (STREAM_BUFFER_SIZE / 100); +streamer_get_fill (void) { + return streambuffer_fill; +} + +int +streamer_is_buffering (void) { + if (streambuffer_fill < 16384) { + return 1; + } + else { + return 0; + } } @@ -47,9 +47,12 @@ void streamer_set_seek (float pos); int -streamer_get_fill_level (void); +streamer_get_fill (void); float streamer_get_playpos (void); +int +streamer_is_buffering (void); + #endif // __STREAMER_H |