#include <glib.h>
#include <assert.h>
#include <stdbool.h>
#include <stdint.h>
Go to the source code of this file.
Data Structures | |
struct | queue_item |
One element of the queue: basically a song plus some queue specific information attached. More... | |
struct | queue |
A queue of songs. More... | |
Enumerations | |
enum | { QUEUE_HASH_MULT = 4 } |
Functions | |
static unsigned | queue_length (const struct queue *queue) |
static bool | queue_is_empty (const struct queue *queue) |
Determine if the queue is empty, i.e. | |
static bool | queue_is_full (const struct queue *queue) |
Determine if the maximum number of songs has been reached. | |
static bool | queue_valid_position (const struct queue *queue, unsigned position) |
Is that a valid position number? | |
static bool | queue_valid_order (const struct queue *queue, unsigned order) |
Is that a valid order number? | |
static int | queue_id_to_position (const struct queue *queue, unsigned id) |
static int | queue_position_to_id (const struct queue *queue, unsigned position) |
static unsigned | queue_order_to_position (const struct queue *queue, unsigned order) |
static unsigned | queue_position_to_order (const struct queue *queue, unsigned position) |
static struct song * | queue_get (const struct queue *queue, unsigned position) |
Returns the song at the specified position. | |
static struct song * | queue_get_order (const struct queue *queue, unsigned order) |
Returns the song at the specified order number. | |
static bool | queue_song_newer (const struct queue *queue, unsigned position, uint32_t version) |
Is the song at the specified position newer than the specified version? | |
void | queue_init (struct queue *queue, unsigned max_length) |
Initialize a queue object. | |
void | queue_finish (struct queue *queue) |
Deinitializes a queue object. | |
int | queue_next_order (const struct queue *queue, unsigned order) |
Returns the order number following the specified one. | |
void | queue_increment_version (struct queue *queue) |
Increments the queue's version number. | |
void | queue_modify (struct queue *queue, unsigned order) |
Marks the specified song as "modified" and increments the version number. | |
void | queue_modify_all (struct queue *queue) |
Marks all songs as "modified" and increments the version number. | |
unsigned | queue_append (struct queue *queue, struct song *song) |
Appends a song to the queue and returns its position. | |
void | queue_swap (struct queue *queue, unsigned position1, unsigned position2) |
Swaps two songs, addressed by their position. | |
static void | queue_swap_order (struct queue *queue, unsigned order1, unsigned order2) |
Swaps two songs, addressed by their order number. | |
void | queue_move (struct queue *queue, unsigned from, unsigned to) |
Moves a song to a new position. | |
void | queue_move_range (struct queue *queue, unsigned start, unsigned end, unsigned to) |
Moves a range of songs to a new position. | |
void | queue_delete (struct queue *queue, unsigned position) |
Removes a song from the playlist. | |
void | queue_clear (struct queue *queue) |
Removes all songs from the playlist. | |
static void | queue_restore_order (struct queue *queue) |
Initializes the "order" array, and restores "normal" order. | |
void | queue_shuffle_order (struct queue *queue) |
Shuffles the virtual order of songs, but does not move them physically. | |
void | queue_shuffle_order_last (struct queue *queue, unsigned start, unsigned end) |
Shuffles the virtual order of the last song in the specified (order) range. | |
void | queue_shuffle_range (struct queue *queue, unsigned start, unsigned end) |
Shuffles a (position) range in the queue. |
anonymous enum |
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_in_database()), it is freed when removed from the queue.
void queue_clear | ( | struct queue * | queue | ) |
Removes all songs from the playlist.
void queue_delete | ( | struct queue * | queue, | |
unsigned | position | |||
) |
Removes a song from the playlist.
void queue_finish | ( | struct queue * | queue | ) |
Deinitializes a queue object.
It does not free the queue pointer itself.
static int queue_id_to_position | ( | const struct queue * | queue, | |
unsigned | id | |||
) | [inline, static] |
void queue_increment_version | ( | struct queue * | queue | ) |
Increments the queue's version number.
This handles integer overflow well.
void queue_init | ( | struct queue * | queue, | |
unsigned | max_length | |||
) |
Initialize a queue object.
static bool queue_is_empty | ( | const struct queue * | queue | ) | [inline, static] |
static bool queue_is_full | ( | const struct queue * | queue | ) | [inline, static] |
static unsigned queue_length | ( | const struct queue * | queue | ) | [inline, static] |
void queue_modify | ( | struct queue * | queue, | |
unsigned | order | |||
) |
Marks the specified song as "modified" and increments the version number.
void queue_modify_all | ( | struct queue * | queue | ) |
Marks all songs as "modified" and increments the version number.
void queue_move | ( | struct queue * | queue, | |
unsigned | from, | |||
unsigned | to | |||
) |
Moves a song to a new position.
void queue_move_range | ( | struct queue * | queue, | |
unsigned | start, | |||
unsigned | end, | |||
unsigned | to | |||
) |
Moves a range of songs to a new position.
int queue_next_order | ( | const struct queue * | queue, | |
unsigned | order | |||
) |
Returns the order number following the specified one.
This takes end of queue and "repeat" mode into account.
static unsigned queue_order_to_position | ( | const struct queue * | queue, | |
unsigned | order | |||
) | [inline, static] |
static int queue_position_to_id | ( | const struct queue * | queue, | |
unsigned | position | |||
) | [inline, static] |
static unsigned queue_position_to_order | ( | const struct queue * | queue, | |
unsigned | position | |||
) | [inline, static] |
static void queue_restore_order | ( | struct queue * | queue | ) | [inline, static] |
void queue_shuffle_order | ( | struct queue * | queue | ) |
Shuffles the virtual order of songs, but does not move them physically.
This is used in random mode.
void queue_shuffle_order_last | ( | struct queue * | queue, | |
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_shuffle_range | ( | struct queue * | queue, | |
unsigned | start, | |||
unsigned | end | |||
) |
Shuffles a (position) range in the queue.
The songs are physically shuffled, not by using the "order" mapping.
static bool queue_song_newer | ( | const struct queue * | queue, | |
unsigned | position, | |||
uint32_t | version | |||
) | [inline, static] |
void queue_swap | ( | struct queue * | queue, | |
unsigned | position1, | |||
unsigned | position2 | |||
) |
Swaps two songs, addressed by their position.
static void queue_swap_order | ( | struct queue * | queue, | |
unsigned | order1, | |||
unsigned | order2 | |||
) | [inline, static] |
static bool queue_valid_order | ( | const struct queue * | queue, | |
unsigned | order | |||
) | [inline, static] |