myMPD
Internal API documentation
Loading...
Searching...
No Matches
queue.c File Reference

myMPD queue API More...

#include "compile_time.h"
#include "src/mympd_api/queue.h"
#include "src/lib/cache/cache_rax_album.h"
#include "src/lib/json/json_print.h"
#include "src/lib/json/json_rpc.h"
#include "src/lib/log.h"
#include "src/lib/sds_extras.h"
#include "src/lib/utility.h"
#include "src/mympd_api/sticker.h"
#include "src/mympd_api/webradio.h"
#include "src/mympd_client/errorhandler.h"
#include "src/mympd_client/queue.h"
#include "src/mympd_client/search.h"
#include "src/mympd_client/shortcuts.h"
#include "src/mympd_client/stickerdb.h"
#include "src/mympd_client/tags.h"
#include <limits.h>
#include <string.h>
Include dependency graph for queue.c:

Functions

static bool add_queue_search_adv_params (struct t_partition_state *partition_state, sds sort, bool sortdesc, unsigned offset, unsigned limit)
 
sds print_queue_entry (struct t_mympd_state *mympd_state, struct t_partition_state *partition_state, sds buffer, const struct t_fields *tagcols, bool print_stickers, struct mpd_song *song)
 
bool mympd_api_queue_save (struct t_partition_state *partition_state, sds name, sds mode, sds *error)
 
bool mympd_api_queue_rm_song_ids (struct t_partition_state *partition_state, struct t_list *song_ids, sds *error)
 
bool mympd_api_queue_prio_set (struct t_partition_state *partition_state, struct t_list *song_ids, unsigned priority, sds *error)
 
bool mympd_api_queue_prio_set_highest (struct t_partition_state *partition_state, struct t_list *song_ids, sds *error)
 
bool mympd_api_queue_move_relative (struct t_partition_state *partition_state, struct t_list *song_ids, unsigned to, unsigned whence, sds *error)
 
bool mympd_api_queue_insert_uri_tags (struct t_partition_state *partition_state, sds uri, struct t_list *tags, unsigned to, unsigned whence, sds *error)
 
bool mympd_api_queue_append_uri_tags (struct t_partition_state *partition_state, sds uri, struct t_list *tags, sds *error)
 
bool mympd_api_queue_replace_uri_tags (struct t_partition_state *partition_state, sds uri, struct t_list *tags, sds *error)
 
bool mympd_api_queue_insert_uri_resume (struct t_partition_state *partition_state, struct t_stickerdb_state *stickerdb, sds uri, unsigned to, unsigned whence, sds *error)
 
bool mympd_api_queue_append_uri_resume (struct t_partition_state *partition_state, struct t_stickerdb_state *stickerdb, sds uri, sds *error)
 
bool mympd_api_queue_replace_uri_resume (struct t_partition_state *partition_state, struct t_stickerdb_state *stickerdb, sds uri, sds *error)
 
bool mympd_api_queue_insert (struct t_partition_state *partition_state, struct t_list *uris, unsigned to, unsigned whence, sds *error)
 
bool mympd_api_queue_append (struct t_partition_state *partition_state, struct t_list *uris, sds *error)
 
bool mympd_api_queue_replace (struct t_partition_state *partition_state, struct t_list *uris, sds *error)
 
bool mympd_api_queue_insert_search (struct t_partition_state *partition_state, sds expression, unsigned to, unsigned whence, const char *sort, bool sort_desc, sds *error)
 
bool mympd_api_queue_append_search (struct t_partition_state *partition_state, sds expression, const char *sort, bool sort_desc, sds *error)
 
bool mympd_api_queue_replace_search (struct t_partition_state *partition_state, sds expression, const char *sort, bool sort_desc, sds *error)
 
bool mympd_api_queue_insert_albums (struct t_partition_state *partition_state, struct t_cache *album_cache, struct t_list *albumids, unsigned to, unsigned whence, sds *error)
 
bool mympd_api_queue_append_albums (struct t_partition_state *partition_state, struct t_cache *album_cache, struct t_list *albumids, sds *error)
 
