playlist/lastfm: convert to class
This commit is contained in:
@@ -30,12 +30,22 @@
|
|||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
struct lastfm_playlist {
|
struct LastfmPlaylist {
|
||||||
struct playlist_provider base;
|
struct playlist_provider base;
|
||||||
|
|
||||||
struct input_stream *is;
|
struct input_stream *is;
|
||||||
|
|
||||||
struct playlist_provider *xspf;
|
struct playlist_provider *xspf;
|
||||||
|
|
||||||
|
LastfmPlaylist(input_stream *_is, playlist_provider *_xspf)
|
||||||
|
:is(_is), xspf(_xspf) {
|
||||||
|
playlist_provider_init(&base, &lastfm_playlist_plugin);
|
||||||
|
}
|
||||||
|
|
||||||
|
~LastfmPlaylist() {
|
||||||
|
playlist_plugin_close(xspf);
|
||||||
|
input_stream_close(is);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
static struct {
|
static struct {
|
||||||
@@ -249,28 +259,22 @@ lastfm_open_uri(const char *uri, Mutex &mutex, Cond &cond)
|
|||||||
|
|
||||||
/* create the playlist object */
|
/* create the playlist object */
|
||||||
|
|
||||||
const auto playlist = g_new(struct lastfm_playlist, 1);
|
const auto playlist = new LastfmPlaylist(is, xspf);
|
||||||
playlist_provider_init(&playlist->base, &lastfm_playlist_plugin);
|
|
||||||
playlist->is = is;
|
|
||||||
playlist->xspf = xspf;
|
|
||||||
|
|
||||||
return &playlist->base;
|
return &playlist->base;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
lastfm_close(struct playlist_provider *_playlist)
|
lastfm_close(struct playlist_provider *_playlist)
|
||||||
{
|
{
|
||||||
struct lastfm_playlist *playlist = (struct lastfm_playlist *)_playlist;
|
LastfmPlaylist *playlist = (LastfmPlaylist *)_playlist;
|
||||||
|
|
||||||
playlist_plugin_close(playlist->xspf);
|
delete playlist;
|
||||||
input_stream_close(playlist->is);
|
|
||||||
g_free(playlist);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static Song *
|
static Song *
|
||||||
lastfm_read(struct playlist_provider *_playlist)
|
lastfm_read(struct playlist_provider *_playlist)
|
||||||
{
|
{
|
||||||
struct lastfm_playlist *playlist = (struct lastfm_playlist *)_playlist;
|
LastfmPlaylist *playlist = (LastfmPlaylist *)_playlist;
|
||||||
|
|
||||||
return playlist_plugin_read(playlist->xspf);
|
return playlist_plugin_read(playlist->xspf);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user