src/queue.h File Reference

#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 G_GNUC_PURE uint8_t queue_get_priority_at_position (const struct queue *queue, unsigned position)
static struct songqueue_get (const struct queue *queue, unsigned position)
 Returns the song at the specified position.
static struct songqueue_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, uint8_t priority)
 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_range_with_priority (struct queue *queue, unsigned start, unsigned end)
 Shuffle the order of items in the specified range, taking their priorities into account.
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.
bool queue_set_priority (struct queue *queue, unsigned position, uint8_t priority, int after_order)
bool queue_set_priority_range (struct queue *queue, unsigned start_position, unsigned end_position, uint8_t priority, int after_order)

Enumeration Type Documentation

anonymous enum
Enumerator:
QUEUE_HASH_MULT 

reserve max_length * QUEUE_HASH_MULT elements in the id number space

Definition at line 29 of file queue.h.


Function Documentation

unsigned queue_append ( struct queue queue,
struct song 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_in_database()), it is freed when removed from the queue.

Parameters:
priority the priority of this new queue item
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 struct song* queue_get ( const struct queue queue,
unsigned  position 
) [static, read]

Returns the song at the specified position.

Definition at line 204 of file queue.h.

static struct song* queue_get_order ( const struct queue queue,
unsigned  order 
) [static, read]

Returns the song at the specified order number.

Definition at line 215 of file queue.h.

static G_GNUC_PURE uint8_t queue_get_priority_at_position ( const struct queue queue,
unsigned  position 
) [inline, static]

Definition at line 193 of file queue.h.

static int queue_id_to_position ( const struct queue queue,
unsigned  id 
) [inline, static]

Definition at line 151 of file queue.h.

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]

Determine if the queue is empty, i.e.

there are no songs.

Definition at line 116 of file queue.h.

static bool queue_is_full ( const struct queue queue  )  [inline, static]

Determine if the maximum number of songs has been reached.

Definition at line 125 of file queue.h.

static unsigned queue_length ( const struct queue queue  )  [inline, static]

Definition at line 105 of file queue.h.

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.

Returns:
the next order number, or -1 to stop playback
static unsigned queue_order_to_position ( const struct queue queue,
unsigned  order 
) [inline, static]

Definition at line 171 of file queue.h.

static int queue_position_to_id ( const struct queue queue,
unsigned  position 
) [inline, static]

Definition at line 163 of file queue.h.

static unsigned queue_position_to_order ( const struct queue queue,
unsigned  position 
) [inline, static]

Definition at line 179 of file queue.h.

static void queue_restore_order ( struct queue queue  )  [inline, static]

Initializes the "order" array, and restores "normal" order.

Definition at line 334 of file queue.h.

bool queue_set_priority ( struct queue queue,
unsigned  position,
uint8_t  priority,
int  after_order 
)
bool queue_set_priority_range ( struct queue queue,
unsigned  start_position,
unsigned  end_position,
uint8_t  priority,
int  after_order 
)
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_order_range_with_priority ( struct queue queue,
unsigned  start,
unsigned  end 
)

Shuffle the order of items in the specified range, taking their priorities into account.

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]

Is the song at the specified position newer than the specified version?

Definition at line 225 of file queue.h.

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]

Swaps two songs, addressed by their order number.

Definition at line 299 of file queue.h.

static bool queue_valid_order ( const struct queue queue,
unsigned  order 
) [inline, static]

Is that a valid order number?

Definition at line 145 of file queue.h.

static bool queue_valid_position ( const struct queue queue,
unsigned  position 
) [inline, static]

Is that a valid position number?

Definition at line 136 of file queue.h.


Generated on 17 Jul 2013 for MPD by  doxygen 1.6.1