bool mympd_api_queue_replace_albums (struct t_partition_state *partition_state, struct t_cache *album_cache, struct t_list *albumids, sds *error)
 
bool mympd_api_queue_insert_album_tag (struct t_partition_state *partition_state, struct t_cache *album_cache, sds albumid, enum mpd_tag_type tag, sds value, unsigned to, unsigned whence, sds *error)
 
bool mympd_api_queue_append_album_tag (struct t_partition_state *partition_state, struct t_cache *album_cache, sds albumid, enum mpd_tag_type tag, sds value, sds *error)
 
bool mympd_api_queue_replace_album_tag (struct t_partition_state *partition_state, struct t_cache *album_cache, sds albumid, enum mpd_tag_type tag, sds value, sds *error)
 
bool mympd_api_queue_insert_album_range (struct t_partition_state *partition_state, struct t_cache *album_cache, sds albumid, unsigned start, int end, unsigned to, unsigned whence, sds *error)
 
bool mympd_api_queue_append_album_range (struct t_partition_state *partition_state, struct t_cache *album_cache, sds albumid, unsigned start, int end, sds *error)
 
bool mympd_api_queue_replace_album_range (struct t_partition_state *partition_state, struct t_cache *album_cache, sds albumid, unsigned start, int end, sds *error)
 
bool mympd_api_queue_insert_plist_range (struct t_partition_state *partition_state, sds plist, unsigned to, unsigned whence, unsigned start, int end, sds *error)
 
bool mympd_api_queue_append_plist_range (struct t_partition_state *partition_state, sds plist, unsigned start, int end, sds *error)
 
bool mympd_api_queue_replace_plist_range (struct t_partition_state *partition_state, sds plist, unsigned start, int end, sds *error)
 
bool mympd_api_queue_insert_plists (struct t_partition_state *partition_state, struct t_list *plists, unsigned to, unsigned whence, sds *error)
 
bool mympd_api_queue_append_plists (struct t_partition_state *partition_state, struct t_list *plists, sds *error)
 
bool mympd_api_queue_replace_plists (struct t_partition_state *partition_state, struct t_list *plists, sds *error)
 
sds mympd_api_queue_crop (struct t_partition_state *partition_state, sds buffer, enum mympd_cmd_ids cmd_id, unsigned request_id, bool or_clear)
 
sds mympd_api_queue_list (struct t_mympd_state *mympd_state, struct t_partition_state *partition_state, sds buffer, unsigned request_id, unsigned offset, unsigned limit, const struct t_fields *tagcols)
 
sds mympd_api_queue_search (struct t_mympd_state *mympd_state, struct t_partition_state *partition_state, sds buffer, unsigned request_id, sds expression, sds sort, bool sortdesc, unsigned offset, unsigned limit, const struct t_fields *tagcols)
 

Detailed Description

myMPD queue API

Function Documentation

◆ add_queue_search_adv_params()

static bool add_queue_search_adv_params ( struct t_partition_state partition_state,
sds  sort,
bool  sortdesc,
unsigned  offset,
unsigned  limit 
)
static

Private definitions

Adds sort and window parameter to queue search, if feat_advqueue is true

Parameters
partition_statepointer to partition state
sorttag to sort
sortdescsort descending?
offsetoffset for the list - only relevant for feat_advqueue
limitmaximum entries to print - only relevant for feat_advqueue
Returns
true on success, else false

◆ mympd_api_queue_append()

bool mympd_api_queue_append ( struct t_partition_state partition_state,
struct t_list uris,
sds *  error 
)

Appends uris to the queue

Parameters
partition_statepointer to partition state
urisuris to append
errorpointer to an already allocated sds string for the error message
Returns
true on success, else false

◆ mympd_api_queue_append_album_range()

bool mympd_api_queue_append_album_range ( struct t_partition_state partition_state,
struct t_cache album_cache,
sds  albumid,
unsigned  start,
int  end,
sds *  error 
)

Appends a range of song from an album to the queue

Parameters
partition_statepointer to partition state
album_cachepointer to album cache
albumidalbum id to append
startstart of the range (including)
endend of the range (excluded)
errorpointer to an already allocated sds string for the error message
Returns
true on success, else false

