Commit e202b407 authored by Max Kellermann's avatar Max Kellermann

Playlist: add constructor and destructor

parent 2cc89e60
...@@ -35,12 +35,8 @@ struct Partition { ...@@ -35,12 +35,8 @@ struct Partition {
Partition(unsigned max_length, Partition(unsigned max_length,
unsigned buffer_chunks, unsigned buffer_chunks,
unsigned buffered_before_play) unsigned buffered_before_play)
:pc(buffer_chunks, buffered_before_play) { :playlist(max_length),
playlist_init(&playlist, max_length); pc(buffer_chunks, buffered_before_play) {
}
~Partition() {
playlist_finish(&playlist);
} }
}; };
......
...@@ -52,21 +52,6 @@ playlist_tag_changed(struct playlist *playlist) ...@@ -52,21 +52,6 @@ playlist_tag_changed(struct playlist *playlist)
idle_add(IDLE_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. * Queue a song, addressed by its order number.
*/ */
......
...@@ -68,16 +68,19 @@ struct playlist { ...@@ -68,16 +68,19 @@ struct playlist {
* This variable is only valid if #playing is true. * This variable is only valid if #playing is true.
*/ */
int queued; int queued;
};
void playlist(unsigned max_length)
playlist_global_init(); :current(-1), queued(-1) {
queue_init(&queue, max_length);
}
void ~playlist() {
playlist_init(struct playlist *playlist, unsigned max_length); queue_finish(&queue);
}
};
void void
playlist_finish(struct playlist *playlist); playlist_global_init();
void void
playlist_tag_changed(struct playlist *playlist); playlist_tag_changed(struct playlist *playlist);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment