From 95fb65527f2f45f1855fb211ea4ca384db38d2a3 Mon Sep 17 00:00:00 2001 From: Christopher Snowhill Date: Mon, 7 Feb 2022 01:11:30 -0800 Subject: [PATCH] Playlist Entry / SQLite: Add channel config field Add channel config field to PlaylistEntry and the SQLite backing store. Signed-off-by: Christopher Snowhill --- Playlist/PlaylistEntry.h | 2 ++ Playlist/PlaylistEntry.m | 2 ++ Utils/SQLiteStore.m | 26 ++++++++++++++++++++++---- 3 files changed, 26 insertions(+), 4 deletions(-) diff --git a/Playlist/PlaylistEntry.h b/Playlist/PlaylistEntry.h index d2916da77..8e019c907 100644 --- a/Playlist/PlaylistEntry.h +++ b/Playlist/PlaylistEntry.h @@ -51,6 +51,7 @@ long long totalFrames; int bitrate; int channels; + uint32_t channelConfig; int bitsPerSample; BOOL floatingPoint; BOOL Unsigned; @@ -138,6 +139,7 @@ @property long long totalFrames; @property int bitrate; @property int channels; +@property uint32_t channelConfig; @property int bitsPerSample; @property BOOL floatingPoint; @property BOOL Unsigned; diff --git a/Playlist/PlaylistEntry.m b/Playlist/PlaylistEntry.m index add7136d8..08989f3b6 100644 --- a/Playlist/PlaylistEntry.m +++ b/Playlist/PlaylistEntry.m @@ -42,6 +42,7 @@ @synthesize totalFrames; @synthesize bitrate; @synthesize channels; +@synthesize channelConfig; @synthesize bitsPerSample; @synthesize floatingPoint; @synthesize Unsigned; @@ -491,6 +492,7 @@ pe->totalFrames = totalFrames; pe->bitrate = bitrate; pe->channels = channels; + pe->channelConfig = channelConfig; pe->bitsPerSample = bitsPerSample; pe->floatingPoint = floatingPoint; pe->Unsigned = Unsigned; diff --git a/Utils/SQLiteStore.m b/Utils/SQLiteStore.m index 219dea6c5..6dec23726 100644 --- a/Utils/SQLiteStore.m +++ b/Utils/SQLiteStore.m @@ -16,7 +16,7 @@ NSString *getDatabasePath(void) { return [basePath stringByAppendingPathComponent:filename]; } -static int64_t currentSchemaVersion = 1; +static int64_t currentSchemaVersion = 2; NSArray *createSchema(void) { return @[ @@ -50,6 +50,7 @@ NSArray *createSchema(void) { samplerate REAL, \ bitspersample INTEGER, \ channels INTEGER, \ + channelconfig INTEGER, \ endianid INTEGER, \ floatingpoint INTEGER, \ totalframes INTEGER, \ @@ -264,6 +265,7 @@ enum { select_track_data_out_samplerate, select_track_data_out_bitspersample, select_track_data_out_channels, + select_track_data_out_channelconfig, select_track_data_out_endian_id, select_track_data_out_floatingpoint, select_track_data_out_totalframes, @@ -276,7 +278,7 @@ enum { select_track_data_out_replaygaintrackpeak, }; -const char *query_select_track_data = "SELECT urlid, artid, albumid, albumartistid, artistid, titleid, genreid, codecid, cuesheetid, encodingid, track, year, unsigned, bitrate, samplerate, bitspersample, channels, endianid, floatingpoint, totalframes, metadataloaded, seekable, volume, replaygainalbumgain, replaygainalbumpeak, replaygaintrackgain, replaygaintrackpeak FROM knowntracks WHERE (trackid = ?) LIMIT 1"; +const char *query_select_track_data = "SELECT urlid, artid, albumid, albumartistid, artistid, titleid, genreid, codecid, cuesheetid, encodingid, track, year, unsigned, bitrate, samplerate, bitspersample, channels, channelconfig, endianid, floatingpoint, totalframes, metadataloaded, seekable, volume, replaygainalbumgain, replaygainalbumpeak, replaygaintrackgain, replaygaintrackpeak FROM knowntracks WHERE (trackid = ?) LIMIT 1"; enum { bump_track_in_id = 1, @@ -308,6 +310,7 @@ enum { add_track_in_samplerate, add_track_in_bitspersample, add_track_in_channels, + add_track_in_channelconfig, add_track_in_endian_id, add_track_in_floatingpoint, add_track_in_totalframes, @@ -320,7 +323,7 @@ enum { add_track_in_replaygaintrackpeak, }; -const char *query_add_track = "INSERT INTO knowntracks (referencecount, urlid, artid, albumid, albumartistid, artistid, titleid, genreid, codecid, cuesheetid, encodingid, track, year, unsigned, bitrate, samplerate, bitspersample, channels, endianid, floatingpoint, totalframes, metadataloaded, seekable, volume, replaygainalbumgain, replaygainalbumpeak, replaygaintrackgain, replaygaintrackpeak) VALUES (1, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"; +const char *query_add_track = "INSERT INTO knowntracks (referencecount, urlid, artid, albumid, albumartistid, artistid, titleid, genreid, codecid, cuesheetid, encodingid, track, year, unsigned, bitrate, samplerate, bitspersample, channels, channelconfig, endianid, floatingpoint, totalframes, metadataloaded, seekable, volume, replaygainalbumgain, replaygainalbumpeak, replaygaintrackgain, replaygaintrackpeak) VALUES (1, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"; enum { remove_track_in_id = 1, @@ -346,6 +349,7 @@ enum { update_track_in_samplerate, update_track_in_bitspersample, update_track_in_channels, + update_track_in_channelconfig, update_track_in_endian_id, update_track_in_floatingpoint, update_track_in_totalframes, @@ -359,7 +363,7 @@ enum { update_track_in_id }; -const char *query_update_track = "UPDATE knowntracks SET urlid = ?, artid = ?, albumid = ?, albumartistid = ?, artistid = ?, titleid = ?, genreid = ?, codecid = ?, cuesheetid = ?, encodingid = ?, track = ?, year = ?, unsigned = ?, bitrate = ?, samplerate = ?, bitspersample = ?, channels = ?, endianid = ?, floatingpoint = ?, totalframes = ?, metadataloaded = ?, seekable = ?, volume = ?, replaygainalbumgain = ?, replaygainalbumpeak = ?, replaygaintrackgain = ?, replaygaintrackpeak = ? WHERE trackid = ?"; +const char *query_update_track = "UPDATE knowntracks SET urlid = ?, artid = ?, albumid = ?, albumartistid = ?, artistid = ?, titleid = ?, genreid = ?, codecid = ?, cuesheetid = ?, encodingid = ?, track = ?, year = ?, unsigned = ?, bitrate = ?, samplerate = ?, bitspersample = ?, channels = ?, channelconfig = ?, endianid = ?, floatingpoint = ?, totalframes = ?, metadataloaded = ?, seekable = ?, volume = ?, replaygainalbumgain = ?, replaygainalbumpeak = ?, replaygaintrackgain = ?, replaygaintrackpeak = ? WHERE trackid = ?"; enum { select_playlist_in_id = 1, @@ -595,6 +599,14 @@ static SQLiteStore *g_sharedStore = NULL; } break; + case 1: + // Schema 1 to 2: Add channelconfig integer field to the knowntracks table + if(sqlite3_exec(g_database, "ALTER TABLE knowntracks ADD channelconfig INTEGER", NULL, NULL, &error)) { + DLog(@"SQLite error: %s", error); + return nil; + } + break; + default: break; } @@ -999,6 +1011,7 @@ static SQLiteStore *g_sharedStore = NULL; double samplerate = [track sampleRate]; int64_t bitspersample = [track bitsPerSample]; int64_t channels = [track channels]; + int64_t channelConfig = [track channelConfig]; int64_t endianId = [self addString:[track endian]]; int64_t floatingpoint = [track floatingPoint]; int64_t totalframes = [track totalFrames]; @@ -1036,6 +1049,7 @@ static SQLiteStore *g_sharedStore = NULL; sqlite3_bind_double(st, add_track_in_samplerate, samplerate) || sqlite3_bind_int64(st, add_track_in_bitspersample, bitspersample) || sqlite3_bind_int64(st, add_track_in_channels, channels) || + sqlite3_bind_int64(st, add_track_in_channelconfig, channelConfig) || sqlite3_bind_int64(st, add_track_in_endian_id, endianId) || sqlite3_bind_int64(st, add_track_in_floatingpoint, floatingpoint) || sqlite3_bind_int64(st, add_track_in_totalframes, totalframes) || @@ -1192,6 +1206,7 @@ static SQLiteStore *g_sharedStore = NULL; double samplerate = [track sampleRate]; int64_t bitspersample = [track bitsPerSample]; int64_t channels = [track channels]; + int64_t channelConfig = [track channelConfig]; int64_t endianId = [self addString:[track endian]]; int64_t floatingpoint = [track floatingPoint]; int64_t totalframes = [track totalFrames]; @@ -1229,6 +1244,7 @@ static SQLiteStore *g_sharedStore = NULL; sqlite3_bind_double(st, update_track_in_samplerate, samplerate) || sqlite3_bind_int64(st, update_track_in_bitspersample, bitspersample) || sqlite3_bind_int64(st, update_track_in_channels, channels) || + sqlite3_bind_int64(st, update_track_in_channelconfig, channelConfig) || sqlite3_bind_int64(st, update_track_in_endian_id, endianId) || sqlite3_bind_int64(st, update_track_in_floatingpoint, floatingpoint) || sqlite3_bind_int64(st, update_track_in_totalframes, totalframes) || @@ -1301,6 +1317,7 @@ static SQLiteStore *g_sharedStore = NULL; double samplerate = sqlite3_column_double(st, select_track_data_out_samplerate); int64_t bitspersample = sqlite3_column_int64(st, select_track_data_out_bitspersample); int64_t channels = sqlite3_column_int64(st, select_track_data_out_channels); + int64_t channelConfig = sqlite3_column_int64(st, select_track_data_out_channelconfig); int64_t endianId = sqlite3_column_int64(st, select_track_data_out_endian_id); int64_t floatingpoint = sqlite3_column_int64(st, select_track_data_out_floatingpoint); int64_t totalframes = sqlite3_column_int64(st, select_track_data_out_totalframes); @@ -1333,6 +1350,7 @@ static SQLiteStore *g_sharedStore = NULL; [entry setSampleRate:samplerate]; [entry setBitsPerSample:(int)bitspersample]; [entry setChannels:(int)channels]; + [entry setChannelConfig:(uint32_t)channelConfig]; [entry setEndian:[self getString:endianId]]; [entry setFloatingPoint:!!floatingpoint]; [entry setTotalFrames:totalframes];