From 03e11849011b59026b4a54faf09838ef4718405c Mon Sep 17 00:00:00 2001 From: waker Date: Mon, 7 May 2012 23:36:10 +0200 Subject: fixed loading remote playlists with unknown size --- plugins/vfs_curl/vfs_curl.c | 2 ++ streamer.c | 9 ++++++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/plugins/vfs_curl/vfs_curl.c b/plugins/vfs_curl/vfs_curl.c index b0779da7..bf35b7f4 100644 --- a/plugins/vfs_curl/vfs_curl.c +++ b/plugins/vfs_curl/vfs_curl.c @@ -652,6 +652,7 @@ http_thread_func (void *ctx) { trace ("curl error:\n%s\n", fp->http_err); } deadbeef->mutex_lock (fp->mutex); +#if 0 if (status == 0 && fp->length < 0 && fp->status != STATUS_ABORTED && fp->status != STATUS_SEEK) { trace ("vfs_curl: restarting stream\n"); // NOTE: don't do http_stream_reset here - we don't want to cut the ending @@ -669,6 +670,7 @@ http_thread_func (void *ctx) { deadbeef->mutex_unlock (fp->mutex); continue; } +#endif if (fp->status != STATUS_SEEK) { trace ("vfs_curl: break loop\n"); deadbeef->mutex_unlock (fp->mutex); diff --git a/streamer.c b/streamer.c index ce381dee..5da0d08f 100644 --- a/streamer.c +++ b/streamer.c @@ -755,8 +755,9 @@ streamer_set_current (playItem_t *it) { trace ("failed to alloc %d bytes for playlist buffer\n"); goto m3u_error; } + trace ("reading %d bytes\n", size); int rd = vfs_fread (buf, 1, size, fp); - if (rd != size) { + if (rd <= 0) { trace ("failed to download %d bytes (got %d bytes)\n", size, rd); goto m3u_error; } @@ -772,13 +773,14 @@ streamer_set_current (playItem_t *it) { trace ("failed to open temp file %s\n", tempfile); goto m3u_error; } + trace ("writing to %s\n", tempfile); out = fdopen (fd, "w+b"); if (!out) { trace ("fdopen failed for %s\n", tempfile); goto m3u_error; } - int rw = fwrite (buf, 1, size, out); - if (rw != size) { + int rw = fwrite (buf, 1, rd, out); + if (rw != rd) { trace ("failed to write %d bytes into file %s\n", size, tempfile); goto m3u_error; } @@ -786,6 +788,7 @@ streamer_set_current (playItem_t *it) { fd = -1; out = NULL; + trace ("loading playlist from %s\n", tempfile); // load playlist playlist_t *plt = plt_alloc ("temp"); DB_playlist_t **plug = plug_get_playlist_list (); -- cgit v1.2.3