From a0590ce548181713fb43a21b5209cf5508a214ad Mon Sep 17 00:00:00 2001 From: chme Date: Sat, 12 Nov 2016 13:23:41 +0100 Subject: [PATCH] [db/player] Icy metadata update --- src/db.c | 44 +++++++++++++++++++++++--------------------- src/db.h | 6 +++--- src/player.c | 4 ++-- 3 files changed, 28 insertions(+), 26 deletions(-) diff --git a/src/db.c b/src/db.c index f6b627d4..d6298b42 100644 --- a/src/db.c +++ b/src/db.c @@ -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) { diff --git a/src/db.h b/src/db.h index 63652917..8c1e94c8 100644 --- a/src/db.h +++ b/src/db.h @@ -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); diff --git a/src/player.c b/src/player.c index ca3b8f63..88f3f0c0 100644 --- a/src/player.c +++ b/src/player.c @@ -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);