mirror of
https://github.com/owntone/owntone-server.git
synced 2025-04-13 07:50:41 -04:00
[player] Fix segfault if player reaches end of queue, fix repeat single
This commit is contained in:
parent
a0590ce548
commit
6c66d39d91
31
src/db.c
31
src/db.c
@ -4805,6 +4805,12 @@ db_queue_fetch_byitemid(uint32_t item_id)
|
|||||||
DPRINTF(E_LOG, L_DB, "Error fetching queue item by item id\n");
|
DPRINTF(E_LOG, L_DB, "Error fetching queue item by item id\n");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
else if (queue_item->item_id == 0)
|
||||||
|
{
|
||||||
|
// No item found
|
||||||
|
free_queue_item(queue_item, 0);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
return queue_item;
|
return queue_item;
|
||||||
}
|
}
|
||||||
@ -4849,6 +4855,12 @@ db_queue_fetch_byfileid(uint32_t file_id)
|
|||||||
DPRINTF(E_LOG, L_DB, "Error fetching queue item by file id\n");
|
DPRINTF(E_LOG, L_DB, "Error fetching queue item by file id\n");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
else if (queue_item->item_id == 0)
|
||||||
|
{
|
||||||
|
// No item found
|
||||||
|
free_queue_item(queue_item, 0);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
return queue_item;
|
return queue_item;
|
||||||
}
|
}
|
||||||
@ -4902,6 +4914,12 @@ db_queue_fetch_bypos(uint32_t pos, char shuffle)
|
|||||||
DPRINTF(E_LOG, L_DB, "Error fetching queue item by pos id\n");
|
DPRINTF(E_LOG, L_DB, "Error fetching queue item by pos id\n");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
else if (queue_item->item_id == 0)
|
||||||
|
{
|
||||||
|
// No item found
|
||||||
|
free_queue_item(queue_item, 0);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
return queue_item;
|
return queue_item;
|
||||||
}
|
}
|
||||||
@ -4961,6 +4979,12 @@ db_queue_fetch_byposrelativetoitem(int pos, uint32_t item_id, char shuffle)
|
|||||||
DPRINTF(E_LOG, L_DB, "Error fetching queue item by pos relative to item id\n");
|
DPRINTF(E_LOG, L_DB, "Error fetching queue item by pos relative to item id\n");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
else if (queue_item->item_id == 0)
|
||||||
|
{
|
||||||
|
// No item found
|
||||||
|
free_queue_item(queue_item, 0);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
DPRINTF(E_DBG, L_DB, "Fetch by pos: fetched item (id=%d, pos=%d, file-id=%d)\n", queue_item->item_id, queue_item->pos, queue_item->file_id);
|
DPRINTF(E_DBG, L_DB, "Fetch by pos: fetched item (id=%d, pos=%d, file-id=%d)\n", queue_item->item_id, queue_item->pos, queue_item->file_id);
|
||||||
|
|
||||||
@ -5257,6 +5281,13 @@ db_queue_delete_byposrelativetoitem(uint32_t pos, uint32_t item_id, char shuffle
|
|||||||
db_transaction_rollback();
|
db_transaction_rollback();
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
else if (queue_item.item_id == 0)
|
||||||
|
{
|
||||||
|
// No item found
|
||||||
|
queue_enum_end(&queue_enum);
|
||||||
|
db_transaction_end();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
ret = queue_delete_item(&queue_item);
|
ret = queue_delete_item(&queue_item);
|
||||||
|
|
||||||
|
19
src/player.c
19
src/player.c
@ -1321,9 +1321,8 @@ source_next()
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
queue_item = db_queue_fetch_next(cur_streaming->item_id, shuffle);
|
queue_item = db_queue_fetch_next(cur_streaming->item_id, shuffle);
|
||||||
if (!!queue_item && repeat == REPEAT_ALL)
|
if (!queue_item && repeat == REPEAT_ALL)
|
||||||
{
|
{
|
||||||
free_queue_item(queue_item, 0);
|
|
||||||
if (shuffle)
|
if (shuffle)
|
||||||
{
|
{
|
||||||
db_queue_reshuffle(0);
|
db_queue_reshuffle(0);
|
||||||
@ -1336,11 +1335,16 @@ source_next()
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ps = source_new(queue_item);
|
|
||||||
free_queue_item(queue_item, 0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!queue_item)
|
||||||
|
{
|
||||||
|
DPRINTF(E_DBG, L_PLAYER, "Reached end of queue\n");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
ps = source_new(queue_item);
|
||||||
|
free_queue_item(queue_item, 0);
|
||||||
return ps;
|
return ps;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1412,11 +1416,6 @@ source_read(uint8_t *buf, int len, uint64_t rtptime)
|
|||||||
DPRINTF(E_DBG, L_PLAYER, "New file\n");
|
DPRINTF(E_DBG, L_PLAYER, "New file\n");
|
||||||
|
|
||||||
ps = source_next();
|
ps = source_next();
|
||||||
if (!ps)
|
|
||||||
{
|
|
||||||
DPRINTF(E_LOG, L_PLAYER, "Error fetching next item from queue %d\n", cur_streaming->id);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user