◆ mympd_api_queue_append_album_tag()

bool mympd_api_queue_append_album_tag ( struct t_partition_state partition_state,
struct t_cache album_cache,
sds  albumid,
enum mpd_tag_type  tag,
sds  value,
sds *  error 
)

Appends songs of an album filtered by tag to the queue

Parameters
partition_statepointer to partition state
album_cachepointer to album cache
albumidalbum id to append
tagMPD tag
valueMPD tag value
errorpointer to an already allocated sds string for the error message
Returns
true on success, else false

◆ mympd_api_queue_append_albums()

bool mympd_api_queue_append_albums ( struct t_partition_state partition_state,
struct t_cache album_cache,
struct t_list albumids,
sds *  error 
)

Appends albums to the queue

Parameters
partition_statepointer to partition state
album_cachepointer to album cache
albumidsalbum ids to append
errorpointer to an already allocated sds string for the error message
Returns
true on success, else false

◆ mympd_api_queue_append_plist_range()

bool mympd_api_queue_append_plist_range ( struct t_partition_state partition_state,
sds  plist,
unsigned  start,
int  end,
sds *  error 
)

Appends a playlist range to the queue

Parameters
partition_statepointer to partition state
plistplaylist to append
startstart of the range (including)
endend of the range (excluded)
errorpointer to an already allocated sds string for the error message
Returns
true on success, else false

◆ mympd_api_queue_append_plists()

bool mympd_api_queue_append_plists ( struct t_partition_state partition_state,
struct t_list plists,
sds *  error 
)

Appends playlists to the queue

Parameters
partition_statepointer to partition state
plistsplaylists to append
errorpointer to an already allocated sds string for the error message
Returns
true on success, else false

◆ mympd_api_queue_append_search()

bool mympd_api_queue_append_search ( struct t_partition_state partition_state,
sds  expression,
const char *  sort,
bool  sort_desc,
sds *  error 
)

Appends the search results to the queue

Parameters
partition_statepointer to partition state
expressionmpd search expression
sortsort by tag
sort_descsort descending?
errorpointer to an already allocated sds string for the error message
Returns
true on success, else false

◆ mympd_api_queue_append_uri_resume()

bool mympd_api_queue_append_uri_resume ( struct t_partition_state partition_state,
struct t_stickerdb_state stickerdb,
sds  uri,
sds *  error 
)

Appends an uri to the queue and resumes playback.

Parameters
partition_statepointer to partition state
stickerdbpointer to stickerdb
uriuri to add to the queue
errorpointer to an already allocated sds string for the error message
Returns
bool true on success, else false

◆ mympd_api_queue_append_uri_tags()

bool mympd_api_queue_append_uri_tags ( struct t_partition_state partition_state,
sds  uri,
struct t_list tags,
sds *  error 
)

Appends an uri to the queue and sets tag values for it.

Parameters
partition_statepointer to partition state
uriuri to add to the queue
tagslist of tags with values to set
errorpointer to an already allocated sds string for the error message
Returns
bool true on success, else false

◆ mympd_api_queue_crop()

sds mympd_api_queue_crop ( struct t_partition_state partition_state,
sds  buffer,
enum mympd_cmd_ids  cmd_id,
unsigned  request_id,
bool  or_clear 
)

Crops (removes all but playing song) or clears the queue if no song is playing

Parameters
partition_statepointer to partition state
bufferalready allocated sds string to append the response
cmd_idjsonrpc method
request_idjsonrpc id
or_clearif true: clears the queue if there is no current playing or paused song
Returns
pointer to buffer

◆ mympd_api_queue_insert()

bool mympd_api_queue_insert ( struct t_partition_state partition_state,
struct t_list uris,
unsigned  to,
unsigned  whence,
sds *  error 
)

Insert uris into the queue

Parameters
partition_statepointer to partition state
urisuris to insert
toposition to insert
whencehow to interpret the to parameter
errorpointer to an already allocated sds string for the error message
Returns
true on success, else false

