[db/player] Icy metadata update

This commit is contained in:
chme 2016-11-12 13:23:41 +01:00
parent e08b4f3b01
commit a0590ce548
3 changed files with 28 additions and 26 deletions

View File

@ -2734,27 +2734,6 @@ db_file_update(struct media_file_info *mfi)
#undef Q_TMPL
}
void
db_file_update_icy(int id, char *artist, char *album)
{
#define Q_TMPL "UPDATE files SET artist = TRIM(%Q), album = TRIM(%Q) WHERE id = %d;"
char *query;
if (id == 0)
return;
query = sqlite3_mprintf(Q_TMPL, artist, album, id);
if (!query)
{
DPRINTF(E_LOG, L_DB, "Out of memory for query string\n");
return;
}
db_query_run(query, 1, 0);
#undef Q_TMPL
}
void
db_file_save_seek(int id, uint32_t seek)
{
@ -4290,6 +4269,29 @@ queue_inc_version_and_notify()
listener_notify(LISTENER_PLAYLIST);
}
void
db_queue_update_icymetadata(int id, char *artist, char *album)
{
#define Q_TMPL "UPDATE queue SET artist = TRIM(%Q), album = TRIM(%Q) WHERE id = %d;"
char *query;
if (id == 0)
return;
query = sqlite3_mprintf(Q_TMPL, artist, album, id);
if (!query)
{
DPRINTF(E_LOG, L_DB, "Out of memory for query string\n");
return;
}
db_query_run(query, 1, 0);
queue_inc_version_and_notify();
#undef Q_TMPL
}
static int
queue_add_mediafileinfo(struct db_media_file_info *dbmfi, int pos, int shuffle_pos)
{

View File

@ -561,9 +561,6 @@ db_file_add(struct media_file_info *mfi);
int
db_file_update(struct media_file_info *mfi);
void
db_file_update_icy(int id, char *artist, char *album);
void
db_file_save_seek(int id, uint32_t seek);
@ -713,6 +710,9 @@ db_speaker_clear_all(void);
int
db_queue_get_version();
void
db_queue_update_icymetadata(int id, char *artist, char *album);
int
db_queue_add_by_queryafteritemid(struct query_params *qp, uint32_t item_id);

View File

@ -520,7 +520,7 @@ update_icy_cb(void *arg)
{
struct http_icy_metadata *metadata = arg;
db_file_update_icy(metadata->id, metadata->artist, metadata->title);
db_queue_update_icymetadata(metadata->id, metadata->artist, metadata->title);
http_icy_metadata_free(metadata, 1);
}
@ -579,7 +579,7 @@ metadata_check_icy(void)
if (metadata->title[0] == '\0')
goto no_update;
metadata->id = cur_streaming->id;
metadata->id = cur_streaming->item_id;
/* Defer the database update to the worker thread */
worker_execute(update_icy_cb, metadata, sizeof(struct http_icy_metadata), 0);