summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorGravatar Alexey Yakovenko <wakeroid@gmail.com>2009-11-08 12:22:39 +0100
committerGravatar Alexey Yakovenko <wakeroid@gmail.com>2009-11-08 12:22:39 +0100
commit16f075f95d55466856cf7f3fdea2c503b2fcd7cf (patch)
treead8c457b89cd4b112b4720f186af2a26c6a037ca /plugins
parent9743e5efa30faa3eedaadc534d821a29ba41290e (diff)
now it's possible to interrupt hanging file operations (e.g. slow http)
Diffstat (limited to 'plugins')
-rw-r--r--plugins/mpgmad/mpgmad.c3
-rw-r--r--plugins/vfs_curl/vfs_curl.c24
-rw-r--r--plugins/vorbis/vorbis.c3
3 files changed, 28 insertions, 2 deletions
diff --git a/plugins/mpgmad/mpgmad.c b/plugins/mpgmad/mpgmad.c
index 8e54b6c8..763b7fb1 100644
--- a/plugins/mpgmad/mpgmad.c
+++ b/plugins/mpgmad/mpgmad.c
@@ -470,7 +470,7 @@ cmp3_scan_stream (buffer_t *buffer, int sample) {
static int
cmp3_init (DB_playItem_t *it) {
memset (&buffer, 0, sizeof (buffer));
- buffer.file = deadbeef->fopen (it->fname);
+ buffer.file = plugin.info.file = deadbeef->fopen (it->fname);
if (!buffer.file) {
return -1;
}
@@ -783,6 +783,7 @@ cmp3_decode_float32 (void) {
static void
cmp3_free (void) {
+ plugin.info.file = NULL;
if (buffer.file) {
deadbeef->fclose (buffer.file);
buffer.file = NULL;
diff --git a/plugins/vfs_curl/vfs_curl.c b/plugins/vfs_curl/vfs_curl.c
index 3619ab6e..42211fe3 100644
--- a/plugins/vfs_curl/vfs_curl.c
+++ b/plugins/vfs_curl/vfs_curl.c
@@ -290,6 +290,7 @@ http_curl_write_abort (void *ptr, size_t size, size_t nmemb, void *stream) {
static int
http_curl_control (void *stream, double dltotal, double dlnow, double ultotal, double ulnow) {
+ trace ("http_curl_control\n");
assert (stream);
HTTP_FILE *fp = (HTTP_FILE *)stream;
if (fp->status == STATUS_ABORTED) {
@@ -342,6 +343,8 @@ http_thread_func (uintptr_t ctx) {
curl_easy_setopt (curl, CURLOPT_HEADERFUNCTION, http_content_header_handler);
curl_easy_setopt (curl, CURLOPT_HEADERDATA, ctx);
curl_easy_setopt (curl, CURLOPT_PROGRESSFUNCTION, http_curl_control);
+ curl_easy_setopt (curl, CURLOPT_NOPROGRESS, 0);
+ curl_easy_setopt (curl, CURLOPT_PROGRESSDATA, ctx);
// enable up to 10 redirects
curl_easy_setopt (curl, CURLOPT_FOLLOWLOCATION, 1);
curl_easy_setopt (curl, CURLOPT_MAXREDIRS, 10);
@@ -589,6 +592,9 @@ http_getlength (DB_FILE *stream) {
trace ("http_getlength\n");
assert (stream);
HTTP_FILE *fp = (HTTP_FILE *)stream;
+ if (fp->status == STATUS_ABORTED) {
+ return -1;
+ }
if (!fp->tid) {
http_start_streamer (fp);
}
@@ -604,6 +610,9 @@ http_get_content_type (DB_FILE *stream) {
trace ("http_get_content_type\n");
assert (stream);
HTTP_FILE *fp = (HTTP_FILE *)stream;
+ if (fp->status == STATUS_ABORTED) {
+ return NULL;
+ }
if (fp->gotheader) {
return fp->content_type;
}
@@ -622,6 +631,9 @@ http_get_content_name (DB_FILE *stream) {
trace ("http_get_content_name\n");
assert (stream);
HTTP_FILE *fp = (HTTP_FILE *)stream;
+ if (fp->status == STATUS_ABORTED) {
+ return NULL;
+ }
if (fp->gotheader) {
return fp->content_name;
}
@@ -640,6 +652,9 @@ http_get_content_genre (DB_FILE *stream) {
trace ("http_get_content_genre\n");
assert (stream);
HTTP_FILE *fp = (HTTP_FILE *)stream;
+ if (fp->status == STATUS_ABORTED) {
+ return NULL;
+ }
if (fp->gotheader) {
return fp->content_genre;
}
@@ -653,6 +668,14 @@ http_get_content_genre (DB_FILE *stream) {
return fp->content_genre;
}
+static void
+http_stop (DB_FILE *stream) {
+ trace ("http_stop\n");
+ assert (stream);
+ HTTP_FILE *fp = (HTTP_FILE *)stream;
+ fp->status = STATUS_ABORTED;
+}
+
static const char *scheme_names[] = { "http://", "ftp://", NULL };
// standard stdio vfs
@@ -676,6 +699,7 @@ static DB_vfs_t plugin = {
.get_content_type = http_get_content_type,
.get_content_name = http_get_content_name,
.get_content_genre = http_get_content_type,
+ .stop = http_stop,
.scheme_names = scheme_names,
.streaming = 1
};
diff --git a/plugins/vorbis/vorbis.c b/plugins/vorbis/vorbis.c
index 8a32bd86..31e252eb 100644
--- a/plugins/vorbis/vorbis.c
+++ b/plugins/vorbis/vorbis.c
@@ -110,7 +110,7 @@ cvorbis_init (DB_playItem_t *it) {
cur_bit_stream = -1;
ptrack = it;
- file = deadbeef->fopen (it->fname);
+ file = plugin.info.file = deadbeef->fopen (it->fname);
if (!file) {
return -1;
}
@@ -191,6 +191,7 @@ cvorbis_init (DB_playItem_t *it) {
static void
cvorbis_free (void) {
+ plugin.info.file = NULL;
if (file) {
ptrack = NULL;
ov_clear (&vorbis_file);