From fbc71d502354faf0f6c1ba6b3599dd1e72318e6f Mon Sep 17 00:00:00 2001 From: jcorporation Date: Sat, 15 Jun 2024 00:46:07 +0200 Subject: [PATCH] Upd: add addToQueue argument for jukebox trigger --- src/mpd_client/jukebox.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/mpd_client/jukebox.c b/src/mpd_client/jukebox.c index d70071cec..f6ffdbf05 100644 --- a/src/mpd_client/jukebox.c +++ b/src/mpd_client/jukebox.c @@ -142,8 +142,12 @@ bool jukebox_run(struct t_mympd_state *mympd_state, struct t_partition_state *pa if (add_songs > partition_state->jukebox.queue->length) { if (partition_state->jukebox.mode == JUKEBOX_SCRIPT) { MYMPD_LOG_DEBUG(partition_state->name, "Jukebox: Trigger"); + struct t_list arguments; + list_init(&arguments); + list_push(&arguments, "addToQueue", 0, "1", NULL); int n = mympd_api_trigger_execute(&mympd_state->trigger_list, TRIGGER_MYMPD_JUKEBOX, partition_state->name, NULL); + list_clear(&arguments); if (n > 0) { if (n > 1) { MYMPD_LOG_WARN(partition_state->name, "More than one script triggered for jukebox."); @@ -186,6 +190,22 @@ bool jukebox_run(struct t_mympd_state *mympd_state, struct t_partition_state *pa request->extra = queue_list; return mympd_queue_push(mympd_api_queue, request, 0); } + if (partition_state->jukebox.mode == JUKEBOX_SCRIPT && partition_state->jukebox.queue->length < JUKEBOX_INTERNAL_SONG_QUEUE_LENGTH_MIN) { + MYMPD_LOG_DEBUG(partition_state->name, "Jukebox: Trigger"); + struct t_list arguments; + list_init(&arguments); + list_push(&arguments, "addToQueue", 0, "0", NULL); + int n = mympd_api_trigger_execute(&mympd_state->trigger_list, TRIGGER_MYMPD_JUKEBOX, + partition_state->name, NULL); + list_clear(&arguments); + if (n > 0) { + if (n > 1) { + MYMPD_LOG_WARN(partition_state->name, "More than one script triggered for jukebox."); + } + partition_state->jukebox.filling = true; + } + return n == 1; + } return rc; }