[player] Only update queue item in metadata_update_cb on changed

metadata. This avoids an unnecessary update query and queue change
notification (leading to clients requesting the unchanged queue).
This commit is contained in:
chme 2017-12-09 10:40:30 +01:00
parent 2ee02d407b
commit 0b07cff633
1 changed files with 23 additions and 19 deletions

View File

@ -385,26 +385,30 @@ metadata_update_cb(void *arg)
goto out_free_metadata;
}
// Since we won't be using the metadata struct values for anything else than
// this we just swap pointers
if (metadata->artist)
swap_pointers(&queue_item->artist, &metadata->artist);
if (metadata->title)
swap_pointers(&queue_item->title, &metadata->title);
if (metadata->album)
swap_pointers(&queue_item->album, &metadata->album);
if (metadata->genre)
swap_pointers(&queue_item->genre, &metadata->genre);
if (metadata->artwork_url)
swap_pointers(&queue_item->artwork_url, &metadata->artwork_url);
if (metadata->song_length)
queue_item->song_length = metadata->song_length;
ret = db_queue_update_item(queue_item);
if (ret < 0)
// Update queue item if metadata changed
if (metadata->artist || metadata->title || metadata->album || metadata->genre || metadata->artwork_url || metadata->song_length)
{
DPRINTF(E_LOG, L_PLAYER, "Database error while updating queue with new metadata\n");
goto out_free_queueitem;
// Since we won't be using the metadata struct values for anything else than
// this we just swap pointers
if (metadata->artist)
swap_pointers(&queue_item->artist, &metadata->artist);
if (metadata->title)
swap_pointers(&queue_item->title, &metadata->title);
if (metadata->album)
swap_pointers(&queue_item->album, &metadata->album);
if (metadata->genre)
swap_pointers(&queue_item->genre, &metadata->genre);
if (metadata->artwork_url)
swap_pointers(&queue_item->artwork_url, &metadata->artwork_url);
if (metadata->song_length)
queue_item->song_length = metadata->song_length;
ret = db_queue_update_item(queue_item);
if (ret < 0)
{
DPRINTF(E_LOG, L_PLAYER, "Database error while updating queue with new metadata\n");
goto out_free_queueitem;
}
}
o_metadata = outputs_metadata_prepare(metadata->item_id);