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

Jukebox functions. More...

#include "compile_time.h"
#include "src/mympd_client/jukebox.h"
#include "dist/sds/sds.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/mem.h"
#include "src/lib/msg_queue.h"
#include "src/lib/mympd_state.h"
#include "src/lib/sds_extras.h"
#include "src/lib/timer.h"
#include "src/mympd_api/trigger.h"
#include "src/mympd_client/errorhandler.h"
#include "src/mympd_client/queue.h"
#include "src/mympd_client/shortcuts.h"
#include "src/mympd_client/tags.h"
#include <stdbool.h>
#include <string.h>
Include dependency graph for jukebox.c:

Functions

static void jukebox_get_last_played_add (struct t_partition_state *partition_state, struct mpd_song *song, struct t_list *queue_list, enum jukebox_modes jukebox_mode)
 
static struct t_listjukebox_get_last_played (struct t_partition_state *partition_state, enum jukebox_modes jukebox_mode)
 
void jukebox_clear_all (struct t_mympd_state *mympd_state)
 
void jukebox_disable (struct t_partition_state *partition_state)
 
bool jukebox_trigger_script (struct t_mympd_state *mympd_state, struct t_partition_state *partition_state, bool add_to_queue)
 
static bool jukebox_request_worker (struct t_partition_state *partition_state, enum mympd_cmd_ids cmd_id, unsigned add_songs)
 
bool jukebox_run (struct t_mympd_state *mympd_state, struct t_partition_state *partition_state, struct t_cache *album_cache)
 
bool jukebox_add_to_queue (struct t_partition_state *partition_state, struct t_cache *album_cache, unsigned add_songs, sds *error)
 

Detailed Description

Jukebox functions.

Function Documentation

◆ jukebox_add_to_queue()

bool jukebox_add_to_queue ( struct t_partition_state partition_state,
struct t_cache album_cache,
unsigned  add_songs,
sds *  error 
)

Adds songs or albums from the jukebox queue to the MPD queue and starts playing.

Parameters
partition_statepointer to myMPD partition state
album_cachepointer to album cache
add_songsnumber of songs to add
errorpointer to allocated sds for error message
Returns
true on success, else false

◆ jukebox_clear_all()

void jukebox_clear_all ( struct t_mympd_state mympd_state)

Public functions Clears the jukebox queue of all partitions.

Parameters
mympd_statepointer to central myMPD state.

◆ jukebox_disable()

void jukebox_disable ( struct t_partition_state partition_state)

Disables the jukebox timer

Parameters
partition_statepointer to partition state

◆ jukebox_get_last_played()

static struct t_list * jukebox_get_last_played ( struct t_partition_state partition_state,
enum jukebox_modes  jukebox_mode 
)
static

Gets the songs or albums from queue and last played. This list is used to enforce the uniq tag constraint

Parameters
partition_statepointer to myMPD partition state
jukebox_modethe jukebox mode
Returns
a newly allocated list with songs or albums

◆ jukebox_get_last_played_add()

static void jukebox_get_last_played_add ( struct t_partition_state partition_state,
struct mpd_song *  song,
struct t_list queue_list,
enum jukebox_modes  jukebox_mode 
)
static

Private functions Adds an album or song to the jukebox last played list

Parameters
partition_statepointer to myMPD partition state
songmpd_song struct to append
queue_listlist to append the entry
jukebox_modethe jukebox mode

◆ jukebox_request_worker()

static bool jukebox_request_worker ( struct t_partition_state partition_state,
enum mympd_cmd_ids  cmd_id,
unsigned  add_songs 
)
static

Sends a request to the mympd_api thread to start worker to fill the jukebox queue

Parameters
partition_statePointer to myMPD partition state
cmd_idMYMPD_API_JUKEBOX_REFILL or MYMPD_API_JUKEBOX_REFILL_ADD
add_songsNumber of songs to add
Returns
true on success, else false

◆ jukebox_run()

bool jukebox_run ( struct t_mympd_state mympd_state,
struct t_partition_state partition_state,
struct t_cache album_cache 
)

The real jukebox function. It determines if a song must be added or not and starts playing.

Parameters
mympd_statePointer to myMPD state
partition_statePointer to myMPD partition state
album_cachePointer to album cache
Returns
true on success, else false

◆ jukebox_trigger_script()

bool jukebox_trigger_script ( struct t_mympd_state mympd_state,
struct t_partition_state partition_state,
bool  add_to_queue 
)

Executes the jukebox script trigger

Parameters
mympd_statePointer to myMPD state
partition_statePointer to myMPD partition state
add_to_queueAdd entries to MPD queue
Returns
true on success, else false