Playlist: add constructor and destructor
This commit is contained in:
		| @@ -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) | |||||||
| 	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,17 +68,20 @@ struct playlist { | |||||||
| 	 * This variable is only valid if #playing is true. | 	 * This variable is only valid if #playing is true. | ||||||
| 	 */ | 	 */ | ||||||
| 	int queued; | 	int queued; | ||||||
|  |  | ||||||
|  | 	playlist(unsigned max_length) | ||||||
|  | 		:current(-1), queued(-1) { | ||||||
|  | 		queue_init(&queue, max_length); | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	~playlist() { | ||||||
|  | 		queue_finish(&queue); | ||||||
|  | 	} | ||||||
| }; | }; | ||||||
|  |  | ||||||
| void | void | ||||||
| playlist_global_init(); | playlist_global_init(); | ||||||
|  |  | ||||||
| void |  | ||||||
| playlist_init(struct playlist *playlist, unsigned max_length); |  | ||||||
|  |  | ||||||
| void |  | ||||||
| playlist_finish(struct playlist *playlist); |  | ||||||
|  |  | ||||||
| void | void | ||||||
| playlist_tag_changed(struct playlist *playlist); | playlist_tag_changed(struct playlist *playlist); | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Max Kellermann
					Max Kellermann