2013-01-04 22:42:05 +01:00
|
|
|
/*
|
2014-01-13 22:30:36 +01:00
|
|
|
* Copyright (C) 2003-2014 The Music Player Daemon Project
|
2013-01-04 22:42:05 +01:00
|
|
|
* 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"
|
2014-01-27 08:20:25 +01:00
|
|
|
#include "output/MultipleOutputs.hxx"
|
2013-01-04 22:42:05 +01:00
|
|
|
#include "PlayerControl.hxx"
|
|
|
|
|
2013-04-17 22:58:33 +02:00
|
|
|
struct Instance;
|
2014-01-27 08:20:25 +01:00
|
|
|
class MultipleOutputs;
|
2013-04-17 22:58:33 +02:00
|
|
|
|
2013-01-04 22:42:05 +01:00
|
|
|
/**
|
|
|
|
* A partition of the Music Player Daemon. It is a separate unit with
|
|
|
|
* a playlist, a player, outputs etc.
|
|
|
|
*/
|
|
|
|
struct Partition {
|
2013-04-17 22:58:33 +02:00
|
|
|
Instance &instance;
|
|
|
|
|
2013-01-04 22:42:05 +01:00
|
|
|
struct playlist playlist;
|
|
|
|
|
2014-01-27 08:20:25 +01:00
|
|
|
MultipleOutputs outputs;
|
|
|
|
|
2013-10-28 10:12:21 +01:00
|
|
|
PlayerControl pc;
|
2013-01-04 22:42:05 +01:00
|
|
|
|
2013-04-17 22:58:33 +02:00
|
|
|
Partition(Instance &_instance,
|
|
|
|
unsigned max_length,
|
2013-01-04 22:42:05 +01:00
|
|
|
unsigned buffer_chunks,
|
|
|
|
unsigned buffered_before_play)
|
2013-04-17 22:58:33 +02:00
|
|
|
:instance(_instance), playlist(max_length),
|
2014-01-27 08:20:25 +01:00
|
|
|
pc(outputs, buffer_chunks, buffered_before_play) {}
|
2013-01-07 10:55:05 +01:00
|
|
|
|
|
|
|
void ClearQueue() {
|
|
|
|
playlist.Clear(pc);
|
|
|
|
}
|
|
|
|
|
2013-10-19 19:50:54 +02:00
|
|
|
PlaylistResult AppendFile(const char *path_utf8,
|
|
|
|
unsigned *added_id=nullptr) {
|
2013-01-18 15:33:34 +01:00
|
|
|
return playlist.AppendFile(pc, path_utf8, added_id);
|
2013-01-07 10:55:05 +01:00
|
|
|
}
|
|
|
|
|
2013-10-19 19:50:54 +02:00
|
|
|
PlaylistResult AppendURI(const char *uri_utf8,
|
|
|
|
unsigned *added_id=nullptr) {
|
2013-01-07 10:55:05 +01:00
|
|
|
return playlist.AppendURI(pc, uri_utf8, added_id);
|
|
|
|
}
|
|
|
|
|
2013-10-19 19:50:54 +02:00
|
|
|
PlaylistResult DeletePosition(unsigned position) {
|
2013-01-07 10:55:05 +01:00
|
|
|
return playlist.DeletePosition(pc, position);
|
|
|
|
}
|
|
|
|
|
2013-10-19 19:50:54 +02:00
|
|
|
PlaylistResult DeleteId(unsigned id) {
|
2013-01-07 10:55:05 +01:00
|
|
|
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
|
|
|
|
*/
|
2013-10-19 19:50:54 +02:00
|
|
|
PlaylistResult DeleteRange(unsigned start, unsigned end) {
|
2013-01-07 10:55:05 +01:00
|
|
|
return playlist.DeleteRange(pc, start, end);
|
|
|
|
}
|
|
|
|
|
2014-01-30 20:29:48 +01:00
|
|
|
#ifdef ENABLE_DATABASE
|
|
|
|
|
2014-01-07 21:39:47 +01:00
|
|
|
void DeleteSong(const char *uri) {
|
|
|
|
playlist.DeleteSong(pc, uri);
|
2013-01-07 10:55:05 +01:00
|
|
|
}
|
|
|
|
|
2014-01-30 20:29:48 +01:00
|
|
|
#endif
|
|
|
|
|
2013-01-07 10:55:05 +01:00
|
|
|
void Shuffle(unsigned start, unsigned end) {
|
|
|
|
playlist.Shuffle(pc, start, end);
|
|
|
|
}
|
|
|
|
|
2013-10-19 19:50:54 +02:00
|
|
|
PlaylistResult MoveRange(unsigned start, unsigned end, int to) {
|
2013-01-07 10:55:05 +01:00
|
|
|
return playlist.MoveRange(pc, start, end, to);
|
|
|
|
}
|
|
|
|
|
2013-10-19 19:50:54 +02:00
|
|
|
PlaylistResult MoveId(unsigned id, int to) {
|
2013-01-07 10:55:05 +01:00
|
|
|
return playlist.MoveId(pc, id, to);
|
|
|
|
}
|
|
|
|
|
2013-10-19 19:50:54 +02:00
|
|
|
PlaylistResult SwapPositions(unsigned song1, unsigned song2) {
|
2013-01-07 10:55:05 +01:00
|
|
|
return playlist.SwapPositions(pc, song1, song2);
|
|
|
|
}
|
|
|
|
|
2013-10-19 19:50:54 +02:00
|
|
|
PlaylistResult SwapIds(unsigned id1, unsigned id2) {
|
2013-01-07 10:55:05 +01:00
|
|
|
return playlist.SwapIds(pc, id1, id2);
|
|
|
|
}
|
|
|
|
|
2013-10-19 19:50:54 +02:00
|
|
|
PlaylistResult SetPriorityRange(unsigned start_position,
|
|
|
|
unsigned end_position,
|
|
|
|
uint8_t priority) {
|
2013-01-07 10:55:05 +01:00
|
|
|
return playlist.SetPriorityRange(pc,
|
|
|
|
start_position, end_position,
|
|
|
|
priority);
|
|
|
|
}
|
|
|
|
|
2013-10-19 19:50:54 +02:00
|
|
|
PlaylistResult SetPriorityId(unsigned song_id,
|
|
|
|
uint8_t priority) {
|
2013-01-07 10:55:05 +01:00
|
|
|
return playlist.SetPriorityId(pc, song_id, priority);
|
|
|
|
}
|
|
|
|
|
|
|
|
void Stop() {
|
|
|
|
playlist.Stop(pc);
|
|
|
|
}
|
|
|
|
|
2013-10-19 19:50:54 +02:00
|
|
|
PlaylistResult PlayPosition(int position) {
|
2013-01-07 10:55:05 +01:00
|
|
|
return playlist.PlayPosition(pc, position);
|
|
|
|
}
|
|
|
|
|
2013-10-19 19:50:54 +02:00
|
|
|
PlaylistResult PlayId(int id) {
|
2013-01-07 10:55:05 +01:00
|
|
|
return playlist.PlayId(pc, id);
|
|
|
|
}
|
|
|
|
|
|
|
|
void PlayNext() {
|
|
|
|
return playlist.PlayNext(pc);
|
|
|
|
}
|
|
|
|
|
|
|
|
void PlayPrevious() {
|
|
|
|
return playlist.PlayPrevious(pc);
|
|
|
|
}
|
|
|
|
|
2013-10-19 19:50:54 +02:00
|
|
|
PlaylistResult SeekSongPosition(unsigned song_position,
|
|
|
|
float seek_time) {
|
2013-01-07 10:55:05 +01:00
|
|
|
return playlist.SeekSongPosition(pc, song_position, seek_time);
|
|
|
|
}
|
|
|
|
|
2013-10-19 19:50:54 +02:00
|
|
|
PlaylistResult SeekSongId(unsigned song_id, float seek_time) {
|
2013-01-07 10:55:05 +01:00
|
|
|
return playlist.SeekSongId(pc, song_id, seek_time);
|
|
|
|
}
|
|
|
|
|
2013-10-19 19:50:54 +02:00
|
|
|
PlaylistResult SeekCurrent(float seek_time, bool relative) {
|
2013-01-07 10:55:05 +01:00
|
|
|
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);
|
|
|
|
}
|
2013-10-21 23:40:52 +02:00
|
|
|
|
2014-02-01 00:44:41 +01:00
|
|
|
#ifdef ENABLE_DATABASE
|
2013-10-22 00:26:20 +02:00
|
|
|
/**
|
|
|
|
* The database has been modified. Propagate the change to
|
|
|
|
* all subsystems.
|
|
|
|
*/
|
|
|
|
void DatabaseModified();
|
2014-02-01 00:44:41 +01:00
|
|
|
#endif
|
2013-10-22 00:26:20 +02:00
|
|
|
|
2013-10-21 23:40:52 +02:00
|
|
|
/**
|
2013-10-21 23:22:16 +02:00
|
|
|
* A tag in the play queue has been modified by the player
|
|
|
|
* thread. Propagate the change to all subsystems.
|
2013-10-21 23:40:52 +02:00
|
|
|
*/
|
|
|
|
void TagModified();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Synchronize the player with the play queue.
|
|
|
|
*/
|
|
|
|
void SyncWithPlayer();
|
2013-01-04 22:42:05 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|