mirror of
https://github.com/owntone/owntone-server.git
synced 2024-12-27 15:45:56 -05:00
Make player_queue_make() generic and introduce player_queue_make_daap()
This commit is contained in:
parent
2e6ed82e14
commit
055fe8f442
@ -716,7 +716,7 @@ dacp_reply_cue_play(struct evhttp_request *req, struct evbuffer *evbuf, char **u
|
|||||||
{
|
{
|
||||||
sort = evhttp_find_header(query, "sort");
|
sort = evhttp_find_header(query, "sort");
|
||||||
|
|
||||||
ps = player_queue_make(cuequery, sort);
|
ps = player_queue_make_daap(cuequery, sort);
|
||||||
if (!ps)
|
if (!ps)
|
||||||
{
|
{
|
||||||
DPRINTF(E_LOG, L_DACP, "Could not build song queue\n");
|
DPRINTF(E_LOG, L_DACP, "Could not build song queue\n");
|
||||||
|
68
src/player.c
68
src/player.c
@ -338,10 +338,9 @@ player_laudio_status_cb(enum laudio_state status)
|
|||||||
|
|
||||||
/* Audio sources */
|
/* Audio sources */
|
||||||
/* Thread: httpd (DACP) */
|
/* Thread: httpd (DACP) */
|
||||||
struct player_source *
|
static struct player_source *
|
||||||
player_queue_make(const char *query, const char *sort)
|
player_queue_make(struct query_params *qp, const char *sort)
|
||||||
{
|
{
|
||||||
struct query_params qp;
|
|
||||||
struct db_media_file_info dbmfi;
|
struct db_media_file_info dbmfi;
|
||||||
struct player_source *q_head;
|
struct player_source *q_head;
|
||||||
struct player_source *q_tail;
|
struct player_source *q_tail;
|
||||||
@ -349,46 +348,30 @@ player_queue_make(const char *query, const char *sort)
|
|||||||
uint32_t id;
|
uint32_t id;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
memset(&qp, 0, sizeof(struct query_params));
|
qp->idx_type = I_NONE;
|
||||||
|
qp->sort = S_NONE;
|
||||||
qp.type = Q_ITEMS;
|
|
||||||
qp.offset = 0;
|
|
||||||
qp.limit = 0;
|
|
||||||
qp.idx_type = I_NONE;
|
|
||||||
qp.sort = S_NONE;
|
|
||||||
|
|
||||||
qp.filter = daap_query_parse_sql(query);
|
|
||||||
if (!qp.filter)
|
|
||||||
{
|
|
||||||
DPRINTF(E_LOG, L_PLAYER, "Improper DAAP query!\n");
|
|
||||||
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (sort)
|
if (sort)
|
||||||
{
|
{
|
||||||
if (strcmp(sort, "name") == 0)
|
if (strcmp(sort, "name") == 0)
|
||||||
qp.sort = S_NAME;
|
qp->sort = S_NAME;
|
||||||
else if (strcmp(sort, "album") == 0)
|
else if (strcmp(sort, "album") == 0)
|
||||||
qp.sort = S_ALBUM;
|
qp->sort = S_ALBUM;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = db_query_start(&qp);
|
ret = db_query_start(qp);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
DPRINTF(E_LOG, L_PLAYER, "Could not start query\n");
|
DPRINTF(E_LOG, L_PLAYER, "Could not start query\n");
|
||||||
|
|
||||||
if (qp.filter)
|
|
||||||
free(qp.filter);
|
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
DPRINTF(E_DBG, L_PLAYER, "Player queue query returned %d items\n", qp.results);
|
DPRINTF(E_DBG, L_PLAYER, "Player queue query returned %d items\n", qp->results);
|
||||||
|
|
||||||
q_head = NULL;
|
q_head = NULL;
|
||||||
q_tail = NULL;
|
q_tail = NULL;
|
||||||
while (((ret = db_query_fetch_file(&qp, &dbmfi)) == 0) && (dbmfi.id))
|
while (((ret = db_query_fetch_file(qp, &dbmfi)) == 0) && (dbmfi.id))
|
||||||
{
|
{
|
||||||
ret = safe_atou32(dbmfi.id, &id);
|
ret = safe_atou32(dbmfi.id, &id);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
@ -428,10 +411,7 @@ player_queue_make(const char *query, const char *sort)
|
|||||||
DPRINTF(E_DBG, L_PLAYER, "Added song id %d (%s)\n", id, dbmfi.title);
|
DPRINTF(E_DBG, L_PLAYER, "Added song id %d (%s)\n", id, dbmfi.title);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (qp.filter)
|
db_query_end(qp);
|
||||||
free(qp.filter);
|
|
||||||
|
|
||||||
db_query_end(&qp);
|
|
||||||
|
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
@ -449,6 +429,34 @@ player_queue_make(const char *query, const char *sort)
|
|||||||
return q_head;
|
return q_head;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Thread: httpd (DACP) */
|
||||||
|
struct player_source *
|
||||||
|
player_queue_make_daap(const char *query, const char *sort)
|
||||||
|
{
|
||||||
|
struct query_params qp;
|
||||||
|
struct player_source *ps;
|
||||||
|
|
||||||
|
memset(&qp, 0, sizeof(struct query_params));
|
||||||
|
|
||||||
|
qp.type = Q_ITEMS;
|
||||||
|
qp.offset = 0;
|
||||||
|
qp.limit = 0;
|
||||||
|
|
||||||
|
qp.filter = daap_query_parse_sql(query);
|
||||||
|
if (!qp.filter)
|
||||||
|
{
|
||||||
|
DPRINTF(E_LOG, L_PLAYER, "Improper DAAP query!\n");
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
ps = player_queue_make(&qp, sort);
|
||||||
|
|
||||||
|
free(qp.filter);
|
||||||
|
|
||||||
|
return ps;
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
source_free(struct player_source *ps)
|
source_free(struct player_source *ps)
|
||||||
{
|
{
|
||||||
|
@ -95,7 +95,7 @@ player_shuffle_set(int enable);
|
|||||||
|
|
||||||
|
|
||||||
struct player_source *
|
struct player_source *
|
||||||
player_queue_make(const char *query, const char *sort);
|
player_queue_make_daap(const char *query, const char *sort);
|
||||||
|
|
||||||
int
|
int
|
||||||
player_queue_add(struct player_source *ps);
|
player_queue_add(struct player_source *ps);
|
||||||
|
Loading…
Reference in New Issue
Block a user