mirror of
https://github.com/owntone/owntone-server.git
synced 2025-01-27 06:33:21 -05:00
[library/db/filescanner/spotify] Reshuffle after adding non library
items to the queue
This commit is contained in:
parent
05141480e2
commit
a8e8dc1999
8
src/db.c
8
src/db.c
@ -4788,7 +4788,7 @@ db_queue_add_start(struct db_queue_add_info *queue_add_info, int pos)
|
|||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
db_queue_add_end(struct db_queue_add_info *queue_add_info, int ret)
|
db_queue_add_end(struct db_queue_add_info *queue_add_info, char reshuffle, uint32_t item_id, int ret)
|
||||||
{
|
{
|
||||||
char *query;
|
char *query;
|
||||||
|
|
||||||
@ -4800,6 +4800,12 @@ db_queue_add_end(struct db_queue_add_info *queue_add_info, int ret)
|
|||||||
ret = db_query_run(query, 1, 0);
|
ret = db_query_run(query, 1, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Reshuffle after adding new items
|
||||||
|
if (ret == 0 && reshuffle)
|
||||||
|
{
|
||||||
|
ret = queue_reshuffle(item_id, queue_add_info->queue_version);
|
||||||
|
}
|
||||||
|
|
||||||
queue_transaction_end(ret, queue_add_info->queue_version);
|
queue_transaction_end(ret, queue_add_info->queue_version);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
2
src/db.h
2
src/db.h
@ -794,7 +794,7 @@ int
|
|||||||
db_queue_add_start(struct db_queue_add_info *queue_add_info, int pos);
|
db_queue_add_start(struct db_queue_add_info *queue_add_info, int pos);
|
||||||
|
|
||||||
int
|
int
|
||||||
db_queue_add_end(struct db_queue_add_info *queue_add_info, int ret);
|
db_queue_add_end(struct db_queue_add_info *queue_add_info, char reshuffle, uint32_t item_id, int ret);
|
||||||
|
|
||||||
int
|
int
|
||||||
db_queue_add_item(struct db_queue_add_info *queue_add_info, struct db_queue_item *item);
|
db_queue_add_item(struct db_queue_add_info *queue_add_info, struct db_queue_item *item);
|
||||||
|
@ -145,11 +145,14 @@ library_add_media(struct media_file_info *mfi)
|
|||||||
int
|
int
|
||||||
library_queue_add(const char *path, int position, int *count, int *new_item_id)
|
library_queue_add(const char *path, int position, int *count, int *new_item_id)
|
||||||
{
|
{
|
||||||
|
struct player_status status;
|
||||||
int i;
|
int i;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
DPRINTF(E_DBG, L_LIB, "Add items for path '%s' to the queue\n", path);
|
DPRINTF(E_DBG, L_LIB, "Add items for path '%s' to the queue\n", path);
|
||||||
|
|
||||||
|
player_get_status(&status);
|
||||||
|
|
||||||
ret = LIBRARY_PATH_INVALID;
|
ret = LIBRARY_PATH_INVALID;
|
||||||
for (i = 0; sources[i] && ret == LIBRARY_PATH_INVALID; i++)
|
for (i = 0; sources[i] && ret == LIBRARY_PATH_INVALID; i++)
|
||||||
{
|
{
|
||||||
@ -159,7 +162,7 @@ library_queue_add(const char *path, int position, int *count, int *new_item_id)
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = sources[i]->queue_add(path, position, count, new_item_id);
|
ret = sources[i]->queue_add(path, position, status.shuffle, status.item_id, count, new_item_id);
|
||||||
|
|
||||||
if (ret == LIBRARY_OK)
|
if (ret == LIBRARY_OK)
|
||||||
{
|
{
|
||||||
|
@ -84,7 +84,7 @@ struct library_source
|
|||||||
/*
|
/*
|
||||||
* Add item for the given path to the current queue
|
* Add item for the given path to the current queue
|
||||||
*/
|
*/
|
||||||
int (*queue_add)(const char *path, int position, int *count, int *new_item_id);
|
int (*queue_add)(const char *path, int position, char reshuffle, uint32_t item_id, int *count, int *new_item_id);
|
||||||
};
|
};
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -1676,7 +1676,7 @@ map_media_file_to_queue_item(struct db_queue_item *queue_item, struct media_file
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
queue_add_stream(const char *path, int position, int *count, int *new_item_id)
|
queue_add_stream(const char *path, int position, char reshuffle, uint32_t item_id, int *count, int *new_item_id)
|
||||||
{
|
{
|
||||||
struct media_file_info mfi;
|
struct media_file_info mfi;
|
||||||
struct db_queue_item item;
|
struct db_queue_item item;
|
||||||
@ -1694,7 +1694,7 @@ queue_add_stream(const char *path, int position, int *count, int *new_item_id)
|
|||||||
if (ret == 0)
|
if (ret == 0)
|
||||||
{
|
{
|
||||||
ret = db_queue_add_item(&queue_add_info, &item);
|
ret = db_queue_add_item(&queue_add_info, &item);
|
||||||
ret = db_queue_add_end(&queue_add_info, ret);
|
ret = db_queue_add_end(&queue_add_info, reshuffle, item_id, ret);
|
||||||
if (ret == 0)
|
if (ret == 0)
|
||||||
{
|
{
|
||||||
if (count)
|
if (count)
|
||||||
@ -1711,11 +1711,11 @@ queue_add_stream(const char *path, int position, int *count, int *new_item_id)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
queue_add(const char *uri, int position, int *count, int *new_item_id)
|
queue_add(const char *uri, int position, char reshuffle, uint32_t item_id, int *count, int *new_item_id)
|
||||||
{
|
{
|
||||||
if (strncasecmp(uri, "http://", strlen("http://")) == 0)
|
if (strncasecmp(uri, "http://", strlen("http://")) == 0)
|
||||||
{
|
{
|
||||||
queue_add_stream(uri, position, count, new_item_id);
|
queue_add_stream(uri, position, reshuffle, item_id, count, new_item_id);
|
||||||
return LIBRARY_OK;
|
return LIBRARY_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -997,7 +997,7 @@ map_track_to_queueitem(struct db_queue_item *item, const struct spotify_track *t
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
queue_add_track(const char *uri, int position, int *count, int *new_item_id)
|
queue_add_track(const char *uri, int position, char reshuffle, uint32_t item_id, int *count, int *new_item_id)
|
||||||
{
|
{
|
||||||
json_object *response;
|
json_object *response;
|
||||||
struct spotify_track track;
|
struct spotify_track track;
|
||||||
@ -1019,7 +1019,7 @@ queue_add_track(const char *uri, int position, int *count, int *new_item_id)
|
|||||||
if (ret == 0)
|
if (ret == 0)
|
||||||
{
|
{
|
||||||
ret = db_queue_add_item(&queue_add_info, &item);
|
ret = db_queue_add_item(&queue_add_info, &item);
|
||||||
ret = db_queue_add_end(&queue_add_info, ret);
|
ret = db_queue_add_end(&queue_add_info, reshuffle, item_id, ret);
|
||||||
if (ret == 0)
|
if (ret == 0)
|
||||||
{
|
{
|
||||||
if (count)
|
if (count)
|
||||||
@ -1068,7 +1068,7 @@ queue_add_album_tracks(json_object *item, int index, int total, void *arg)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
queue_add_album(const char *uri, int position, int *count, int *new_item_id)
|
queue_add_album(const char *uri, int position, char reshuffle, uint32_t item_id, int *count, int *new_item_id)
|
||||||
{
|
{
|
||||||
char *album_endpoint_uri = NULL;
|
char *album_endpoint_uri = NULL;
|
||||||
char *endpoint_uri = NULL;
|
char *endpoint_uri = NULL;
|
||||||
@ -1088,7 +1088,7 @@ queue_add_album(const char *uri, int position, int *count, int *new_item_id)
|
|||||||
|
|
||||||
ret = request_pagingobject_endpoint(endpoint_uri, queue_add_album_tracks, NULL, NULL, true, ¶m);
|
ret = request_pagingobject_endpoint(endpoint_uri, queue_add_album_tracks, NULL, NULL, true, ¶m);
|
||||||
|
|
||||||
ret = db_queue_add_end(¶m.queue_add_info, ret);
|
ret = db_queue_add_end(¶m.queue_add_info, reshuffle, item_id, ret);
|
||||||
if (ret == 0 && count)
|
if (ret == 0 && count)
|
||||||
*count = param.queue_add_info.count;
|
*count = param.queue_add_info.count;
|
||||||
|
|
||||||
@ -1137,7 +1137,7 @@ queue_add_playlist_tracks(json_object *item, int index, int total, void *arg)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
queue_add_playlist(const char *uri, int position, int *count, int *new_item_id)
|
queue_add_playlist(const char *uri, int position, char reshuffle, uint32_t item_id, int *count, int *new_item_id)
|
||||||
{
|
{
|
||||||
char *endpoint_uri;
|
char *endpoint_uri;
|
||||||
struct db_queue_add_info queue_add_info;
|
struct db_queue_add_info queue_add_info;
|
||||||
@ -1151,7 +1151,7 @@ queue_add_playlist(const char *uri, int position, int *count, int *new_item_id)
|
|||||||
|
|
||||||
ret = request_pagingobject_endpoint(endpoint_uri, queue_add_playlist_tracks, NULL, NULL, true, &queue_add_info);
|
ret = request_pagingobject_endpoint(endpoint_uri, queue_add_playlist_tracks, NULL, NULL, true, &queue_add_info);
|
||||||
|
|
||||||
ret = db_queue_add_end(&queue_add_info, ret);
|
ret = db_queue_add_end(&queue_add_info, reshuffle, item_id, ret);
|
||||||
if (ret == 0 && count)
|
if (ret == 0 && count)
|
||||||
*count = queue_add_info.count;
|
*count = queue_add_info.count;
|
||||||
|
|
||||||
@ -1161,21 +1161,21 @@ queue_add_playlist(const char *uri, int position, int *count, int *new_item_id)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
queue_add(const char *uri, int position, int *count, int *new_item_id)
|
queue_add(const char *uri, int position, char reshuffle, uint32_t item_id, int *count, int *new_item_id)
|
||||||
{
|
{
|
||||||
if (strncasecmp(uri, "spotify:track:", strlen("spotify:track:")) == 0)
|
if (strncasecmp(uri, "spotify:track:", strlen("spotify:track:")) == 0)
|
||||||
{
|
{
|
||||||
queue_add_track(uri, position, count, new_item_id);
|
queue_add_track(uri, position, reshuffle, item_id, count, new_item_id);
|
||||||
return LIBRARY_OK;
|
return LIBRARY_OK;
|
||||||
}
|
}
|
||||||
else if (strncasecmp(uri, "spotify:album:", strlen("spotify:album:")) == 0)
|
else if (strncasecmp(uri, "spotify:album:", strlen("spotify:album:")) == 0)
|
||||||
{
|
{
|
||||||
queue_add_album(uri, position, count, new_item_id);
|
queue_add_album(uri, position, reshuffle, item_id, count, new_item_id);
|
||||||
return LIBRARY_OK;
|
return LIBRARY_OK;
|
||||||
}
|
}
|
||||||
else if (strncasecmp(uri, "spotify:", strlen("spotify:")) == 0)
|
else if (strncasecmp(uri, "spotify:", strlen("spotify:")) == 0)
|
||||||
{
|
{
|
||||||
queue_add_playlist(uri, position, count, new_item_id);
|
queue_add_playlist(uri, position, reshuffle, item_id, count, new_item_id);
|
||||||
return LIBRARY_OK;
|
return LIBRARY_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user