[db] Generic fixup + align fixing up between mfi, pli and queue_item

The idea here is to make sure the fixing up of tags is done in a consistent
manner. For strings, this means stuff like trimming and empty strings -> null
are applied the same unless there are special exception rules set. It also
means that defaults are applied the same across structs, e.g. "Unknown artist"
for both mfi->artist and queue_item->artist.

The change is also necessary because we want to remove trimming from the sql
query and instead implement it ourselves.
This commit is contained in:
ejurgensen
2018-12-28 19:10:17 +01:00
parent fc5a66f86d
commit 1de8f39264
5 changed files with 361 additions and 292 deletions

View File

@@ -425,8 +425,7 @@ struct directory_enum {
void *stmt;
};
struct db_queue_item
{
struct db_queue_item {
/* A unique id for this queue item. If the same item appears multiple
times in the queue each corresponding queue item has its own id. */
uint32_t id;
@@ -434,18 +433,16 @@ struct db_queue_item
/* Id of the file/item in the files database */
uint32_t file_id;
/* Length of the item in ms */
uint32_t song_length;
uint32_t pos;
uint32_t shuffle_pos;
/* Data type of the item */
enum data_kind data_kind;
/* Media type of the item */
enum media_kind media_kind;
uint32_t seek;
uint32_t pos;
uint32_t shuffle_pos;
/* Length of the item in ms */
uint32_t song_length;
char *path;
char *virtual_path;
@@ -453,7 +450,6 @@ struct db_queue_item
char *title;
char *artist;
char *album_artist;
char *composer;
char *album;
char *genre;
@@ -471,8 +467,15 @@ struct db_queue_item
char *artwork_url;
uint32_t queue_version;
char *composer;
/* Not saved in queue table */
uint32_t seek;
};
#define qi_offsetof(field) offsetof(struct db_queue_item, field)
struct db_queue_add_info
{
int queue_version;
@@ -510,12 +513,6 @@ free_query_params(struct query_params *qp, int content_only);
void
free_queue_item(struct db_queue_item *queue_item, int content_only);
void
unicode_fixup_mfi(struct media_file_info *mfi);
void
fixup_tags_mfi(struct media_file_info *mfi);
/* Maintenance and DB hygiene */
void
db_hook_post_scan(void);