MPD: Partition.hxx Source File

MPD 0.20.18

Partition.hxx
Go to the documentation of this file.
1 /*
2 * Copyright 2003-2017 The Music Player Daemon Project
3 * http://www.musicpd.org
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 */
19
20 #ifndef MPD_PARTITION_HXX
21 #define MPD_PARTITION_HXX
22
23 #include "event/MaskMonitor.hxx"
24 #include "queue/Playlist.hxx"
25 #include "queue/Listener.hxx"
26 #include "output/MultipleOutputs.hxx"
27 #include "mixer/Listener.hxx"
28 #include "player/Control.hxx"
29 #include "player/Listener.hxx"
30 #include "ReplayGainMode.hxx"
31 #include "Chrono.hxx"
32 #include "Compiler.h"
33
34 struct Instance;
35 class MultipleOutputs;
36 class SongLoader;
37
42 struct Partition final : QueueListener, PlayerListener, MixerListener {
43 static constexpr unsigned TAG_MODIFIED = 0x1;
44 static constexpr unsigned SYNC_WITH_PLAYER = 0x2;
45
46 Instance &instance;
47
48 MaskMonitor global_events;
49
50 struct playlist playlist;
51
52 MultipleOutputs outputs;
53
54 PlayerControl pc;
55
56 ReplayGainMode replay_gain_mode = ReplayGainMode::OFF;
57
58 Partition(Instance &_instance,
59 unsigned max_length,
60 unsigned buffer_chunks,
61 unsigned buffered_before_play,
62 AudioFormat configured_audio_format,
63 const ReplayGainConfig &replay_gain_config);
64
65 void EmitGlobalEvent(unsigned mask) {
66 global_events.OrMask(mask);
67 }
68
69 void EmitIdle(unsigned mask);
70
71 void ClearQueue() {
72 playlist.Clear(pc);
73 }
74
75 unsigned AppendURI(const SongLoader &loader,
76 const char *uri_utf8) {
77 return playlist.AppendURI(pc, loader, uri_utf8);
78 }
79
80 void DeletePosition(unsigned position) {
81 playlist.DeletePosition(pc, position);
82 }
83
84 void DeleteId(unsigned id) {
85 playlist.DeleteId(pc, id);
86 }
87
94 void DeleteRange(unsigned start, unsigned end) {
95 playlist.DeleteRange(pc, start, end);
96 }
97
98 void StaleSong(const char *uri) {
99 playlist.StaleSong(pc, uri);
100 }
101
102 void Shuffle(unsigned start, unsigned end) {
103 playlist.Shuffle(pc, start, end);
104 }
105
106 void MoveRange(unsigned start, unsigned end, int to) {
107 playlist.MoveRange(pc, start, end, to);
108 }
109
110 void MoveId(unsigned id, int to) {
111 playlist.MoveId(pc, id, to);
112 }
113
114 void SwapPositions(unsigned song1, unsigned song2) {
115 playlist.SwapPositions(pc, song1, song2);
116 }
117
118 void SwapIds(unsigned id1, unsigned id2) {
119 playlist.SwapIds(pc, id1, id2);
120 }
121
122 void SetPriorityRange(unsigned start_position, unsigned end_position,
123 uint8_t priority) {
124 playlist.SetPriorityRange(pc, start_position, end_position,
125 priority);
126 }
127
128 void SetPriorityId(unsigned song_id, uint8_t priority) {
129 playlist.SetPriorityId(pc, song_id, priority);
130 }
131
132 void Stop() {
133 playlist.Stop(pc);
134 }
135
136 void PlayPosition(int position) {
137 return playlist.PlayPosition(pc, position);
138 }
139
140 void PlayId(int id) {
141 return playlist.PlayId(pc, id);
142 }
143
144 void PlayNext() {
145 return playlist.PlayNext(pc);
146 }
147
148 void PlayPrevious() {
149 return playlist.PlayPrevious(pc);
150 }
151
152 void SeekSongPosition(unsigned song_position, SongTime seek_time) {
153 playlist.SeekSongPosition(pc, song_position, seek_time);
154 }
155
156 void SeekSongId(unsigned song_id, SongTime seek_time) {
157 playlist.SeekSongId(pc, song_id, seek_time);
158 }
159
160 void SeekCurrent(SignedSongTime seek_time, bool relative) {
161 playlist.SeekCurrent(pc, seek_time, relative);
162 }
163
164 void SetRepeat(bool new_value) {
165 playlist.SetRepeat(pc, new_value);
166 }
167
168 bool GetRandom() const {
169 return playlist.GetRandom();
170 }
171
172 void SetRandom(bool new_value) {
173 playlist.SetRandom(pc, new_value);
174 }
175
176 void SetSingle(bool new_value) {
177 playlist.SetSingle(pc, new_value);
178 }
179
180 void SetConsume(bool new_value) {
181 playlist.SetConsume(new_value);
182 }
183
184 void SetReplayGainMode(ReplayGainMode mode) {
185 replay_gain_mode = mode;
186 UpdateEffectiveReplayGainMode();
187 }
188
193 void UpdateEffectiveReplayGainMode();
194
195 #ifdef ENABLE_DATABASE
196
201 const Database *GetDatabase() const;
202
203 const Database &GetDatabaseOrThrow() const;
204
209 void DatabaseModified(const Database &db);
210 #endif
211
216 void TagModified();
217
221 void SyncWithPlayer();
222
223 private:
224 /* virtual methods from class QueueListener */
225 void OnQueueModified() override;
226 void OnQueueOptionsChanged() override;
227 void OnQueueSongStarted() override;
228
229 /* virtual methods from class PlayerListener */
230 void OnPlayerSync() override;
231 void OnPlayerTagModified() override;
232
233 /* virtual methods from class MixerListener */
234 void OnMixerVolumeChanged(Mixer &mixer, int volume) override;
235
236 /* callback for #global_events */
237 void OnGlobalEvent(unsigned mask);
238 };
239
240 #endif
Partition::SetPriorityId
void SetPriorityId(unsigned song_id, uint8_t priority)
Definition: Partition.hxx:128
playlist
Definition: Playlist.hxx:34
Partition::SetReplayGainMode
void SetReplayGainMode(ReplayGainMode mode)
Definition: Partition.hxx:184
Mixer
Definition: MixerInternal.hxx:30
ReplayGainMode
ReplayGainMode
Definition: ReplayGainMode.hxx:27
AudioFormat
This structure describes the format of a raw PCM stream.
Definition: AudioFormat.hxx:37
playlist::StaleSong
void StaleSong(PlayerControl &pc, const char *uri)
Mark the given song as "stale", i.e.
ReplayGainMode.hxx
MultipleOutputs.hxx
playlist::Clear
void Clear(PlayerControl &pc)
Partition::MoveId
void MoveId(unsigned id, int to)
Definition: Partition.hxx:110
playlist::PlayNext
void PlayNext(PlayerControl &pc)
Throws std::runtime_error or #Error on error.
playlist::SetConsume
void SetConsume(bool new_value)
Chrono.hxx
Partition::AppendURI
unsigned AppendURI(const SongLoader &loader, const char *uri_utf8)
Definition: Partition.hxx:75
SongTime
A time stamp within a song.
Definition: Chrono.hxx:31
ReplayGainConfig
Definition: ReplayGainConfig.hxx:25
Partition::outputs
MultipleOutputs outputs
Definition: Partition.hxx:52
Database
Definition: Interface.hxx:35
Partition::SetSingle
void SetSingle(bool new_value)
Definition: Partition.hxx:176
Partition::Partition
Partition(Instance &_instance, unsigned max_length, unsigned buffer_chunks, unsigned buffered_before_play, AudioFormat configured_audio_format, const ReplayGainConfig &replay_gain_config)
playlist::SwapIds
void SwapIds(PlayerControl &pc, unsigned id1, unsigned id2)
MaskMonitor
Manage a bit mask of events that have occurred.
Definition: MaskMonitor.hxx:35
Partition
A partition of the Music Player Daemon.
Definition: Partition.hxx:42
Partition::Stop
void Stop()
Definition: Partition.hxx:132
playlist::DeleteRange
void DeleteRange(PlayerControl &pc, unsigned start, unsigned end)
Deletes a range of songs from the playlist.
Instance
Definition: Instance.hxx:52
Partition::DeletePosition
void DeletePosition(unsigned position)
Definition: Partition.hxx:80
playlist::PlayPrevious
void PlayPrevious(PlayerControl &pc)
Throws std::runtime_error or #Error on error.
playlist::SetPriorityId
void SetPriorityId(PlayerControl &pc, unsigned song_id, uint8_t priority)
Control.hxx
playlist::DeleteId
void DeleteId(PlayerControl &pc, unsigned id)
Partition::Shuffle
void Shuffle(unsigned start, unsigned end)
Definition: Partition.hxx:102
Partition::SetRepeat
void SetRepeat(bool new_value)
Definition: Partition.hxx:164
playlist::SetRandom
void SetRandom(PlayerControl &pc, bool new_value)
Partition::PlayPrevious
void PlayPrevious()
Definition: Partition.hxx:148
MaskMonitor::OrMask
void OrMask(unsigned new_mask)
Partition::GetRandom
bool GetRandom() const
Definition: Partition.hxx:168
playlist::MoveRange
void MoveRange(PlayerControl &pc, unsigned start, unsigned end, int to)
Partition::SetConsume
void SetConsume(bool new_value)
Definition: Partition.hxx:180
Compiler.h
Partition::SwapIds
void SwapIds(unsigned id1, unsigned id2)
Definition: Partition.hxx:118
Partition::UpdateEffectiveReplayGainMode
void UpdateEffectiveReplayGainMode()
Publishes the effective ReplayGainMode to all subsystems.
Partition::StaleSong
void StaleSong(const char *uri)
Definition: Partition.hxx:98
Partition::SyncWithPlayer
void SyncWithPlayer()
Synchronize the player with the play queue.
playlist::PlayId
void PlayId(PlayerControl &pc, int id)
Throws std::runtime_error or #Error on error.
Partition::EmitIdle
void EmitIdle(unsigned mask)
Listener.hxx
PlayerListener
Definition: Listener.hxx:23
Listener.hxx
PlayerControl
Definition: Control.hxx:100
Partition::replay_gain_mode
ReplayGainMode replay_gain_mode
Definition: Partition.hxx:56
playlist::SetRepeat
void SetRepeat(PlayerControl &pc, bool new_value)
Partition::SYNC_WITH_PLAYER
static constexpr unsigned SYNC_WITH_PLAYER
Definition: Partition.hxx:44
MultipleOutputs
Definition: MultipleOutputs.hxx:47
Partition::TagModified
void TagModified()
A tag in the play queue has been modified by the player thread.
Partition::DeleteId
void DeleteId(unsigned id)
Definition: Partition.hxx:84
SignedSongTime
A variant of SongTime that is based on a signed integer.
Definition: Chrono.hxx:115
MixerListener
An interface that listens on events from mixer plugins.
Definition: Listener.hxx:29
Partition::SetPriorityRange
void SetPriorityRange(unsigned start_position, unsigned end_position, uint8_t priority)
Definition: Partition.hxx:122
Partition::PlayNext
void PlayNext()
Definition: Partition.hxx:144
ReplayGainMode::OFF
Partition::EmitGlobalEvent
void EmitGlobalEvent(unsigned mask)
Definition: Partition.hxx:65
playlist::MoveId
void MoveId(PlayerControl &pc, unsigned id, int to)
playlist::PlayPosition
void PlayPosition(PlayerControl &pc, int position)
Throws std::runtime_error or #Error on error.
playlist::SeekCurrent
void SeekCurrent(PlayerControl &pc, SignedSongTime seek_time, bool relative)
Seek within the current song.
Partition::MoveRange
void MoveRange(unsigned start, unsigned end, int to)
Definition: Partition.hxx:106
playlist::DeletePosition
void DeletePosition(PlayerControl &pc, unsigned position)
Partition::SeekSongId
void SeekSongId(unsigned song_id, SongTime seek_time)
Definition: Partition.hxx:156
SongLoader
A utility class that loads a DetachedSong object by its URI.
Definition: SongLoader.hxx:41
playlist::GetRandom
bool GetRandom() const
Definition: Playlist.hxx:342
Listener.hxx
Partition::PlayPosition
void PlayPosition(int position)
Definition: Partition.hxx:136
playlist::Stop
void Stop(PlayerControl &pc)
playlist::SwapPositions
void SwapPositions(PlayerControl &pc, unsigned song1, unsigned song2)
Partition::TAG_MODIFIED
static constexpr unsigned TAG_MODIFIED
Definition: Partition.hxx:43
Partition::DeleteRange
void DeleteRange(unsigned start, unsigned end)
Deletes a range of songs from the playlist.
Definition: Partition.hxx:94
Partition::instance
Instance & instance
Definition: Partition.hxx:46
Partition::SetRandom
void SetRandom(bool new_value)
Definition: Partition.hxx:172
Partition::SeekCurrent
void SeekCurrent(SignedSongTime seek_time, bool relative)
Definition: Partition.hxx:160
playlist::Shuffle
void Shuffle(PlayerControl &pc, unsigned start, unsigned end)
playlist::SeekSongPosition
void SeekSongPosition(PlayerControl &pc, unsigned sonag_position, SongTime seek_time)
Throws std::runtime_error or #Error on error.
MaskMonitor.hxx
Partition::global_events
MaskMonitor global_events
Definition: Partition.hxx:48
Partition::SeekSongPosition
void SeekSongPosition(unsigned song_position, SongTime seek_time)
Definition: Partition.hxx:152
Partition::ClearQueue
void ClearQueue()
Definition: Partition.hxx:71
Partition::PlayId
void PlayId(int id)
Definition: Partition.hxx:140
Partition::SwapPositions
void SwapPositions(unsigned song1, unsigned song2)
Definition: Partition.hxx:114
playlist::AppendURI
unsigned AppendURI(PlayerControl &pc, const SongLoader &loader, const char *uri_utf8)
Throws #std::runtime_error on error.
playlist::SetPriorityRange
void SetPriorityRange(PlayerControl &pc, unsigned start_position, unsigned end_position, uint8_t priority)
Partition::pc
PlayerControl pc
Definition: Partition.hxx:54
uri
const Storage const char * uri
Definition: DatabasePlaylist.hxx:31
playlist::SeekSongId
void SeekSongId(PlayerControl &pc, unsigned song_id, SongTime seek_time)
Throws std::runtime_error or #Error on error.
QueueListener
Definition: Listener.hxx:23
playlist::SetSingle
void SetSingle(PlayerControl &pc, bool new_value)
Playlist.hxx