mirror of
https://github.com/owntone/owntone-server.git
synced 2024-12-27 23:55:57 -05:00
[dacp] Fix playing of radio streams after queue refactoring
This commit is contained in:
parent
f4faac3cc8
commit
c8a61015fc
@ -758,7 +758,6 @@ dacp_reply_ctrlint(struct evhttp_request *req, struct evbuffer *evbuf, char **ur
|
||||
static int
|
||||
find_first_song_id(const char *query)
|
||||
{
|
||||
//TODO [refactor][performance] Unnecessary query, it is enough to extract the item id from the query string. Accessing the db to verify the item exists is not needed.
|
||||
struct db_media_file_info dbmfi;
|
||||
struct query_params qp;
|
||||
int id;
|
||||
@ -1214,7 +1213,12 @@ dacp_reply_playspec(struct evhttp_request *req, struct evbuffer *evbuf, char **u
|
||||
|
||||
DPRINTF(E_DBG, L_DACP, "Playspec request for playlist %d, start song id %d%s\n", plid, pos, (shuffle) ? ", shuffle" : "");
|
||||
|
||||
items = queue_make_pl(plid); //TODO [queue] get queue-item-id or pos for first song to play (dacp) --- , &pos);
|
||||
items = NULL;
|
||||
if (plid > 0)
|
||||
items = queue_make_pl(plid);
|
||||
else if (pos > 0)
|
||||
items = queue_make_item(pos);
|
||||
|
||||
if (!items)
|
||||
{
|
||||
DPRINTF(E_LOG, L_DACP, "Could not build song queue from playlist %d\n", plid);
|
||||
|
@ -1527,7 +1527,6 @@ source_read(uint8_t *buf, int len, uint64_t rtptime)
|
||||
if (item)
|
||||
{
|
||||
ret = source_open(item, cur_streaming->end + 1, 0);
|
||||
|
||||
if (ret < 0)
|
||||
return -1;
|
||||
|
||||
|
42
src/queue.c
42
src/queue.c
@ -16,14 +16,16 @@
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
|
||||
#include "queue.h"
|
||||
|
||||
#include <inttypes.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "db.h"
|
||||
#include "logger.h"
|
||||
#include "misc.h"
|
||||
#include "queue.h"
|
||||
#include "rng.h"
|
||||
|
||||
|
||||
@ -1070,11 +1072,17 @@ queue_make(struct query_params *qp)
|
||||
return item_head;
|
||||
}
|
||||
|
||||
/*
|
||||
* Makes a list of queue-items for the given playlist id (plid)
|
||||
*
|
||||
* @param plid Id of the playlist
|
||||
* @return List of items for all playlist items
|
||||
*/
|
||||
struct queue_item *
|
||||
queue_make_pl(int plid)
|
||||
{
|
||||
struct query_params qp;
|
||||
struct queue_item *item;;
|
||||
struct queue_item *item;
|
||||
|
||||
memset(&qp, 0, sizeof(struct query_params));
|
||||
|
||||
@ -1089,3 +1097,31 @@ queue_make_pl(int plid)
|
||||
|
||||
return item;
|
||||
}
|
||||
|
||||
/*
|
||||
* Makes a queue-item for the item/file with the given id (dbmfi_id)
|
||||
*
|
||||
* @param dbmfi_id Id of the item/file
|
||||
* @return List of items containing only the item with the given id
|
||||
*/
|
||||
struct queue_item *
|
||||
queue_make_item(uint32_t dbmfi_id)
|
||||
{
|
||||
struct query_params qp;
|
||||
struct queue_item *item;
|
||||
char buf[124];
|
||||
|
||||
memset(&qp, 0, sizeof(struct query_params));
|
||||
|
||||
qp.id = 0;
|
||||
qp.type = Q_ITEMS;
|
||||
qp.offset = 0;
|
||||
qp.limit = 0;
|
||||
qp.sort = S_NONE;
|
||||
snprintf(buf, sizeof(buf), "f.id = %" PRIu32, dbmfi_id);
|
||||
qp.filter = strdup(buf);
|
||||
|
||||
item = queue_make(&qp);
|
||||
|
||||
return item;
|
||||
}
|
||||
|
@ -3,6 +3,8 @@
|
||||
#define SRC_QUEUE_H_
|
||||
|
||||
|
||||
#include "db.h"
|
||||
|
||||
enum repeat_mode {
|
||||
REPEAT_OFF = 0,
|
||||
REPEAT_SONG = 1,
|
||||
@ -126,4 +128,7 @@ queue_make(struct query_params *qp);
|
||||
struct queue_item *
|
||||
queue_make_pl(int plid);
|
||||
|
||||
struct queue_item *
|
||||
queue_make_item(uint32_t dbmfi_id);
|
||||
|
||||
#endif /* SRC_QUEUE_H_ */
|
||||
|
Loading…
Reference in New Issue
Block a user