mirror of
https://github.com/owntone/owntone-server.git
synced 2025-02-04 10:26:02 -05:00
[player] Add 'consume' mode
If consume mode is active the current song is removed from the queue at eof or if the next song action is triggered.
This commit is contained in:
parent
6f0e50add1
commit
c3e8568782
36
src/player.c
36
src/player.c
@ -190,6 +190,7 @@ static int clear_queue_on_stop_disabled;
|
|||||||
static enum play_status player_state;
|
static enum play_status player_state;
|
||||||
static enum repeat_mode repeat;
|
static enum repeat_mode repeat;
|
||||||
static char shuffle;
|
static char shuffle;
|
||||||
|
static char consume;
|
||||||
|
|
||||||
/* Playback timer */
|
/* Playback timer */
|
||||||
#if defined(__linux__)
|
#if defined(__linux__)
|
||||||
@ -1221,6 +1222,9 @@ source_check(void)
|
|||||||
#endif
|
#endif
|
||||||
history_add(cur_playing->id, cur_playing->item_id);
|
history_add(cur_playing->id, cur_playing->item_id);
|
||||||
|
|
||||||
|
if (consume)
|
||||||
|
db_queue_delete_byitemid(cur_playing->item_id);
|
||||||
|
|
||||||
/* Stop playback */
|
/* Stop playback */
|
||||||
if (!cur_playing->play_next)
|
if (!cur_playing->play_next)
|
||||||
{
|
{
|
||||||
@ -2064,6 +2068,7 @@ get_status(void *arg, int *retval)
|
|||||||
memset(status, 0, sizeof(struct player_status));
|
memset(status, 0, sizeof(struct player_status));
|
||||||
|
|
||||||
status->shuffle = shuffle;
|
status->shuffle = shuffle;
|
||||||
|
status->consume = consume;
|
||||||
status->repeat = repeat;
|
status->repeat = repeat;
|
||||||
|
|
||||||
status->volume = master_volume;
|
status->volume = master_volume;
|
||||||
@ -2519,6 +2524,7 @@ playback_next_bh(void *arg, int *retval)
|
|||||||
{
|
{
|
||||||
struct player_source *ps;
|
struct player_source *ps;
|
||||||
int ret;
|
int ret;
|
||||||
|
uint32_t item_id;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The upper half is playback_pause, therefor the current playing item is
|
* The upper half is playback_pause, therefor the current playing item is
|
||||||
@ -2535,6 +2541,8 @@ playback_next_bh(void *arg, int *retval)
|
|||||||
if (cur_streaming->output_start > cur_streaming->stream_start)
|
if (cur_streaming->output_start > cur_streaming->stream_start)
|
||||||
history_add(cur_streaming->id, cur_streaming->item_id);
|
history_add(cur_streaming->id, cur_streaming->item_id);
|
||||||
|
|
||||||
|
item_id = cur_streaming->item_id;
|
||||||
|
|
||||||
ps = source_next();
|
ps = source_next();
|
||||||
if (!ps)
|
if (!ps)
|
||||||
{
|
{
|
||||||
@ -2559,6 +2567,9 @@ playback_next_bh(void *arg, int *retval)
|
|||||||
return COMMAND_END;
|
return COMMAND_END;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (consume)
|
||||||
|
db_queue_delete_byitemid(item_id);
|
||||||
|
|
||||||
/* Silent status change - playback_start() sends the real status update */
|
/* Silent status change - playback_start() sends the real status update */
|
||||||
player_state = PLAY_PAUSED;
|
player_state = PLAY_PAUSED;
|
||||||
|
|
||||||
@ -3029,6 +3040,18 @@ shuffle_set(void *arg, int *retval)
|
|||||||
return COMMAND_END;
|
return COMMAND_END;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static enum command_state
|
||||||
|
consume_set(void *arg, int *retval)
|
||||||
|
{
|
||||||
|
union player_arg *cmdarg = arg;
|
||||||
|
|
||||||
|
consume = cmdarg->intval;
|
||||||
|
|
||||||
|
listener_notify(LISTENER_OPTIONS);
|
||||||
|
|
||||||
|
*retval = 0;
|
||||||
|
return COMMAND_END;
|
||||||
|
}
|
||||||
/*
|
/*
|
||||||
* Removes all items from the history
|
* Removes all items from the history
|
||||||
*/
|
*/
|
||||||
@ -3286,6 +3309,18 @@ player_shuffle_set(int enable)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
player_consume_set(int enable)
|
||||||
|
{
|
||||||
|
union player_arg cmdarg;
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
cmdarg.intval = enable;
|
||||||
|
|
||||||
|
ret = commands_exec_sync(cmdbase, consume_set, NULL, &cmdarg);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
player_queue_clear_history()
|
player_queue_clear_history()
|
||||||
{
|
{
|
||||||
@ -3415,6 +3450,7 @@ player_init(void)
|
|||||||
player_state = PLAY_STOPPED;
|
player_state = PLAY_STOPPED;
|
||||||
repeat = REPEAT_OFF;
|
repeat = REPEAT_OFF;
|
||||||
shuffle = 0;
|
shuffle = 0;
|
||||||
|
consume = 0;
|
||||||
|
|
||||||
history = (struct player_history *)calloc(1, sizeof(struct player_history));
|
history = (struct player_history *)calloc(1, sizeof(struct player_history));
|
||||||
|
|
||||||
|
@ -44,6 +44,7 @@ struct player_status {
|
|||||||
enum play_status status;
|
enum play_status status;
|
||||||
enum repeat_mode repeat;
|
enum repeat_mode repeat;
|
||||||
char shuffle;
|
char shuffle;
|
||||||
|
char consume;
|
||||||
|
|
||||||
int volume;
|
int volume;
|
||||||
|
|
||||||
@ -130,6 +131,9 @@ player_repeat_set(enum repeat_mode mode);
|
|||||||
int
|
int
|
||||||
player_shuffle_set(int enable);
|
player_shuffle_set(int enable);
|
||||||
|
|
||||||
|
int
|
||||||
|
player_consume_set(int enable);
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
player_queue_clear_history(void);
|
player_queue_clear_history(void);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user