aboutsummaryrefslogtreecommitdiff
path: root/src/Partition.hxx
blob: 776f74e2ad52ce8892f495b6fdb7c721a1832539 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
/*
 * Copyright (C) 2003-2013 The Music Player Daemon Project
 * http://www.musicpd.org
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License along
 * with this program; if not, write to the Free Software Foundation, Inc.,
 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 */

#ifndef MPD_PARTITION_HXX
#define MPD_PARTITION_HXX

#include "Playlist.hxx"
#include "PlayerControl.hxx"

/**
 * A partition of the Music Player Daemon.  It is a separate unit with
 * a playlist, a player, outputs etc.
 */
struct Partition {
	struct playlist playlist;

	player_control pc;

	Partition(unsigned max_length,
		  unsigned buffer_chunks,
		  unsigned buffered_before_play)
		:playlist(max_length),
		 pc(buffer_chunks, buffered_before_play) {
	}

	void ClearQueue() {
		playlist.Clear(pc);
	}

	enum playlist_result AppendFile(const char *path_utf8,
					unsigned *added_id=nullptr) {
		return playlist.AppendFile(pc, path_utf8, added_id);
	}

	enum playlist_result AppendURI(const char *uri_utf8,
				       unsigned *added_id=nullptr) {
		return playlist.AppendURI(pc, uri_utf8, added_id);
	}

	enum playlist_result DeletePosition(unsigned position) {
		return playlist.DeletePosition(pc, position);
	}

	enum playlist_result DeleteId(unsigned id) {
		return playlist.DeleteId(pc, id);
	}

	/**
	 * Deletes a range of songs from the playlist.
	 *
	 * @param start the position of the first song to delete
	 * @param end the position after the last song to delete
	 */
	enum playlist_result DeleteRange(unsigned start, unsigned end) {
		return playlist.DeleteRange(pc, start, end);
	}

	void DeleteSong(const song &song) {
		playlist.DeleteSong(pc, song);
	}

	void Shuffle(unsigned start, unsigned end) {
		playlist.Shuffle(pc, start, end);
	}

	enum playlist_result MoveRange(unsigned start, unsigned end, int to) {
		return playlist.MoveRange(pc, start, end, to);
	}

	enum playlist_result MoveId(unsigned id, int to) {
		return playlist.MoveId(pc, id, to);
	}

	enum playlist_result SwapPositions(unsigned song1, unsigned song2) {
		return playlist.SwapPositions(pc, song1, song2);
	}

	enum playlist_result SwapIds(unsigned id1, unsigned id2) {
		return playlist.SwapIds(pc, id1, id2);
	}

	enum playlist_result SetPriorityRange(unsigned start_position,
					      unsigned end_position,
					      uint8_t priority) {
		return playlist.SetPriorityRange(pc,
						 start_position, end_position,
						 priority);
	}

	enum playlist_result SetPriorityId(unsigned song_id,
					   uint8_t priority) {
		return playlist.SetPriorityId(pc, song_id, priority);
	}

	void Stop() {
		playlist.Stop(pc);
	}

	enum playlist_result PlayPosition(int position) {
		return playlist.PlayPosition(pc, position);
	}

	enum playlist_result PlayId(int id) {
		return playlist.PlayId(pc, id);
	}

	void PlayNext() {
		return playlist.PlayNext(pc);
	}

	void PlayPrevious() {
		return playlist.PlayPrevious(pc);
	}

	enum playlist_result SeekSongPosition(unsigned song_position,
					      float seek_time) {
		return playlist.SeekSongPosition(pc, song_position, seek_time);
	}

	enum playlist_result SeekSongId(unsigned song_id, float seek_time) {
		return playlist.SeekSongId(pc, song_id, seek_time);
	}

	enum playlist_result SeekCurrent(float seek_time, bool relative) {
		return playlist.SeekCurrent(pc, seek_time, relative);
	}

	void SetRepeat(bool new_value) {
		playlist.SetRepeat(pc, new_value);
	}

	bool GetRandom() const {
		return playlist.GetRandom();
	}

	void SetRandom(bool new_value) {
		playlist.SetRandom(pc, new_value);
	}

	void SetSingle(bool new_value) {
		playlist.SetSingle(pc, new_value);
	}

	void SetConsume(bool new_value) {
		playlist.SetConsume(new_value);
	}
};

#endif