diff options
author | Lars-Dominik Braun <PromyLOPh@lavabit.com> | 2008-12-13 18:55:02 +0100 |
---|---|---|
committer | Lars-Dominik Braun <PromyLOPh@lavabit.com> | 2008-12-13 18:55:02 +0100 |
commit | 60622ee6d13324d9433a82ac721270723a180668 (patch) | |
tree | faffb5a4f4c75005b233a26f33c86e35a96287a4 /src | |
parent | 0180e2a1a6ff72df90edeaa08a219f4e818e50ae (diff) | |
download | pianobar-60622ee6d13324d9433a82ac721270723a180668.tar.gz pianobar-60622ee6d13324d9433a82ac721270723a180668.tar.bz2 pianobar-60622ee6d13324d9433a82ac721270723a180668.zip |
Use curl's built-in range support
Diffstat (limited to 'src')
-rw-r--r-- | src/player.c | 13 |
1 files changed, 4 insertions, 9 deletions
diff --git a/src/player.c b/src/player.c index d543547..7e93933 100644 --- a/src/player.c +++ b/src/player.c @@ -235,8 +235,6 @@ size_t BarPlayerCurlCb (void *ptr, size_t size, size_t nmemb, void *stream) { void *BarPlayerThread (void *data) { struct aacPlayer *player = data; NeAACDecConfigurationPtr conf; - struct curl_slist *extraHeader = NULL; - char rangeHeader[255]; CURLcode curlRet = 0; /* init handles */ @@ -258,6 +256,8 @@ void *BarPlayerThread (void *data) { curl_easy_setopt (player->audioFd, CURLOPT_WRITEDATA, (void *) player); curl_easy_setopt (player->audioFd, CURLOPT_USERAGENT, PACKAGE_STRING); curl_easy_setopt (player->audioFd, CURLOPT_CONNECTTIMEOUT, 60); + /* start downloading from beginning of file */ + curl_easy_setopt (player->audioFd, CURLOPT_RESUME_FROM, 0); player->mode = PLAYER_INITIALIZED; @@ -266,15 +266,10 @@ void *BarPlayerThread (void *data) { do { /* if curl failed, setup new headers _everytime_ (the range changed) */ if (curlRet == CURLE_PARTIAL_FILE) { - snprintf (rangeHeader, sizeof (rangeHeader), - "Range: bytes=%i-", player->bytesReceived); - extraHeader = curl_slist_append (extraHeader, rangeHeader); - curl_easy_setopt (player->audioFd, CURLOPT_HTTPHEADER, - extraHeader); + curl_easy_setopt (player->audioFd, CURLOPT_RESUME_FROM, + player->bytesReceived); } curlRet = curl_easy_perform (player->audioFd); - curl_slist_free_all (extraHeader); - extraHeader = NULL; } while (curlRet == CURLE_PARTIAL_FILE); NeAACDecClose(player->aacHandle); |