◆ mympd_api_queue_insert_album_range()

bool mympd_api_queue_insert_album_range ( struct t_partition_state partition_state,
struct t_cache album_cache,
sds  albumid,
unsigned  start,
int  end,
unsigned  to,
unsigned  whence,
sds *  error 
)

Inserts a range of song from an album into the queue

Parameters
partition_statepointer to partition state
album_cachepointer to album cache
albumidalbum id to insert
startstart of the range (including)
endend of the range (excluded)
toposition to insert
whencehow to interpret the to parameter
errorpointer to an already allocated sds string for the error message
Returns
true on success, else false

◆ mympd_api_queue_insert_album_tag()

bool mympd_api_queue_insert_album_tag ( struct t_partition_state partition_state,
struct t_cache album_cache,
sds  albumid,
enum mpd_tag_type  tag,
sds  value,
unsigned  to,
unsigned  whence,
sds *  error 
)

Inserts songs of an album filtered by tag into the queue

Parameters
partition_statepointer to partition state
album_cachepointer to album cache
albumidalbum id to insert
tagMPD tag
valueMPD tag value
toposition to insert
whencehow to interpret the to parameter
errorpointer to an already allocated sds string for the error message
Returns
true on success, else false

◆ mympd_api_queue_insert_albums()

bool mympd_api_queue_insert_albums ( struct t_partition_state partition_state,
struct t_cache album_cache,
struct t_list albumids,
unsigned  to,
unsigned  whence,
sds *  error 
)

Inserts albums into the queue

Parameters
partition_statepointer to partition state
album_cachepointer to album cache
albumidsalbum ids to insert
toposition to insert
whencehow to interpret the to parameter
errorpointer to an already allocated sds string for the error message
Returns
true on success, else false

◆ mympd_api_queue_insert_plist_range()

bool mympd_api_queue_insert_plist_range ( struct t_partition_state partition_state,
sds  plist,
unsigned  to,
unsigned  whence,
unsigned  start,
int  end,
sds *  error 
)

Inserts a playlist range into the queue

Parameters
partition_statepointer to partition state
plistplaylist to insert
toposition to insert
whencehow to interpret the to parameter
startstart of the range (including)
endend of the range (excluded)
errorpointer to an already allocated sds string for the error message
Returns
true on success, else false

◆ mympd_api_queue_insert_plists()

bool mympd_api_queue_insert_plists ( struct t_partition_state partition_state,
struct t_list plists,
unsigned  to,
unsigned  whence,
sds *  error 
)

Insert playlists into the queue

Parameters
partition_statepointer to partition state
plistsplaylists to insert
toposition to insert
whencehow to interpret the to parameter
errorpointer to an already allocated sds string for the error message
Returns
true on success, else false

◆ mympd_api_queue_insert_search()

bool mympd_api_queue_insert_search ( struct t_partition_state partition_state,
sds  expression,
unsigned  to,
unsigned  whence,
const char *  sort,
bool  sort_desc,
sds *  error 
)

Inserts search results into the queue

Parameters
partition_statepointer to partition state
expressionmpd search expression
toposition to insert
whencehow to interpret the to parameter
sortsort by tag
sort_descsort descending?
errorpointer to an already allocated sds string for the error message
Returns
true on success, else false

◆ mympd_api_queue_insert_uri_resume()

bool mympd_api_queue_insert_uri_resume ( struct t_partition_state partition_state,
struct t_stickerdb_state stickerdb,
sds  uri,
unsigned  to,
unsigned  whence,
sds *  error 
)

Inserts an uri to the queue and resumes playback.

Parameters
partition_statepointer to partition state
stickerdbpointer to stickerdb
uriuri to add to the queue
towhere to insert the uri
whenceHow to interprete the to parameter
errorpointer to an already allocated sds string for the error message
Returns
bool true on success, else false

◆ mympd_api_queue_insert_uri_tags()

bool mympd_api_queue_insert_uri_tags ( struct t_partition_state partition_state,
sds  uri,
struct t_list tags,
unsigned  to,
unsigned  whence,
sds *  error 
)

Inserts an uri to the queue and sets tag values for it.

