[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");
|
||||
return NULL;
|
||||
}
|
||||
else if (queue_item->item_id == 0)
|
||||
{
|
||||
// No item found
|
||||
free_queue_item(queue_item, 0);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
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");
|
||||
return NULL;
|
||||
}
|
||||
else if (queue_item->item_id == 0)
|
||||
{
|
||||
// No item found
|
||||
free_queue_item(queue_item, 0);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
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");
|
||||
return NULL;
|
||||
}
|
||||
else if (queue_item->item_id == 0)
|
||||
{
|
||||
// No item found
|
||||
free_queue_item(queue_item, 0);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
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");
|
||||
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);
|
||||
|
||||
|
@ -5257,6 +5281,13 @@ db_queue_delete_byposrelativetoitem(uint32_t pos, uint32_t item_id, char shuffle
|
|||
db_transaction_rollback();
|
||||
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);
|
||||
|
||||
|
|
17
src/player.c
17
src/player.c
|
@ -1321,9 +1321,8 @@ source_next()
|
|||
else
|
||||
{
|
||||
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)
|
||||
{
|
||||
db_queue_reshuffle(0);
|
||||
|
@ -1336,11 +1335,16 @@ source_next()
|
|||
return NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -1412,11 +1416,6 @@ source_read(uint8_t *buf, int len, uint64_t rtptime)
|
|||
DPRINTF(E_DBG, L_PLAYER, "New file\n");
|
||||
|
||||
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)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue