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/lastfm_playlist_plugin.c | |
parent | d000d31355c824a076324b647a3f056aab9ddabe (diff) | |
download | mpd-228b03edf8513aa1cdaf4e4647279cc580245555.tar.gz mpd-228b03edf8513aa1cdaf4e4647279cc580245555.tar.xz mpd-228b03edf8513aa1cdaf4e4647279cc580245555.zip |
input_stream: return errors with GError
Diffstat (limited to 'src/playlist/lastfm_playlist_plugin.c')
-rw-r--r-- | src/playlist/lastfm_playlist_plugin.c | 36 |
1 files changed, 29 insertions, 7 deletions
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; } |