From a8b75dc4df3bf3ba9a1554249cf6d07527184864 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Tue, 29 Jan 2013 18:56:35 +0100 Subject: playlist/{asx,rss,soundcloud,xspf}: merge code to MemoryPlaylistProvider --- src/playlist/SoundCloudPlaylistPlugin.cxx | 43 +++---------------------------- 1 file changed, 4 insertions(+), 39 deletions(-) (limited to 'src/playlist/SoundCloudPlaylistPlugin.cxx') 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 -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, -- cgit v1.2.3