mirror of
https://github.com/owntone/owntone-server.git
synced 2024-12-25 22:55:56 -05:00
fixes for playqueue-contents
This commit is contained in:
parent
5f307c7ce1
commit
8036a5a6d3
@ -1146,6 +1146,11 @@ playqueuecontents_add_source(struct evbuffer *songlist, uint32_t source_id, int
|
|||||||
}
|
}
|
||||||
|
|
||||||
mfi = db_file_fetch_byid(source_id);
|
mfi = db_file_fetch_byid(source_id);
|
||||||
|
if (!mfi)
|
||||||
|
{
|
||||||
|
DPRINTF(E_LOG, L_DACP, "Could not fetch file id %d\n", source_id);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
dmap_add_container(song, "ceQs", 16);
|
dmap_add_container(song, "ceQs", 16);
|
||||||
dmap_add_raw_uint32(song, 1); /* Database */
|
dmap_add_raw_uint32(song, 1); /* Database */
|
||||||
dmap_add_raw_uint32(song, plid);
|
dmap_add_raw_uint32(song, plid);
|
||||||
@ -1167,7 +1172,6 @@ playqueuecontents_add_source(struct evbuffer *songlist, uint32_t source_id, int
|
|||||||
|
|
||||||
ret = evbuffer_add_buffer(songlist, song);
|
ret = evbuffer_add_buffer(songlist, song);
|
||||||
evbuffer_free(song);
|
evbuffer_free(song);
|
||||||
if (mfi)
|
|
||||||
free_mfi(mfi, 0);
|
free_mfi(mfi, 0);
|
||||||
|
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
@ -1246,10 +1250,9 @@ static void dacp_reply_playqueuecontents(struct evhttp_request *req, struct evbu
|
|||||||
{
|
{
|
||||||
start_index = (history->start_index + history->count - abs(span)) % MAX_HISTORY_COUNT;
|
start_index = (history->start_index + history->count - abs(span)) % MAX_HISTORY_COUNT;
|
||||||
}
|
}
|
||||||
for (i = 0; i < history->count && i < abs(span); i++)
|
for (n = 0; n < history->count && n < abs(span); n++)
|
||||||
{
|
{
|
||||||
n++;
|
ret = playqueuecontents_add_source(songlist, history->id[(start_index + n) % MAX_HISTORY_COUNT], (n + 1), status.plid);
|
||||||
ret = playqueuecontents_add_source(songlist, history->buffer[(start_index + i) % MAX_HISTORY_COUNT], (n + i + 1), status.plid);
|
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
DPRINTF(E_LOG, L_DACP, "Could not add song to songlist for playqueue-contents\n");
|
DPRINTF(E_LOG, L_DACP, "Could not add song to songlist for playqueue-contents\n");
|
||||||
@ -1286,6 +1289,7 @@ static void dacp_reply_playqueuecontents(struct evhttp_request *req, struct evbu
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Playlists are hist, curr and main. */
|
||||||
playlists = evbuffer_new();
|
playlists = evbuffer_new();
|
||||||
if (!playlists)
|
if (!playlists)
|
||||||
{
|
{
|
||||||
|
20
src/player.c
20
src/player.c
@ -1448,11 +1448,23 @@ player_history_get(void)
|
|||||||
static void
|
static void
|
||||||
history_add(uint32_t id)
|
history_add(uint32_t id)
|
||||||
{
|
{
|
||||||
unsigned int next_index = (history->start_index + history->count) % MAX_HISTORY_COUNT;
|
unsigned int cur_index;
|
||||||
|
unsigned int next_index;
|
||||||
|
|
||||||
|
/* Check if the current song is already the last in the history to avoid duplicates */
|
||||||
|
cur_index = (history->start_index + history->count - 1) % MAX_HISTORY_COUNT;
|
||||||
|
if (id == history->id[cur_index])
|
||||||
|
{
|
||||||
|
DPRINTF(E_LOG, L_PLAYER, "Current playing/streaming song already in history\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Calculate the next index and update the start-index and count for the id-buffer */
|
||||||
|
next_index = (history->start_index + history->count) % MAX_HISTORY_COUNT;
|
||||||
if (next_index == history->start_index && history->count > 0)
|
if (next_index == history->start_index && history->count > 0)
|
||||||
history->start_index = (history->start_index + 1) % MAX_HISTORY_COUNT;
|
history->start_index = (history->start_index + 1) % MAX_HISTORY_COUNT;
|
||||||
|
|
||||||
history->buffer[next_index] = id;
|
history->id[next_index] = id;
|
||||||
|
|
||||||
if (history->count < MAX_HISTORY_COUNT)
|
if (history->count < MAX_HISTORY_COUNT)
|
||||||
history->count++;
|
history->count++;
|
||||||
@ -2623,11 +2635,13 @@ playback_prev_bh(struct player_command *cmd)
|
|||||||
|
|
||||||
if (cur_playing)
|
if (cur_playing)
|
||||||
{
|
{
|
||||||
|
if (cur_playing->end > cur_playing->stream_start)
|
||||||
history_add(cur_playing->id);
|
history_add(cur_playing->id);
|
||||||
source_stop(cur_playing);
|
source_stop(cur_playing);
|
||||||
}
|
}
|
||||||
else if (cur_streaming)
|
else if (cur_streaming)
|
||||||
{
|
{
|
||||||
|
if (cur_streaming->end > cur_streaming->stream_start)
|
||||||
history_add(cur_streaming->id);
|
history_add(cur_streaming->id);
|
||||||
source_stop(cur_streaming);
|
source_stop(cur_streaming);
|
||||||
}
|
}
|
||||||
@ -2661,11 +2675,13 @@ playback_next_bh(struct player_command *cmd)
|
|||||||
|
|
||||||
if (cur_playing)
|
if (cur_playing)
|
||||||
{
|
{
|
||||||
|
if (cur_playing->end > cur_playing->stream_start)
|
||||||
history_add(cur_playing->id);
|
history_add(cur_playing->id);
|
||||||
source_stop(cur_playing);
|
source_stop(cur_playing);
|
||||||
}
|
}
|
||||||
else if (cur_streaming)
|
else if (cur_streaming)
|
||||||
{
|
{
|
||||||
|
if (cur_streaming->end > cur_streaming->stream_start)
|
||||||
history_add(cur_streaming->id);
|
history_add(cur_streaming->id);
|
||||||
source_stop(cur_streaming);
|
source_stop(cur_streaming);
|
||||||
}
|
}
|
||||||
|
@ -96,7 +96,7 @@ struct player_history
|
|||||||
unsigned int count;
|
unsigned int count;
|
||||||
|
|
||||||
/* Circular buffer of song ids previously played by forked-daapd */
|
/* Circular buffer of song ids previously played by forked-daapd */
|
||||||
uint32_t buffer[MAX_HISTORY_COUNT];
|
uint32_t id[MAX_HISTORY_COUNT];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user