diff options
author | Max Kellermann <max@duempel.org> | 2009-11-14 23:53:04 +0100 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2009-12-15 23:12:11 +0100 |
commit | 228b03edf8513aa1cdaf4e4647279cc580245555 (patch) | |
tree | 7f5b03a9727fb8c371885469296eb7f49f6fa68b /src/playlist | |
parent | d000d31355c824a076324b647a3f056aab9ddabe (diff) | |
download | mpd-228b03edf8513aa1cdaf4e4647279cc580245555.tar.gz mpd-228b03edf8513aa1cdaf4e4647279cc580245555.tar.xz mpd-228b03edf8513aa1cdaf4e4647279cc580245555.zip |
input_stream: return errors with GError
Diffstat (limited to '')
-rw-r--r-- | src/playlist/asx_playlist_plugin.c | 12 | ||||
-rw-r--r-- | src/playlist/lastfm_playlist_plugin.c | 36 | ||||
-rw-r--r-- | src/playlist/pls_playlist_plugin.c | 13 | ||||
-rw-r--r-- | src/playlist/xspf_playlist_plugin.c | 12 | ||||
-rw-r--r-- | src/playlist_list.c | 17 | ||||
-rw-r--r-- | src/playlist_queue.c | 12 |
6 files changed, 83 insertions, 19 deletions
diff --git a/src/playlist/asx_playlist_plugin.c b/src/playlist/asx_playlist_plugin.c index 901212f90..03a5edea6 100644 --- a/src/playlist/asx_playlist_plugin.c +++ b/src/playlist/asx_playlist_plugin.c @@ -233,9 +233,17 @@ asx_open_stream(struct input_stream *is) &parser, asx_parser_destroy); while (true) { - nbytes = input_stream_read(is, buffer, sizeof(buffer)); - if (nbytes == 0) + nbytes = input_stream_read(is, buffer, sizeof(buffer), &error); + if (nbytes == 0) { + if (error != NULL) { + g_markup_parse_context_free(context); + g_warning("%s", error->message); + g_error_free(error); + return NULL; + } + break; + } success = g_markup_parse_context_parse(context, buffer, nbytes, &error); diff --git a/src/playlist/lastfm_playlist_plugin.c b/src/playlist/lastfm_playlist_plugin.c index c776d25ab..ec499925a 100644 --- a/src/playlist/lastfm_playlist_plugin.c +++ b/src/playlist/lastfm_playlist_plugin.c @@ -86,27 +86,41 @@ static char * lastfm_get(const char *url) { struct input_stream input_stream; + GError *error = NULL; bool success; int ret; char buffer[4096]; size_t length = 0, nbytes; - success = input_stream_open(&input_stream, url); - if (!success) + success = input_stream_open(&input_stream, url, &error); + if (!success) { + if (error != NULL) { + g_warning("%s", error->message); + g_error_free(error); + } + return NULL; + } while (!input_stream.ready) { - ret = input_stream_buffer(&input_stream); + ret = input_stream_buffer(&input_stream, &error); if (ret < 0) { input_stream_close(&input_stream); + g_warning("%s", error->message); + g_error_free(error); return NULL; } } do { nbytes = input_stream_read(&input_stream, buffer + length, - sizeof(buffer) - length); + sizeof(buffer) - length, &error); if (nbytes == 0) { + if (error != NULL) { + g_warning("%s", error->message); + g_error_free(error); + } + if (input_stream_eof(&input_stream)) break; @@ -152,6 +166,7 @@ static struct playlist_provider * lastfm_open_uri(const char *uri) { struct lastfm_playlist *playlist; + GError *error = NULL; char *p, *q, *response, *session; bool success; @@ -216,20 +231,27 @@ lastfm_open_uri(const char *uri) NULL); g_free(session); - success = input_stream_open(&playlist->is, p); + success = input_stream_open(&playlist->is, p, &error); g_free(p); if (!success) { - g_warning("Failed to load XSPF playlist"); + if (error != NULL) { + g_warning("Failed to load XSPF playlist: %s", + error->message); + g_error_free(error); + } else + g_warning("Failed to load XSPF playlist"); g_free(playlist); return NULL; } while (!playlist->is.ready) { - int ret = input_stream_buffer(&playlist->is); + int ret = input_stream_buffer(&playlist->is, &error); if (ret < 0) { input_stream_close(&playlist->is); g_free(playlist); + g_warning("%s", error->message); + g_error_free(error); return NULL; } diff --git a/src/playlist/pls_playlist_plugin.c b/src/playlist/pls_playlist_plugin.c index 5308b7160..30c62b76e 100644 --- a/src/playlist/pls_playlist_plugin.c +++ b/src/playlist/pls_playlist_plugin.c @@ -115,9 +115,18 @@ pls_open_stream(struct input_stream *is) GString *kf_data = g_string_new(""); do { - nbytes = input_stream_read(is, buffer, sizeof(buffer)); - if(nbytes ==0) + nbytes = input_stream_read(is, buffer, sizeof(buffer), &error); + if (nbytes == 0) { + if (error != NULL) { + g_string_free(kf_data, TRUE); + g_warning("%s", error->message); + g_error_free(error); + return NULL; + } + break; + } + kf_data = g_string_append_len(kf_data, buffer,nbytes); /* Limit to 64k */ } while(kf_data->len < 65536); diff --git a/src/playlist/xspf_playlist_plugin.c b/src/playlist/xspf_playlist_plugin.c index 687765b3a..a36463500 100644 --- a/src/playlist/xspf_playlist_plugin.c +++ b/src/playlist/xspf_playlist_plugin.c @@ -253,9 +253,17 @@ xspf_open_stream(struct input_stream *is) &parser, xspf_parser_destroy); while (true) { - nbytes = input_stream_read(is, buffer, sizeof(buffer)); - if (nbytes == 0) + nbytes = input_stream_read(is, buffer, sizeof(buffer), &error); + if (nbytes == 0) { + if (error != NULL) { + g_markup_parse_context_free(context); + g_warning("%s", error->message); + g_error_free(error); + return NULL; + } + break; + } success = g_markup_parse_context_parse(context, buffer, nbytes, &error); diff --git a/src/playlist_list.c b/src/playlist_list.c index 2ea174a2f..1ac4d4358 100644 --- a/src/playlist_list.c +++ b/src/playlist_list.c @@ -159,7 +159,7 @@ playlist_list_open_stream_mime(struct input_stream *is) string_array_contains(plugin->mime_types, is->mime)) { /* rewind the stream, so each plugin gets a fresh start */ - input_stream_seek(is, 0, SEEK_SET); + input_stream_seek(is, 0, SEEK_SET, NULL); playlist = playlist_plugin_open_stream(plugin, is); if (playlist != NULL) @@ -185,7 +185,7 @@ playlist_list_open_stream_suffix(struct input_stream *is, const char *suffix) string_array_contains(plugin->suffixes, suffix)) { /* rewind the stream, so each plugin gets a fresh start */ - input_stream_seek(is, 0, SEEK_SET); + input_stream_seek(is, 0, SEEK_SET, NULL); playlist = playlist_plugin_open_stream(plugin, is); if (playlist != NULL) @@ -237,16 +237,25 @@ playlist_suffix_supported(const char *suffix) struct playlist_provider * playlist_list_open_path(struct input_stream *is, const char *path_fs) { + GError *error = NULL; const char *suffix; struct playlist_provider *playlist; assert(path_fs != NULL); suffix = uri_get_suffix(path_fs); - if (suffix == NULL || !playlist_suffix_supported(suffix) || - !input_stream_open(is, path_fs)) + if (suffix == NULL || !playlist_suffix_supported(suffix)) return NULL; + if (!input_stream_open(is, path_fs, &error)) { + if (error != NULL) { + g_warning("%s", error->message); + g_error_free(error); + } + + return NULL; + } + playlist = playlist_list_open_stream_suffix(is, suffix); if (playlist == NULL) input_stream_close(is); diff --git a/src/playlist_queue.c b/src/playlist_queue.c index 0b4231f59..5b4439bbb 100644 --- a/src/playlist_queue.c +++ b/src/playlist_queue.c @@ -65,6 +65,7 @@ playlist_load_into_queue(struct playlist_provider *source, static enum playlist_result playlist_open_remote_into_queue(const char *uri, struct playlist *dest) { + GError *error = NULL; struct playlist_provider *playlist; bool stream = false; struct input_stream is; @@ -74,9 +75,16 @@ playlist_open_remote_into_queue(const char *uri, struct playlist *dest) playlist = playlist_list_open_uri(uri); if (playlist == NULL) { - stream = input_stream_open(&is, uri); - if (!stream) + stream = input_stream_open(&is, uri, &error); + if (!stream) { + if (error != NULL) { + g_warning("Failed to open %s: %s", + uri, error->message); + g_error_free(error); + } + return PLAYLIST_RESULT_NO_SUCH_LIST; + } playlist = playlist_list_open_stream(&is, uri); if (playlist == NULL) { |