diff options
author | Max Kellermann <max@duempel.org> | 2013-01-29 18:56:35 +0100 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2013-01-29 18:56:35 +0100 |
commit | a8b75dc4df3bf3ba9a1554249cf6d07527184864 (patch) | |
tree | 30749b1aa56a0b8fd1f869ad96d2869b4e639b31 /src/playlist/SoundCloudPlaylistPlugin.cxx | |
parent | e4455962c640bd157713002b1d8d74fe64cecf67 (diff) | |
download | mpd-a8b75dc4df3bf3ba9a1554249cf6d07527184864.tar.gz mpd-a8b75dc4df3bf3ba9a1554249cf6d07527184864.tar.xz mpd-a8b75dc4df3bf3ba9a1554249cf6d07527184864.zip |
playlist/{asx,rss,soundcloud,xspf}: merge code to MemoryPlaylistProvider
Diffstat (limited to 'src/playlist/SoundCloudPlaylistPlugin.cxx')
-rw-r--r-- | src/playlist/SoundCloudPlaylistPlugin.cxx | 43 |
1 files changed, 4 insertions, 39 deletions
diff --git a/src/playlist/SoundCloudPlaylistPlugin.cxx b/src/playlist/SoundCloudPlaylistPlugin.cxx index eefa23dd3..b236481a0 100644 --- a/src/playlist/SoundCloudPlaylistPlugin.cxx +++ b/src/playlist/SoundCloudPlaylistPlugin.cxx @@ -19,7 +19,7 @@ #include "config.h" #include "SoundCloudPlaylistPlugin.hxx" -#include "PlaylistPlugin.hxx" +#include "MemoryPlaylistProvider.hxx" #include "conf.h" #include "input_stream.h" #include "song.h" @@ -30,12 +30,6 @@ #include <string.h> -struct soundcloud_playlist { - struct playlist_provider base; - - GSList *songs; -}; - static struct { char *apikey; } soundcloud_config; @@ -326,8 +320,6 @@ soundcloud_parse_json(const char *url, yajl_handle hand, static struct playlist_provider * soundcloud_open_uri(const char *uri, Mutex &mutex, Cond &cond) { - struct soundcloud_playlist *playlist = NULL; - char *s, *p; char *scheme, *arg, *rest; s = g_strdup(uri); @@ -399,34 +391,7 @@ soundcloud_open_uri(const char *uri, Mutex &mutex, Cond &cond) if (ret == -1) return NULL; - playlist = g_new(struct soundcloud_playlist, 1); - playlist_provider_init(&playlist->base, &soundcloud_playlist_plugin); - playlist->songs = g_slist_reverse(data.songs); - - return &playlist->base; -} - -static void -soundcloud_close(struct playlist_provider *_playlist) -{ - struct soundcloud_playlist *playlist = (struct soundcloud_playlist *)_playlist; - - g_free(playlist); -} - - -static struct song * -soundcloud_read(struct playlist_provider *_playlist) -{ - struct soundcloud_playlist *playlist = (struct soundcloud_playlist *)_playlist; - - if (playlist->songs == NULL) - return NULL; - - struct song* s; - s = (struct song *)playlist->songs->data; - playlist->songs = g_slist_remove(playlist->songs, s); - return s; + return new MemoryPlaylistProvider(g_slist_reverse(data.songs)); } static const char *const soundcloud_schemes[] = { @@ -441,8 +406,8 @@ const struct playlist_plugin soundcloud_playlist_plugin = { soundcloud_finish, soundcloud_open_uri, nullptr, - soundcloud_close, - soundcloud_read, + nullptr, + nullptr, soundcloud_schemes, nullptr, |