playlist/cue: add constructor/destructor

This commit is contained in:
Max Kellermann 2013-04-09 00:34:48 +02:00
parent 6728b8c1a3
commit 3cc7be0fa6
1 changed files with 13 additions and 11 deletions

View File

@ -42,18 +42,23 @@ struct CuePlaylist {
struct input_stream *is;
struct text_input_stream *tis;
struct cue_parser *parser;
CuePlaylist(struct input_stream *_is)
:is(_is), tis(text_input_stream_new(is)),
parser(cue_parser_new()) {
playlist_provider_init(&base, &cue_playlist_plugin);
}
~CuePlaylist() {
cue_parser_free(parser);
text_input_stream_free(tis);
}
};
static struct playlist_provider *
cue_playlist_open_stream(struct input_stream *is)
{
CuePlaylist *playlist = g_new(CuePlaylist, 1);
playlist_provider_init(&playlist->base, &cue_playlist_plugin);
playlist->is = is;
playlist->tis = text_input_stream_new(is);
playlist->parser = cue_parser_new();
CuePlaylist *playlist = new CuePlaylist(is);
return &playlist->base;
}
@ -61,10 +66,7 @@ static void
cue_playlist_close(struct playlist_provider *_playlist)
{
CuePlaylist *playlist = (CuePlaylist *)_playlist;
cue_parser_free(playlist->parser);
text_input_stream_free(playlist->tis);
g_free(playlist);
delete playlist;
}
static struct song *