From e202b407ec18570ad54a04c64341f654b447fb31 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Sun, 6 Jan 2013 14:55:35 +0100 Subject: Playlist: add constructor and destructor --- src/Partition.hxx | 8 ++------ src/Playlist.cxx | 15 --------------- src/Playlist.hxx | 15 +++++++++------ 3 files changed, 11 insertions(+), 27 deletions(-) (limited to 'src') diff --git a/src/Partition.hxx b/src/Partition.hxx index b91a4b6f9..a3b9e4625 100644 --- a/src/Partition.hxx +++ b/src/Partition.hxx @@ -35,12 +35,8 @@ struct Partition { Partition(unsigned max_length, unsigned buffer_chunks, unsigned buffered_before_play) - :pc(buffer_chunks, buffered_before_play) { - playlist_init(&playlist, max_length); - } - - ~Partition() { - playlist_finish(&playlist); + :playlist(max_length), + pc(buffer_chunks, buffered_before_play) { } }; diff --git a/src/Playlist.cxx b/src/Playlist.cxx index f89a7e31a..bb3daba8d 100644 --- a/src/Playlist.cxx +++ b/src/Playlist.cxx @@ -52,21 +52,6 @@ playlist_tag_changed(struct playlist *playlist) idle_add(IDLE_PLAYLIST); } -void -playlist_init(struct playlist *playlist, unsigned max_length) -{ - queue_init(&playlist->queue, max_length); - - playlist->queued = -1; - playlist->current = -1; -} - -void -playlist_finish(struct playlist *playlist) -{ - queue_finish(&playlist->queue); -} - /** * Queue a song, addressed by its order number. */ diff --git a/src/Playlist.hxx b/src/Playlist.hxx index 163d17afe..b158d0464 100644 --- a/src/Playlist.hxx +++ b/src/Playlist.hxx @@ -68,16 +68,19 @@ struct playlist { * This variable is only valid if #playing is true. */ int queued; -}; -void -playlist_global_init(); + playlist(unsigned max_length) + :current(-1), queued(-1) { + queue_init(&queue, max_length); + } -void -playlist_init(struct playlist *playlist, unsigned max_length); + ~playlist() { + queue_finish(&queue); + } +}; void -playlist_finish(struct playlist *playlist); +playlist_global_init(); void playlist_tag_changed(struct playlist *playlist); -- cgit v1.2.3