|
MPD
0.20.6
|
A queue of songs. More...
#include <Queue.hxx>
Data Structures | |
| struct | Item |
| One element of the queue: basically a song plus some queue specific information attached. More... | |
Public Member Functions | |
| Queue (unsigned max_length) | |
| ~Queue () | |
| Deinitializes a queue object. More... | |
| Queue (const Queue &)=delete | |
| Queue & | operator= (const Queue &)=delete |
| unsigned | GetLength () const |
| bool | IsEmpty () const |
| Determine if the queue is empty, i.e. More... | |
| bool | IsFull () const |
| Determine if the maximum number of songs has been reached. More... | |
| bool | IsValidPosition (unsigned position) const |
| Is that a valid position number? More... | |
| bool | IsValidOrder (unsigned _order) const |
| Is that a valid order number? More... | |
| int | IdToPosition (unsigned id) const |
| int | PositionToId (unsigned position) const |
| gcc_pure unsigned | OrderToPosition (unsigned _order) const |
| gcc_pure unsigned | PositionToOrder (unsigned position) const |
| gcc_pure uint8_t | GetPriorityAtPosition (unsigned position) const |
| const Item & | GetOrderItem (unsigned i) const |
| uint8_t | GetOrderPriority (unsigned i) const |
| DetachedSong & | Get (unsigned position) const |
| Returns the song at the specified position. More... | |
| DetachedSong & | GetOrder (unsigned _order) const |
| Returns the song at the specified order number. More... | |
| bool | IsNewerAtPosition (unsigned position, uint32_t _version) const |
| Is the song at the specified position newer than the specified version? More... | |
| gcc_pure int | GetNextOrder (unsigned order) const |
| Returns the order number following the specified one. More... | |
| void | IncrementVersion () |
| Increments the queue's version number. More... | |
| void | ModifyAtPosition (unsigned position) |
| Marks the specified song as "modified". More... | |
| void | ModifyAtOrder (unsigned order) |
| Marks the specified song as "modified". More... | |
| unsigned | Append (DetachedSong &&song, uint8_t priority) |
| Appends a song to the queue and returns its position. More... | |
| void | SwapPositions (unsigned position1, unsigned position2) |
| Swaps two songs, addressed by their position. More... | |
| void | SwapOrders (unsigned order1, unsigned order2) |
| Swaps two songs, addressed by their order number. More... | |
| void | MoveOrder (unsigned from_order, unsigned to_order) |
| Moves a song to a new position in the "order" list. More... | |
| void | MovePostion (unsigned from, unsigned to) |
| Moves a song to a new position. More... | |
| void | MoveRange (unsigned start, unsigned end, unsigned to) |
| Moves a range of songs to a new position. More... | |
| void | DeletePosition (unsigned position) |
| Removes a song from the playlist. More... | |
| void | Clear () |
| Removes all songs from the playlist. More... | |
| void | RestoreOrder () |
| Initializes the "order" array, and restores "normal" order. More... | |
| void | ShuffleOrderRange (unsigned start, unsigned end) |
| Shuffle the order of items in the specified range, ignoring their priorities. More... | |
| void | ShuffleOrderRangeWithPriority (unsigned start, unsigned end) |
| Shuffle the order of items in the specified range, taking their priorities into account. More... | |
| void | ShuffleOrder () |
| Shuffles the virtual order of songs, but does not move them physically. More... | |
| void | ShuffleOrderFirst (unsigned start, unsigned end) |
| void | ShuffleOrderLast (unsigned start, unsigned end) |
| Shuffles the virtual order of the last song in the specified (order) range. More... | |
| void | ShuffleRange (unsigned start, unsigned end) |
| Shuffles a (position) range in the queue. More... | |
| bool | SetPriority (unsigned position, uint8_t priority, int after_order, bool reorder=true) |
| bool | SetPriorityRange (unsigned start_position, unsigned end_position, uint8_t priority, int after_order) |
Data Fields | |
| unsigned | max_length |
| configured maximum length of the queue More... | |
| unsigned | length |
| number of songs in the queue More... | |
| uint32_t | version |
| the current version number More... | |
| Item * | items |
| all songs in "position" order More... | |
| unsigned * | order |
| map order numbers to positions More... | |
| IdTable | id_table |
| map song ids to positions More... | |
| bool | repeat |
| repeat playback when the end of the queue has been reached? More... | |
| bool | single |
| play only current song. More... | |
| bool | consume |
| remove each played files. More... | |
| bool | random |
| play back songs in random order? More... | |
| LazyRandomEngine | rand |
| random number generator for shuffle and random mode More... | |
Static Public Attributes | |
| static constexpr unsigned | HASH_MULT = 4 |
| reserve max_length * HASH_MULT elements in the id number space More... | |
A queue of songs.
This is the backend of the playlist: it contains an ordered list of songs.
Songs can be addressed in three possible ways:
|
explicit |
| Queue::~Queue | ( | ) |
Deinitializes a queue object.
It does not free the queue pointer itself.
|
delete |
| unsigned Queue::Append | ( | DetachedSong && | song, |
| uint8_t | priority | ||
| ) |
Appends a song to the queue and returns its position.
Prior to that, the caller must check if the queue is already full.
If a song is not in the database (determined by Song::IsInDatabase()), it is freed when removed from the queue.
| priority | the priority of this new queue item |
| void Queue::Clear | ( | ) |
Removes all songs from the playlist.
| void Queue::DeletePosition | ( | unsigned | position | ) |
Removes a song from the playlist.
|
inline |
| gcc_pure int Queue::GetNextOrder | ( | unsigned | order | ) | const |
Returns the order number following the specified one.
This takes end of queue and "repeat" mode into account.
|
inline |
|
inline |
|
inline |
|
inline |
| void Queue::IncrementVersion | ( | ) |
Increments the queue's version number.
This handles integer overflow well.
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
| void Queue::ModifyAtOrder | ( | unsigned | order | ) |
Marks the specified song as "modified".
Call IncrementVersion() after all modifications have been made. number.
|
inline |
Marks the specified song as "modified".
Call IncrementVersion() after all modifications have been made. number.
| void Queue::MoveOrder | ( | unsigned | from_order, |
| unsigned | to_order | ||
| ) |
Moves a song to a new position in the "order" list.
| void Queue::MovePostion | ( | unsigned | from, |
| unsigned | to | ||
| ) |
Moves a song to a new position.
| void Queue::MoveRange | ( | unsigned | start, |
| unsigned | end, | ||
| unsigned | to | ||
| ) |
Moves a range of songs to a new position.
|
inline |
|
inline |
|
inline |
| bool Queue::SetPriority | ( | unsigned | position, |
| uint8_t | priority, | ||
| int | after_order, | ||
| bool | reorder = true |
||
| ) |
| bool Queue::SetPriorityRange | ( | unsigned | start_position, |
| unsigned | end_position, | ||
| uint8_t | priority, | ||
| int | after_order | ||
| ) |
| void Queue::ShuffleOrder | ( | ) |
Shuffles the virtual order of songs, but does not move them physically.
This is used in random mode.
| void Queue::ShuffleOrderFirst | ( | unsigned | start, |
| unsigned | end | ||
| ) |
| void Queue::ShuffleOrderLast | ( | unsigned | start, |
| unsigned | end | ||
| ) |
Shuffles the virtual order of the last song in the specified (order) range.
This is used in random mode after a song has been appended by queue_append().
| void Queue::ShuffleOrderRange | ( | unsigned | start, |
| unsigned | end | ||
| ) |
Shuffle the order of items in the specified range, ignoring their priorities.
| void Queue::ShuffleOrderRangeWithPriority | ( | unsigned | start, |
| unsigned | end | ||
| ) |
Shuffle the order of items in the specified range, taking their priorities into account.
| void Queue::ShuffleRange | ( | unsigned | start, |
| unsigned | end | ||
| ) |
Shuffles a (position) range in the queue.
The songs are physically shuffled, not by using the "order" mapping.
|
inline |
| void Queue::SwapPositions | ( | unsigned | position1, |
| unsigned | position2 | ||
| ) |
Swaps two songs, addressed by their position.
|
static |
| unsigned Queue::max_length |
| LazyRandomEngine Queue::rand |
| bool Queue::repeat |
1.8.9.1