# HG changeset patch # User iabervon # Date 1168847639 28800 # Node ID ed94145472df537f5d4419eaf511ccf63f44afbc # Parent 74b23aec578d7b47c2cdb70f8a560ec22fe8dd96 [svn] Support shoutcast (over TCP) with VFS HTTP code. mpg123 has to accept failure on seeking to the end of the file. diff -r 74b23aec578d -r ed94145472df ChangeLog --- a/ChangeLog Sun Jan 14 22:39:39 2007 -0800 +++ b/ChangeLog Sun Jan 14 23:53:59 2007 -0800 @@ -1,3 +1,12 @@ +2007-01-15 06:39:39 +0000 William Pitcock + revision [942] + - buildsystem glue for curl http:// transport + + trunk/configure.ac | 2 +- + trunk/src/curl/Makefile | 18 ++++++++++++++++++ + 2 files changed, 19 insertions(+), 1 deletion(-) + + 2007-01-15 06:34:57 +0000 Daniel Barkalow revision [940] Add code for a plugin to use CURL for http. Needs some build-system diff -r 74b23aec578d -r ed94145472df src/curl/curl.c --- a/src/curl/curl.c Sun Jan 14 22:39:39 2007 -0800 +++ b/src/curl/curl.c Sun Jan 14 23:53:59 2007 -0800 @@ -30,7 +30,7 @@ struct _CurlHandle { CURL *curl; - gsize length; // the length of the file + gssize length; // the length of the file gsize rd_abs; // the absolute position for reading from the stream gsize wr_abs; // the absolute position where the input connection is @@ -46,7 +46,7 @@ }; /* TODO: - * - Icecast + * - Fix hang if the server closes the connection in the middle * - Clever buffer stuff when you read a bit of the beginning and a bit of the * end of a file */ @@ -97,9 +97,13 @@ if (retcode == CURLE_OK) { handle->length = value; + if (handle->length == 0) + handle->length = -2; + //g_print("Length: %d\n", handle->length); } else { + handle->length = -2; g_print("getinfo gave error\n"); } } @@ -140,6 +144,7 @@ curl_manage_request(gpointer arg) { CurlHandle *handle = arg; + CURLcode result; //g_print("Connect %p\n", handle); if (handle->no_data) @@ -153,8 +158,13 @@ curl_easy_setopt(handle->curl, CURLOPT_HTTPGET, 1); } - curl_easy_perform(handle->curl); - update_length(handle); + result = curl_easy_perform(handle->curl); + if (result == CURLE_OK) + update_length(handle); + if (result != CURLE_OK && result != CURLE_WRITE_ERROR) + { + g_print("Got curl error %d\n", result); + } //g_print("Done %p%s", handle, handle->cancel ? " (aborted)\n" : "\n"); handle->cancel = 1; return NULL; @@ -271,9 +281,7 @@ while (ret < sz) { size_t available; - while (!(available = buf_available(handle)) && - (handle->length == -1 || handle->rd_abs < handle->length) && - !handle->cancel) + while (!(available = buf_available(handle)) && !handle->cancel) g_usleep(10000); if (available > sz - ret) available = sz - ret; @@ -345,7 +353,7 @@ } } - if (whence == SEEK_END && handle->length == -1) + if (whence == SEEK_END && handle->length < 0) { //g_print("Tried to seek to the end of a file with unknown length\n"); // don't know how long it is... diff -r 74b23aec578d -r ed94145472df src/mpg123/common.c --- a/src/mpg123/common.c Sun Jan 14 22:39:39 2007 -0800 +++ b/src/mpg123/common.c Sun Jan 14 23:53:59 2007 -0800 @@ -222,8 +222,10 @@ if (filept == NULL) return -1; - if (vfs_fseek(filept, 0, SEEK_END) < 0) - return -1; + if (vfs_fseek(filept, 0, SEEK_END) < 0) { + mpgdec_info->filesize = 0; + return 0; + } mpgdec_info->filesize = vfs_ftell(filept); if (vfs_fseek(filept, -128, SEEK_END) < 0)