aboutsummaryrefslogtreecommitdiffstats
path: root/src/playlist/LastFMPlaylistPlugin.cxx
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2013-09-05 09:37:54 +0200
committerMax Kellermann <max@duempel.org>2013-09-05 09:40:55 +0200
commit8929f88e6d78d538d943e80b66fcf21706e53974 (patch)
tree01232fd55f40dfa1cded59cb28a79b257ebb19e4 /src/playlist/LastFMPlaylistPlugin.cxx
parent5348808bf594de927cc64eebae9118d6971343b1 (diff)
downloadmpd-8929f88e6d78d538d943e80b66fcf21706e53974.tar.gz
mpd-8929f88e6d78d538d943e80b66fcf21706e53974.tar.xz
mpd-8929f88e6d78d538d943e80b66fcf21706e53974.zip
PlaylistPlugin: add interface SongEnumerator
Replaces struct playlist_provider.
Diffstat (limited to 'src/playlist/LastFMPlaylistPlugin.cxx')
-rw-r--r--src/playlist/LastFMPlaylistPlugin.cxx42
1 files changed, 13 insertions, 29 deletions
diff --git a/src/playlist/LastFMPlaylistPlugin.cxx b/src/playlist/LastFMPlaylistPlugin.cxx
index a727a21a4..2cc538e1e 100644
--- a/src/playlist/LastFMPlaylistPlugin.cxx
+++ b/src/playlist/LastFMPlaylistPlugin.cxx
@@ -21,6 +21,7 @@
#include "LastFMPlaylistPlugin.hxx"
#include "PlaylistPlugin.hxx"
#include "PlaylistRegistry.hxx"
+#include "SongEnumerator.hxx"
#include "ConfigData.hxx"
#include "Song.hxx"
#include "InputStream.hxx"
@@ -31,22 +32,24 @@
#include <assert.h>
#include <string.h>
-struct LastfmPlaylist {
- struct playlist_provider base;
-
+class LastfmPlaylist final : public SongEnumerator {
struct input_stream *is;
- struct playlist_provider *xspf;
+ SongEnumerator *const xspf;
- LastfmPlaylist(input_stream *_is, playlist_provider *_xspf)
+public:
+ LastfmPlaylist(input_stream *_is, SongEnumerator *_xspf)
:is(_is), xspf(_xspf) {
- playlist_provider_init(&base, &lastfm_playlist_plugin);
}
- ~LastfmPlaylist() {
- playlist_plugin_close(xspf);
+ virtual ~LastfmPlaylist() {
+ delete xspf;
is->Close();
}
+
+ virtual Song *NextSong() override {
+ return xspf->NextSong();
+ }
};
static struct {
@@ -161,7 +164,7 @@ lastfm_find(const char *response, const char *name)
}
}
-static struct playlist_provider *
+static SongEnumerator *
lastfm_open_uri(const char *uri, Mutex &mutex, Cond &cond)
{
char *p, *q, *response, *session;
@@ -256,24 +259,7 @@ lastfm_open_uri(const char *uri, Mutex &mutex, Cond &cond)
/* create the playlist object */
- const auto playlist = new LastfmPlaylist(is, xspf);
- return &playlist->base;
-}
-
-static void
-lastfm_close(struct playlist_provider *_playlist)
-{
- LastfmPlaylist *playlist = (LastfmPlaylist *)_playlist;
-
- delete playlist;
-}
-
-static Song *
-lastfm_read(struct playlist_provider *_playlist)
-{
- LastfmPlaylist *playlist = (LastfmPlaylist *)_playlist;
-
- return playlist_plugin_read(playlist->xspf);
+ return new LastfmPlaylist(is, xspf);
}
static const char *const lastfm_schemes[] = {
@@ -288,8 +274,6 @@ const struct playlist_plugin lastfm_playlist_plugin = {
lastfm_finish,
lastfm_open_uri,
nullptr,
- lastfm_close,
- lastfm_read,
lastfm_schemes,
nullptr,