diff options
author | Alexey Yakovenko <wakeroid@gmail.com> | 2010-05-22 13:32:23 +0200 |
---|---|---|
committer | Alexey Yakovenko <wakeroid@gmail.com> | 2010-05-22 13:32:23 +0200 |
commit | 94c7d8d731349dbc841fa816d363e5ed4b197784 (patch) | |
tree | 6cdb7422ebf3d2b54f836e5cc2d39336bf8804e7 /plugins/vfs_curl | |
parent | d06261ccac56987f57258b679bb1db2ced1ec41f (diff) |
restart shoutcast stream if curl_easy_perform returns 0
(enabled vfs_curl logging/debugging)
Diffstat (limited to 'plugins/vfs_curl')
-rw-r--r-- | plugins/vfs_curl/vfs_curl.c | 36 |
1 files changed, 28 insertions, 8 deletions
diff --git a/plugins/vfs_curl/vfs_curl.c b/plugins/vfs_curl/vfs_curl.c index 22b00216..5476f5c4 100644 --- a/plugins/vfs_curl/vfs_curl.c +++ b/plugins/vfs_curl/vfs_curl.c @@ -25,8 +25,10 @@ #include <time.h> #include "../../deadbeef.h" -//#define trace(...) { fprintf(stderr, __VA_ARGS__); } -#define trace(fmt,...) +#pragma GCC optimize("O0") + +#define trace(...) { fprintf(stderr, __VA_ARGS__); } +//#define trace(fmt,...) #define min(x,y) ((x)<(y)?(x):(y)) #define max(x,y) ((x)>(y)?(x):(y)) @@ -40,12 +42,13 @@ static DB_functions_t *deadbeef; #define TIMEOUT 10 // in seconds -#define STATUS_INITIAL 0 -//#define STATUS_STARTING 1 -#define STATUS_READING 2 -#define STATUS_FINISHED 3 -#define STATUS_ABORTED 4 -#define STATUS_SEEK 5 +enum { + STATUS_INITIAL = 0, + STATUS_READING = 1, + STATUS_FINISHED = 2, + STATUS_ABORTED = 3, + STATUS_SEEK = 4, +}; typedef struct { DB_vfs_t *vfs; @@ -551,6 +554,23 @@ http_thread_func (void *ctx) { trace ("curl error:\n%s\n", http_err); } deadbeef->mutex_lock (fp->mutex); + if (status == 0 && fp->length < 0 && fp->status != STATUS_ABORTED && fp->status != STATUS_SEEK) { + trace ("vfs_curl: restarting stream\n"); + fp->status = STATUS_INITIAL; + fp->skipbytes = 0; + if (fp->content_type) { + free (fp->content_type); + fp->content_type = NULL; + } + fp->seektoend = 0; + fp->gotheader = 0; + fp->icyheader = 0; + fp->gotsomeheader = 0; + fp->wait_meta = 0; + fp->icy_metaint = 0; + deadbeef->mutex_unlock (fp->mutex); + continue; + } if (fp->status != STATUS_SEEK) { deadbeef->mutex_unlock (fp->mutex); break; |