From e17823663289e21e043fbf32e8d26bc133a7b3fe Mon Sep 17 00:00:00 2001 From: waker Date: Mon, 17 Aug 2009 20:23:30 +0200 Subject: fixed hanging on bad files in playlist --- playlist.c | 5 ++++- streamer.c | 21 ++++++++++++++++++++- 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/playlist.c b/playlist.c index 94f2181e..8b15bdf1 100644 --- a/playlist.c +++ b/playlist.c @@ -647,7 +647,10 @@ pl_set_current (playItem_t *it) { // don't do anything on fail, streamer will take care ret = it->codec->init (it); if (ret < 0) { - it->codec->info.samplesPerSecond = -1; +// pl_item_free (&playlist_current); +// playlist_current_ptr = NULL; +// return ret; +//// it->codec->info.samplesPerSecond = -1; } } if (playlist_current_ptr) { diff --git a/streamer.c b/streamer.c index b89717fd..cebd9eed 100644 --- a/streamer.c +++ b/streamer.c @@ -45,6 +45,7 @@ static char streambuffer[STREAM_BUFFER_SIZE]; static uintptr_t mutex; static int nextsong = -1; static int nextsong_pstate = -1; +static int badsong = -1; static float seekpos = -1; @@ -82,7 +83,25 @@ streamer_thread (uintptr_t ctx) { codec_lock (); codecleft = 0; codec_unlock (); - pl_set_current (pl_get_for_idx (sng)); + if (badsong == sng) { + //printf ("looped to bad file. stopping...\n"); + streamer_set_nextsong (-2, 1); + badsong = -1; + continue; + } + int ret = pl_set_current (pl_get_for_idx (sng)); + if (ret < 0) { + //printf ("bad file in playlist, skipping...\n"); + // remember bad song number in case of looping + if (badsong == -1) { + badsong = sng; + } + // try jump to next song + pl_nextsong (0); + usleep (3000); + continue; + } + badsong = -1; playpos = 0; if (pstate == 0) { p_stop (); -- cgit v1.2.3