MPD  0.20.6
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"
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 
43  static constexpr unsigned TAG_MODIFIED = 0x1;
44  static constexpr unsigned SYNC_WITH_PLAYER = 0x2;
45 
47 
49 
51 
53 
55 
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 
185  replay_gain_mode = mode;
187  }
188 
194 
195 #ifdef ENABLE_DATABASE
196 
201  const Database *GetDatabase() const;
202 
203  gcc_pure
204  const Database &GetDatabaseOrThrow() const;
205 
210  void DatabaseModified(const Database &db);
211 #endif
212 
217  void TagModified();
218 
222  void SyncWithPlayer();
223 
224 private:
225  /* virtual methods from class QueueListener */
226  void OnQueueModified() override;
227  void OnQueueOptionsChanged() override;
228  void OnQueueSongStarted() override;
229 
230  /* virtual methods from class PlayerListener */
231  void OnPlayerSync() override;
232  void OnPlayerTagModified() override;
233 
234  /* virtual methods from class MixerListener */
235  void OnMixerVolumeChanged(Mixer &mixer, int volume) override;
236 
237  /* callback for #global_events */
238  void OnGlobalEvent(unsigned mask);
239 };
240 
241 #endif
void SetPriorityId(unsigned song_id, uint8_t priority)
Definition: Partition.hxx:128
void SetReplayGainMode(ReplayGainMode mode)
Definition: Partition.hxx:184
ReplayGainMode
This structure describes the format of a raw PCM stream.
Definition: AudioFormat.hxx:37
void StaleSong(PlayerControl &pc, const char *uri)
Mark the given song as "stale", i.e.
void Clear(PlayerControl &pc)
void MoveId(unsigned id, int to)
Definition: Partition.hxx:110
void PlayNext(PlayerControl &pc)
Throws std::runtime_error or #Error on error.
void SetConsume(bool new_value)
unsigned AppendURI(const SongLoader &loader, const char *uri_utf8)
Definition: Partition.hxx:75
A time stamp within a song.
Definition: Chrono.hxx:31
MultipleOutputs outputs
Definition: Partition.hxx:52
void SetSingle(bool new_value)
Definition: Partition.hxx:176
Partition(Instance &_instance, unsigned max_length, unsigned buffer_chunks, unsigned buffered_before_play, AudioFormat configured_audio_format, const ReplayGainConfig &replay_gain_config)
void SwapIds(PlayerControl &pc, unsigned id1, unsigned id2)
Manage a bit mask of events that have occurred.
Definition: MaskMonitor.hxx:35
A partition of the Music Player Daemon.
Definition: Partition.hxx:42
void Stop()
Definition: Partition.hxx:132
void DeleteRange(PlayerControl &pc, unsigned start, unsigned end)
Deletes a range of songs from the playlist.
void DeletePosition(unsigned position)
Definition: Partition.hxx:80
void PlayPrevious(PlayerControl &pc)
Throws std::runtime_error or #Error on error.
void SetPriorityId(PlayerControl &pc, unsigned song_id, uint8_t priority)
void DeleteId(PlayerControl &pc, unsigned id)
void Shuffle(unsigned start, unsigned end)
Definition: Partition.hxx:102
void SetRepeat(bool new_value)
Definition: Partition.hxx:164
void SetRandom(PlayerControl &pc, bool new_value)
void PlayPrevious()
Definition: Partition.hxx:148
void OrMask(unsigned new_mask)
void MoveRange(PlayerControl &pc, unsigned start, unsigned end, int to)
void SetConsume(bool new_value)
Definition: Partition.hxx:180
void SwapIds(unsigned id1, unsigned id2)
Definition: Partition.hxx:118
void UpdateEffectiveReplayGainMode()
Publishes the effective ReplayGainMode to all subsystems.
bool GetRandom() const
Definition: Partition.hxx:168
void StaleSong(const char *uri)
Definition: Partition.hxx:98
void SyncWithPlayer()
Synchronize the player with the play queue.
void PlayId(PlayerControl &pc, int id)
Throws std::runtime_error or #Error on error.
void EmitIdle(unsigned mask)
ReplayGainMode replay_gain_mode
Definition: Partition.hxx:56
void SetRepeat(PlayerControl &pc, bool new_value)
static constexpr unsigned SYNC_WITH_PLAYER
Definition: Partition.hxx:44
void TagModified()
A tag in the play queue has been modified by the player thread.
void DeleteId(unsigned id)
Definition: Partition.hxx:84
A variant of SongTime that is based on a signed integer.
Definition: Chrono.hxx:115
An interface that listens on events from mixer plugins.
Definition: Listener.hxx:29
void SetPriorityRange(unsigned start_position, unsigned end_position, uint8_t priority)
Definition: Partition.hxx:122
void PlayNext()
Definition: Partition.hxx:144
void EmitGlobalEvent(unsigned mask)
Definition: Partition.hxx:65
void MoveId(PlayerControl &pc, unsigned id, int to)
void PlayPosition(PlayerControl &pc, int position)
Throws std::runtime_error or #Error on error.
bool GetRandom() const
Definition: Playlist.hxx:342
void SeekCurrent(PlayerControl &pc, SignedSongTime seek_time, bool relative)
Seek within the current song.
void MoveRange(unsigned start, unsigned end, int to)
Definition: Partition.hxx:106
void DeletePosition(PlayerControl &pc, unsigned position)
void SeekSongId(unsigned song_id, SongTime seek_time)
Definition: Partition.hxx:156
A utility class that loads a DetachedSong object by its URI.
Definition: SongLoader.hxx:41
void PlayPosition(int position)
Definition: Partition.hxx:136
void Stop(PlayerControl &pc)
void SwapPositions(PlayerControl &pc, unsigned song1, unsigned song2)
static constexpr unsigned TAG_MODIFIED
Definition: Partition.hxx:43
void DeleteRange(unsigned start, unsigned end)
Deletes a range of songs from the playlist.
Definition: Partition.hxx:94
Instance & instance
Definition: Partition.hxx:46
void SetRandom(bool new_value)
Definition: Partition.hxx:172
#define gcc_pure
Definition: Compiler.h:116
void SeekCurrent(SignedSongTime seek_time, bool relative)
Definition: Partition.hxx:160
void Shuffle(PlayerControl &pc, unsigned start, unsigned end)
void SeekSongPosition(PlayerControl &pc, unsigned sonag_position, SongTime seek_time)
Throws std::runtime_error or #Error on error.
MaskMonitor global_events
Definition: Partition.hxx:48
void SeekSongPosition(unsigned song_position, SongTime seek_time)
Definition: Partition.hxx:152
void ClearQueue()
Definition: Partition.hxx:71
void PlayId(int id)
Definition: Partition.hxx:140
void SwapPositions(unsigned song1, unsigned song2)
Definition: Partition.hxx:114
unsigned AppendURI(PlayerControl &pc, const SongLoader &loader, const char *uri_utf8)
Throws #std::runtime_error on error.
void SetPriorityRange(PlayerControl &pc, unsigned start_position, unsigned end_position, uint8_t priority)
PlayerControl pc
Definition: Partition.hxx:54
const Storage const char * uri
void SeekSongId(PlayerControl &pc, unsigned song_id, SongTime seek_time)
Throws std::runtime_error or #Error on error.
void SetSingle(PlayerControl &pc, bool new_value)