Parameters
partition_statepointer to partition state
uriuri to add to the queue
tagslist of tags with values to set
towhere to insert the uri
whenceHow to interprete the to parameter
errorpointer to an already allocated sds string for the error message
Returns
bool true on success, else false

◆ mympd_api_queue_list()

sds mympd_api_queue_list ( struct t_mympd_state mympd_state,
struct t_partition_state partition_state,
sds  buffer,
unsigned  request_id,
unsigned  offset,
unsigned  limit,
const struct t_fields tagcols 
)

Lists the queue, this is faster for older MPD servers than the search function below.

Parameters
mympd_statepointer to mympd_state
partition_statepointer to partition state
bufferalready allocated sds string to append the response
request_idjsonrpc id
offsetoffset for the list
limitmaximum entries to print
tagcolscolumns to print
Returns
pointer to buffer

◆ mympd_api_queue_move_relative()

bool mympd_api_queue_move_relative ( struct t_partition_state partition_state,
struct t_list song_ids,
unsigned  to,
unsigned  whence,
sds *  error 
)

Moves song ids to relative position after current song

Parameters
partition_statepointer to partition state
song_idssong ids to move
torelative position
whencehow to interpret the to parameter
errorpointer to an already allocated sds string for the error message
Returns
bool true on success, else false

◆ mympd_api_queue_prio_set()

bool mympd_api_queue_prio_set ( struct t_partition_state partition_state,
struct t_list song_ids,
unsigned  priority,
sds *  error 
)

Sets the priority of entries in the queue. The priority has only an effect in random mode.

Parameters
partition_statepointer to partition state
song_idssong ids in the queue
prioritypriority to set, max 255
errorpointer to an already allocated sds string for the error message
Returns
true on success, else false

◆ mympd_api_queue_prio_set_highest()

bool mympd_api_queue_prio_set_highest ( struct t_partition_state partition_state,
struct t_list song_ids,
sds *  error 
)

Sets the priority to the highest value of a song in the queue. The priority has only an effect in random mode.

Parameters
partition_statepointer to partition state
song_idssong ids in the queue
errorpointer to an already allocated sds string for the error message
Returns
true on success, else false

◆ mympd_api_queue_replace()

bool mympd_api_queue_replace ( struct t_partition_state partition_state,
struct t_list uris,
sds *  error 
)

Replaces the queue with uris

Parameters
partition_statepointer to partition state
urisuris to add
errorpointer to an already allocated sds string for the error message
Returns
true on success, else false

◆ mympd_api_queue_replace_album_range()

bool mympd_api_queue_replace_album_range ( struct t_partition_state partition_state,
struct t_cache album_cache,
sds  albumid,
unsigned  start,
int  end,
sds *  error 
)

Replaces the queue with a range of song from an album

Parameters
partition_statepointer to partition state
album_cachepointer to album cache
albumidalbum id to insert
startstart of the range (including)
endend of the range (excluded)
errorpointer to an already allocated sds string for the error message
Returns
true on success, else false

◆ mympd_api_queue_replace_album_tag()

bool mympd_api_queue_replace_album_tag ( struct t_partition_state partition_state,
struct t_cache album_cache,
sds  albumid,
enum mpd_tag_type  tag,
sds  value,
sds *  error 
)

Replaces the queue with an album filted by tag

Parameters
partition_statepointer to partition state
album_cachepointer to album cache
albumidalbum id to insert
tagMPD tag
valueMPD tag value
errorpointer to an already allocated sds string for the error message
Returns
true on success, else false

◆ mympd_api_queue_replace_albums()

bool mympd_api_queue_replace_albums ( struct t_partition_state partition_state,
struct t_cache album_cache,
struct t_list albumids,
sds *  error 
)

Replaces the queue with albums

Parameters
partition_statepointer to partition state
album_cachepointer to album cache
albumidsalbum ids to insert
errorpointer to an already allocated sds string for the error message
Returns
true on success, else false

◆ mympd_api_queue_replace_plist_range()

bool mympd_api_queue_replace_plist_range ( struct t_partition_state partition_state,
sds  plist,
unsigned  start,
int  end,
sds *  error 
)

