Skip to content

Commit

Permalink
Upd: add addToQueue argument for jukebox trigger
Browse files Browse the repository at this point in the history
  • Loading branch information
jcorporation committed Jun 14, 2024
1 parent 6e7c1e3 commit fbc71d5
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/mpd_client/jukebox.c
Original file line number Diff line number Diff line change
Expand Up @@ -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.");
Expand Down Expand Up @@ -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;
}

Expand Down

0 comments on commit fbc71d5

Please sign in to comment.