mirror of
https://github.com/owntone/owntone-server.git
synced 2024-12-28 08:05:56 -05:00
[db] schema v20.01 support codec type/bitrate/samplerate in queue tbl
This commit is contained in:
parent
f03d96f152
commit
c796db251d
13
src/db.c
13
src/db.c
@ -273,6 +273,9 @@ static const struct col_type_map qi_cols_map[] =
|
||||
{ "queue_version", qi_offsetof(queue_version), DB_TYPE_INT },
|
||||
{ "composer", qi_offsetof(composer), DB_TYPE_STRING, DB_FIXUP_COMPOSER },
|
||||
{ "songartistid", qi_offsetof(songartistid), DB_TYPE_INT64 },
|
||||
{ "type", qi_offsetof(type), DB_TYPE_STRING, DB_FIXUP_CODECTYPE },
|
||||
{ "bitrate", qi_offsetof(bitrate), DB_TYPE_INT },
|
||||
{ "samplerate", qi_offsetof(samplerate), DB_TYPE_INT },
|
||||
};
|
||||
|
||||
/* This list must be kept in sync with
|
||||
@ -704,6 +707,7 @@ free_queue_item(struct db_queue_item *queue_item, int content_only)
|
||||
free(queue_item->album_sort);
|
||||
free(queue_item->album_artist_sort);
|
||||
free(queue_item->artwork_url);
|
||||
free(queue_item->type);
|
||||
|
||||
if (!content_only)
|
||||
free(queue_item);
|
||||
@ -4640,12 +4644,14 @@ queue_add_file(struct db_media_file_info *dbmfi, int pos, int shuffle_pos, int q
|
||||
"pos, shuffle_pos, path, virtual_path, title, " \
|
||||
"artist, composer, album_artist, album, genre, songalbumid, songartistid," \
|
||||
"time_modified, artist_sort, album_sort, album_artist_sort, year, " \
|
||||
"type, bitrate, samplerate, " \
|
||||
"track, disc, queue_version)" \
|
||||
"VALUES" \
|
||||
"(NULL, %s, %s, %s, %s, " \
|
||||
"%d, %d, %Q, %Q, %Q, " \
|
||||
"%Q, %Q, %Q, %Q, %Q, %s, %s," \
|
||||
"%s, %Q, %Q, %Q, %s, " \
|
||||
"%Q, %s, %s, " \
|
||||
"%s, %s, %d);"
|
||||
|
||||
char *query;
|
||||
@ -4656,6 +4662,7 @@ queue_add_file(struct db_media_file_info *dbmfi, int pos, int shuffle_pos, int q
|
||||
pos, shuffle_pos, dbmfi->path, dbmfi->virtual_path, dbmfi->title,
|
||||
dbmfi->artist, dbmfi->composer, dbmfi->album_artist, dbmfi->album, dbmfi->genre, dbmfi->songalbumid, dbmfi->songartistid,
|
||||
dbmfi->time_modified, dbmfi->artist_sort, dbmfi->album_sort, dbmfi->album_artist_sort, dbmfi->year,
|
||||
dbmfi->type, dbmfi->bitrate, dbmfi->samplerate,
|
||||
dbmfi->track, dbmfi->disc, queue_version);
|
||||
ret = db_query_run(query, 1, 0);
|
||||
|
||||
@ -4672,12 +4679,14 @@ queue_add_item(struct db_queue_item *item, int pos, int shuffle_pos, int queue_v
|
||||
"pos, shuffle_pos, path, virtual_path, title, " \
|
||||
"artist, composer, album_artist, album, genre, songalbumid, songartistid, " \
|
||||
"time_modified, artist_sort, album_sort, album_artist_sort, year, " \
|
||||
"type, bitrate, samplerate, " \
|
||||
"track, disc, artwork_url, queue_version)" \
|
||||
"VALUES" \
|
||||
"(NULL, %d, %d, %d, %d, " \
|
||||
"%d, %d, %Q, %Q, %Q, " \
|
||||
"%Q, %Q, %Q, %Q, %Q, %" PRIi64 ", %" PRIi64 "," \
|
||||
"%d, %Q, %Q, %Q, %d, " \
|
||||
"%Q, %" PRIu32 ", %" PRIu32 ", " \
|
||||
"%d, %d, %Q, %d);"
|
||||
|
||||
char *query;
|
||||
@ -4688,6 +4697,7 @@ queue_add_item(struct db_queue_item *item, int pos, int shuffle_pos, int queue_v
|
||||
pos, shuffle_pos, item->path, item->virtual_path, item->title,
|
||||
item->artist, item->composer, item->album_artist, item->album, item->genre, item->songalbumid, item->songartistid,
|
||||
item->time_modified, item->artist_sort, item->album_sort, item->album_artist_sort, item->year,
|
||||
item->type, item->bitrate, item->samplerate,
|
||||
item->track, item->disc, item->artwork_url, queue_version);
|
||||
ret = db_query_run(query, 1, 0);
|
||||
|
||||
@ -5116,6 +5126,9 @@ queue_enum_fetch(struct query_params *qp, struct db_queue_item *queue_item, int
|
||||
queue_item->artwork_url = strdup_if((char *)sqlite3_column_text(qp->stmt, 22), keep_item);
|
||||
queue_item->composer = strdup_if((char *)sqlite3_column_text(qp->stmt, 24), keep_item);
|
||||
queue_item->songartistid = sqlite3_column_int64(qp->stmt, 25);
|
||||
queue_item->type = strdup_if((char *)sqlite3_column_text(qp->stmt, 26), keep_item);
|
||||
queue_item->bitrate = sqlite3_column_int(qp->stmt, 27);
|
||||
queue_item->samplerate = sqlite3_column_int(qp->stmt, 28);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
4
src/db.h
4
src/db.h
@ -469,6 +469,10 @@ struct db_queue_item {
|
||||
|
||||
char *composer;
|
||||
|
||||
char *type;
|
||||
uint32_t bitrate;
|
||||
uint32_t samplerate;
|
||||
|
||||
int64_t songartistid;
|
||||
|
||||
/* Not saved in queue table */
|
||||
|
@ -192,7 +192,10 @@
|
||||
" artwork_url VARCHAR(4096) DEFAULT NULL," \
|
||||
" queue_version INTEGER DEFAULT 0," \
|
||||
" composer VARCHAR(1024) DEFAULT NULL," \
|
||||
" songartistid INTEGER NOT NULL" \
|
||||
" songartistid INTEGER NOT NULL," \
|
||||
" type VARCHAR(8) DEFAULT NULL," \
|
||||
" bitrate INTEGER DEFAULT 0," \
|
||||
" samplerate INTEGER DEFAULT 0" \
|
||||
");"
|
||||
|
||||
#define Q_PL1 \
|
||||
|
@ -26,7 +26,7 @@
|
||||
* is a major upgrade. In other words minor version upgrades permit downgrading
|
||||
* forked-daapd after the database was upgraded. */
|
||||
#define SCHEMA_VERSION_MAJOR 21
|
||||
#define SCHEMA_VERSION_MINOR 00
|
||||
#define SCHEMA_VERSION_MINOR 01
|
||||
|
||||
int
|
||||
db_init_indices(sqlite3 *hdl);
|
||||
|
@ -995,6 +995,25 @@ static const struct db_upgrade_query db_upgrade_v2100_queries[] =
|
||||
{ U_V2100_SCVER_MINOR, "set schema_version_minor to 00" },
|
||||
};
|
||||
|
||||
#define U_v2101_ALTER_QUEUE_ADD_TYPE \
|
||||
"ALTER TABLE queue ADD COLUMN type VARCHAR(8) DEFAULT NULL;"
|
||||
#define U_v2101_ALTER_QUEUE_ADD_BITRATE \
|
||||
"ALTER TABLE queue ADD COLUMN bitrate INTEGER DEFAULT 0;"
|
||||
#define U_v2101_ALTER_QUEUE_ADD_SAMPLERATE \
|
||||
"ALTER TABLE queue ADD COLUMN samplerate INTEGER DEFAULT 0;"
|
||||
|
||||
#define U_v2101_SCVER_MINOR \
|
||||
"UPDATE admin SET value = '01' WHERE key = 'schema_version_minor';"
|
||||
|
||||
static const struct db_upgrade_query db_upgrade_v2101_queries[] =
|
||||
{
|
||||
{ U_v2101_ALTER_QUEUE_ADD_TYPE, "alter table queue add column type" },
|
||||
{ U_v2101_ALTER_QUEUE_ADD_BITRATE, "alter table queue add column bitrate" },
|
||||
{ U_v2101_ALTER_QUEUE_ADD_SAMPLERATE, "alter table queue add column samplerate" },
|
||||
|
||||
{ U_v2101_SCVER_MINOR, "set schema_version_minor to 01" },
|
||||
};
|
||||
|
||||
|
||||
int
|
||||
db_upgrade(sqlite3 *hdl, int db_ver)
|
||||
@ -1143,6 +1162,13 @@ db_upgrade(sqlite3 *hdl, int db_ver)
|
||||
if (ret < 0)
|
||||
return -1;
|
||||
|
||||
/* FALLTHROUGH */
|
||||
|
||||
case 2100:
|
||||
ret = db_generic_upgrade(hdl, db_upgrade_v2101_queries, ARRAY_SIZE(db_upgrade_v2101_queries));
|
||||
if (ret < 0)
|
||||
return -1;
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
|
Loading…
Reference in New Issue
Block a user