Replaces the queue with a playlist range

Parameters
partition_statepointer to partition state
plistplaylist to add
startstart of the range (including)
endend of the range (excluded)
errorpointer to an already allocated sds string for the error message
Returns
true on success, else false

◆ mympd_api_queue_replace_plists()

bool mympd_api_queue_replace_plists ( struct t_partition_state partition_state,
struct t_list plists,
sds *  error 
)

Replaces the queue with playlists

Parameters
partition_statepointer to partition state
plistsplaylists to add
errorpointer to an already allocated sds string for the error message
Returns
true on success, else false

◆ mympd_api_queue_replace_search()

bool mympd_api_queue_replace_search ( struct t_partition_state partition_state,
sds  expression,
const char *  sort,
bool  sort_desc,
sds *  error 
)

Replaces the queue with the search result

Parameters
partition_statepointer to partition state
expressionmpd search expression
sortsort by tag
sort_descsort descending?
errorpointer to an already allocated sds string for the error message
Returns
true on success, else false

◆ mympd_api_queue_replace_uri_resume()

bool mympd_api_queue_replace_uri_resume ( struct t_partition_state partition_state,
struct t_stickerdb_state stickerdb,
sds  uri,
sds *  error 
)

Replaces the queue with the uri and resumes playback.

Parameters
partition_statepointer to partition state
stickerdbpointer to stickerdb
uriuri to add to the queue
errorpointer to an already allocated sds string for the error message
Returns
bool true on success, else false

◆ mympd_api_queue_replace_uri_tags()

bool mympd_api_queue_replace_uri_tags ( struct t_partition_state partition_state,
sds  uri,
struct t_list tags,
sds *  error 
)

Replaces the queue with the uri and sets tag values for it.

Parameters
partition_statepointer to partition state
uriuri to add to the queue
tagslist of tags with values to set
errorpointer to an already allocated sds string for the error message
Returns
bool true on success, else false

◆ mympd_api_queue_rm_song_ids()

bool mympd_api_queue_rm_song_ids ( struct t_partition_state partition_state,
struct t_list song_ids,
sds *  error 
)

Removes songs defined by id from the queue

Parameters
partition_statepointer to partition state
song_idslist of song_ids to remove
errorpointer to an already allocated sds string for the error message
Returns
true on success, else false

◆ mympd_api_queue_save()

bool mympd_api_queue_save ( struct t_partition_state partition_state,
sds  name,
sds  mode,
sds *  error 
)

Public functions Saves the queue as a playlist

Parameters
partition_state
namepointer to partition state
modempd queue save mode
errorpointer to an already allocated sds string for the error message
Returns
bool true on success, else false

◆ mympd_api_queue_search()

sds mympd_api_queue_search ( struct t_mympd_state mympd_state,
struct t_partition_state partition_state,
sds  buffer,
unsigned  request_id,
sds  expression,
sds  sort,
bool  sortdesc,
unsigned  offset,
unsigned  limit,
const struct t_fields tagcols 
)

Searches the queue

Parameters
mympd_statepointer to mympd_state
partition_statepointer to partition state
bufferalready allocated sds string to append the response
request_idjsonrpc id
expressionmpd filter expression
sorttag to sort - only relevant for feat_advqueue
sortdescfalse = ascending, true = descending sort - only relevant for feat_advqueue
offsetoffset for the list - only relevant for feat_advqueue
limitmaximum entries to print - only relevant for feat_advqueue
tagcolscolumns to print
Returns
pointer to buffer

◆ print_queue_entry()

sds print_queue_entry ( struct t_mympd_state mympd_state,
struct t_partition_state partition_state,
sds  buffer,
const struct t_fields tagcols,
bool  print_stickers,
struct mpd_song *  song 
)

Prints a queue entry as an json object string

Parameters
mympd_statepointer to mympd_state
partition_statepointer to partition state
bufferalready allocated sds string to append the response
tagcolscolumns to print
print_stickersPrint stickers?
songpointer to mpd song struct
Returns
pointer to buffer