From 0c4d5002f61d9cc38066adfb2684618f172e091b Mon Sep 17 00:00:00 2001 From: Christopher Snowhill Date: Fri, 21 Jan 2022 22:38:54 -0800 Subject: [PATCH] Metadata: Now supports storing cuesheet tags and encoding quality status properties --- Base.lproj/InfoInspector.xib | 81 ++++++++------ Playlist/PlaylistEntry.h | 4 + Playlist/PlaylistEntry.m | 4 + Plugins/AdPlug/AdPlug/AdPlugDecoder.mm | 1 + Plugins/CoreAudio/CoreAudioDecoder.m | 1 + Plugins/FFMPEG/FFMPEGDecoder.m | 1 + Plugins/Flac/FlacDecoder.m | 1 + Plugins/GME/GameDecoder.m | 1 + .../HighlyComplete/HCDecoder.mm | 1 + Plugins/Hively/Hively/HVLDecoder.m | 1 + Plugins/MIDI/MIDI/MIDIDecoder.mm | 1 + Plugins/Musepack/MusepackDecoder.m | 1 + Plugins/OpenMPT.old/OpenMPT/OMPTDecoder.mm | 1 + Plugins/OpenMPT/OpenMPT/OMPTDecoder.mm | 1 + Plugins/Opus/Opus/OpusDecoder.m | 1 + Plugins/Shorten/ShortenDecoder.mm | 1 + .../SilenceDecoder/SilenceDecoder.m | 1 + Plugins/Vorbis/VorbisDecoder.m | 1 + Plugins/WavPack/WavPackDecoder.h | 1 + Plugins/WavPack/WavPackDecoder.m | 3 + Plugins/libvgmPlayer/libvgmDecoder.mm | 1 + Plugins/sidplay/SidDecoder.mm | 1 + Plugins/vgmstream/vgmstream/VGMDecoder.m | 2 + Utils/SQLiteStore.h | 2 +- Utils/SQLiteStore.m | 101 ++++++++++++++++-- 25 files changed, 178 insertions(+), 37 deletions(-) diff --git a/Base.lproj/InfoInspector.xib b/Base.lproj/InfoInspector.xib index 6b64594ae..8b6510cf7 100644 --- a/Base.lproj/InfoInspector.xib +++ b/Base.lproj/InfoInspector.xib @@ -15,16 +15,16 @@ - + - + - + @@ -33,7 +33,7 @@ - + @@ -42,7 +42,7 @@ - + @@ -51,7 +51,7 @@ - + @@ -60,7 +60,7 @@ - + @@ -69,7 +69,7 @@ - + @@ -78,7 +78,7 @@ - + @@ -87,7 +87,7 @@ - + @@ -96,7 +96,7 @@ - + @@ -105,7 +105,7 @@ - + @@ -114,7 +114,7 @@ - + @@ -123,7 +123,7 @@ - + @@ -135,7 +135,7 @@ - + @@ -147,7 +147,7 @@ - + @@ -159,7 +159,7 @@ - + @@ -171,7 +171,7 @@ - + @@ -183,7 +183,7 @@ - + @@ -195,7 +195,7 @@ - + @@ -207,7 +207,7 @@ - + @@ -219,7 +219,7 @@ - + @@ -231,7 +231,7 @@ - + @@ -243,7 +243,7 @@ - + @@ -255,7 +255,7 @@ - + @@ -264,7 +264,7 @@ - + @@ -275,8 +275,29 @@ + + + + + + + + + + + + + + + + + + + + + - + @@ -285,7 +306,7 @@ - + @@ -311,7 +332,7 @@ - + @@ -320,7 +341,7 @@ - + diff --git a/Playlist/PlaylistEntry.h b/Playlist/PlaylistEntry.h index aadd1608d..7ce334c7e 100644 --- a/Playlist/PlaylistEntry.h +++ b/Playlist/PlaylistEntry.h @@ -59,6 +59,8 @@ NSString *codec; NSString *endian; + + NSString *encoding; BOOL seekable; @@ -149,6 +151,8 @@ @property(retain) NSString *endian; +@property(retain) NSString *encoding; + @property BOOL seekable; @property BOOL metadataLoaded; diff --git a/Playlist/PlaylistEntry.m b/Playlist/PlaylistEntry.m index c665cd4cc..3247f016c 100644 --- a/Playlist/PlaylistEntry.m +++ b/Playlist/PlaylistEntry.m @@ -59,6 +59,8 @@ @synthesize endian; +@synthesize encoding; + @synthesize seekable; @synthesize metadataLoaded; @@ -491,6 +493,8 @@ pe->codec = [codec copyWithZone:zone]; pe->endian = [endian copyWithZone:zone]; + + pe->encoding = [encoding copyWithZone:zone]; pe->seekable = seekable; diff --git a/Plugins/AdPlug/AdPlug/AdPlugDecoder.mm b/Plugins/AdPlug/AdPlug/AdPlugDecoder.mm index 1969dd269..afd812a5f 100755 --- a/Plugins/AdPlug/AdPlug/AdPlugDecoder.mm +++ b/Plugins/AdPlug/AdPlug/AdPlugDecoder.mm @@ -98,6 +98,7 @@ static CAdPlugDatabase * g_database = NULL; [NSNumber numberWithInt:2], @"channels", //output from gme_play is in stereo [NSNumber numberWithBool:YES], @"seekable", [NSString stringWithUTF8String:m_player->gettype().c_str()], @"codec", + @"synthesized", @"encoding", @"host", @"endian", nil]; } diff --git a/Plugins/CoreAudio/CoreAudioDecoder.m b/Plugins/CoreAudio/CoreAudioDecoder.m index 264115a23..ea83d2c1c 100644 --- a/Plugins/CoreAudio/CoreAudioDecoder.m +++ b/Plugins/CoreAudio/CoreAudioDecoder.m @@ -349,6 +349,7 @@ static SInt64 getSizeProc(void* clientData) { [NSNumber numberWithBool:YES], @"seekable", codec, @"codec", floatingPoint ? @"host" : @"big", @"endian", + floatingPoint ? @"lossy" : @"lossless", @"encoding", nil]; } diff --git a/Plugins/FFMPEG/FFMPEGDecoder.m b/Plugins/FFMPEG/FFMPEGDecoder.m index 1e137d419..7e28104c7 100644 --- a/Plugins/FFMPEG/FFMPEGDecoder.m +++ b/Plugins/FFMPEG/FFMPEGDecoder.m @@ -580,6 +580,7 @@ int lockmgr_callback(void ** mutex, enum AVLockOp op) [NSNumber numberWithBool:seekable], @"seekable", [NSString stringWithUTF8String:avcodec_get_name(codecCtx->codec_id)], @"codec", @"host", @"endian", + floatingPoint ? @"lossy" : @"lossless", @"encoding", nil]; } diff --git a/Plugins/Flac/FlacDecoder.m b/Plugins/Flac/FlacDecoder.m index d27330789..161cd2acd 100644 --- a/Plugins/Flac/FlacDecoder.m +++ b/Plugins/Flac/FlacDecoder.m @@ -348,6 +348,7 @@ void ErrorCallback(const FLAC__StreamDecoder *decoder, FLAC__StreamDecoderErrorS [NSNumber numberWithInt:fileSize ? (fileSize * 8 / ((totalFrames + (frequency / 2)) / frequency)) / 1000 : 0], @"bitrate", @"FLAC",@"codec", @"big",@"endian", + @"lossless", @"encoding", nil]; } diff --git a/Plugins/GME/GameDecoder.m b/Plugins/GME/GameDecoder.m index 6d8d7ff19..975454e8a 100755 --- a/Plugins/GME/GameDecoder.m +++ b/Plugins/GME/GameDecoder.m @@ -160,6 +160,7 @@ gme_err_t readCallback( void* data, void* out, long count ) [NSNumber numberWithInt:2], @"channels", //output from gme_play is in stereo [NSNumber numberWithBool:[source seekable]], @"seekable", @"host", @"endian", + @"synthesized", @"encoding", nil]; } diff --git a/Plugins/HighlyComplete/HighlyComplete/HCDecoder.mm b/Plugins/HighlyComplete/HighlyComplete/HCDecoder.mm index b5050515a..b91dc91cf 100644 --- a/Plugins/HighlyComplete/HighlyComplete/HCDecoder.mm +++ b/Plugins/HighlyComplete/HighlyComplete/HCDecoder.mm @@ -1727,6 +1727,7 @@ static int usf_info(void * context, const char * name, const char * value) [NSNumber numberWithFloat:volume], @"volume", codec, @"codec", @"host", @"endian", + @"synthesized", @"encoding", nil]; } diff --git a/Plugins/Hively/Hively/HVLDecoder.m b/Plugins/Hively/Hively/HVLDecoder.m index ceeea4cc9..002130684 100755 --- a/Plugins/Hively/Hively/HVLDecoder.m +++ b/Plugins/Hively/Hively/HVLDecoder.m @@ -96,6 +96,7 @@ static void oneTimeInit(void) [NSNumber numberWithInt:2], @"channels", [NSNumber numberWithBool:YES], @"seekable", @"host", @"endian", + @"synthesized", @"encoding", nil]; } diff --git a/Plugins/MIDI/MIDI/MIDIDecoder.mm b/Plugins/MIDI/MIDI/MIDIDecoder.mm index 2236c5f30..fd26a10dc 100755 --- a/Plugins/MIDI/MIDI/MIDIDecoder.mm +++ b/Plugins/MIDI/MIDI/MIDIDecoder.mm @@ -115,6 +115,7 @@ static OSType getOSType(const char * in_) [NSNumber numberWithBool:YES], @"seekable", @"MIDI", @"codec", @"host", @"endian", + @"synthesized", @"encoding", nil]; } diff --git a/Plugins/Musepack/MusepackDecoder.m b/Plugins/Musepack/MusepackDecoder.m index e4b787d43..64dd7f070 100644 --- a/Plugins/Musepack/MusepackDecoder.m +++ b/Plugins/Musepack/MusepackDecoder.m @@ -213,6 +213,7 @@ mpc_bool_t CanSeekProc(mpc_reader *p_reader) [NSNumber numberWithBool:[source seekable]], @"seekable", @"Musepack", @"codec", @"host",@"endian", + @"lossy", @"encoding", nil]; } diff --git a/Plugins/OpenMPT.old/OpenMPT/OMPTDecoder.mm b/Plugins/OpenMPT.old/OpenMPT/OMPTDecoder.mm index 0a43d6eab..305ed5410 100755 --- a/Plugins/OpenMPT.old/OpenMPT/OMPTDecoder.mm +++ b/Plugins/OpenMPT.old/OpenMPT/OMPTDecoder.mm @@ -106,6 +106,7 @@ static void g_push_archive_extensions(std::vector & list) [NSNumber numberWithInt:2], @"channels", //output from gme_play is in stereo [NSNumber numberWithBool:YES], @"seekable", @"host", @"endian", + @"synthesized", @"encoding", nil]; } diff --git a/Plugins/OpenMPT/OpenMPT/OMPTDecoder.mm b/Plugins/OpenMPT/OpenMPT/OMPTDecoder.mm index d0cb941f4..ac533ad48 100755 --- a/Plugins/OpenMPT/OpenMPT/OMPTDecoder.mm +++ b/Plugins/OpenMPT/OpenMPT/OMPTDecoder.mm @@ -103,6 +103,7 @@ static void g_push_archive_extensions(std::vector & list) [NSNumber numberWithInt:2], @"channels", //output from gme_play is in stereo [NSNumber numberWithBool:YES], @"seekable", @"host", @"endian", + @"synthesized", @"encoding", nil]; } diff --git a/Plugins/Opus/Opus/OpusDecoder.m b/Plugins/Opus/Opus/OpusDecoder.m index 915782322..56684c710 100644 --- a/Plugins/Opus/Opus/OpusDecoder.m +++ b/Plugins/Opus/Opus/OpusDecoder.m @@ -169,6 +169,7 @@ opus_int64 sourceTell(void *_stream) [NSNumber numberWithBool:([source seekable] && seekable)], @"seekable", @"Opus", @"codec", @"host", @"endian", + @"lossy", @"encoding", nil]; } diff --git a/Plugins/Shorten/ShortenDecoder.mm b/Plugins/Shorten/ShortenDecoder.mm index 19f8f738e..0a36c9fd0 100644 --- a/Plugins/Shorten/ShortenDecoder.mm +++ b/Plugins/Shorten/ShortenDecoder.mm @@ -95,6 +95,7 @@ [NSNumber numberWithBool:seekable ],@"seekable", @"Shorten",@"codec", @"little",@"endian", + @"lossless", @"encoding", nil]; } diff --git a/Plugins/SilenceDecoder/SilenceDecoder/SilenceDecoder.m b/Plugins/SilenceDecoder/SilenceDecoder/SilenceDecoder.m index f42e7f81a..4cafd006a 100755 --- a/Plugins/SilenceDecoder/SilenceDecoder/SilenceDecoder.m +++ b/Plugins/SilenceDecoder/SilenceDecoder/SilenceDecoder.m @@ -46,6 +46,7 @@ enum { channels = 2 }; [NSNumber numberWithInt:channels], @"channels", [NSNumber numberWithBool:YES], @"seekable", @"host", @"endian", + @"synthesized", @"encoding", nil]; } diff --git a/Plugins/Vorbis/VorbisDecoder.m b/Plugins/Vorbis/VorbisDecoder.m index 539976d86..890795cbb 100644 --- a/Plugins/Vorbis/VorbisDecoder.m +++ b/Plugins/Vorbis/VorbisDecoder.m @@ -161,6 +161,7 @@ long sourceTell(void *datasource) [NSNumber numberWithBool:([source seekable] && seekable)], @"seekable", @"Vorbis", @"codec", @"host", @"endian", + @"lossy", @"encoding", nil]; } diff --git a/Plugins/WavPack/WavPackDecoder.h b/Plugins/WavPack/WavPackDecoder.h index 43a770a6b..1d97a51bb 100644 --- a/Plugins/WavPack/WavPackDecoder.h +++ b/Plugins/WavPack/WavPackDecoder.h @@ -37,6 +37,7 @@ size_t inputBufferSize; BOOL isDSD; + BOOL isLossy; int bitsPerSample; int channels; diff --git a/Plugins/WavPack/WavPackDecoder.m b/Plugins/WavPack/WavPackDecoder.m index 1fc86822a..93af6d25e 100644 --- a/Plugins/WavPack/WavPackDecoder.m +++ b/Plugins/WavPack/WavPackDecoder.m @@ -187,6 +187,8 @@ int32_t WriteBytesProc(void *ds, void *data, int32_t bcount) bitrate = (int)(WavpackGetAverageBitrate(wpc, TRUE)/1000.0); floatingPoint = MODE_FLOAT & WavpackGetMode(wpc) && 127 == WavpackGetFloatNormExp(wpc); + + isLossy = !(WavpackGetMode(wpc) & MODE_LOSSLESS); [self willChangeValueForKey:@"properties"]; [self didChangeValueForKey:@"properties"]; @@ -313,6 +315,7 @@ int32_t WriteBytesProc(void *ds, void *data, int32_t bcount) [NSNumber numberWithBool:[[wv source] seekable]], @"seekable", @"Wavpack",@"codec", @"little",@"endian", + isLossy ? @"lossy" : @"lossless", @"encoding", nil]; } diff --git a/Plugins/libvgmPlayer/libvgmDecoder.mm b/Plugins/libvgmPlayer/libvgmDecoder.mm index ffe3aef18..15a4a238b 100755 --- a/Plugins/libvgmPlayer/libvgmDecoder.mm +++ b/Plugins/libvgmPlayer/libvgmDecoder.mm @@ -204,6 +204,7 @@ const int masterVol = 0x10000; // Fixed point 16.16 [NSNumber numberWithInt:numChannels], @"channels", //output from gme_play is in stereo [NSNumber numberWithBool:[source seekable]], @"seekable", @"host", @"endian", + @"synthesized", @"encoding", nil]; } diff --git a/Plugins/sidplay/SidDecoder.mm b/Plugins/sidplay/SidDecoder.mm index 7dedc5e6e..ef93f9dab 100755 --- a/Plugins/sidplay/SidDecoder.mm +++ b/Plugins/sidplay/SidDecoder.mm @@ -209,6 +209,7 @@ static void sidTuneLoader(const char* fileName, std::vector& bufferRef) [NSNumber numberWithInt:n_channels], @"channels", //output from gme_play is in stereo [NSNumber numberWithBool:[source seekable]], @"seekable", @"host", @"endian", + @"synthesized", @"encoding", nil]; } diff --git a/Plugins/vgmstream/vgmstream/VGMDecoder.m b/Plugins/vgmstream/vgmstream/VGMDecoder.m index 649c31814..c1bff9402 100644 --- a/Plugins/vgmstream/vgmstream/VGMDecoder.m +++ b/Plugins/vgmstream/vgmstream/VGMDecoder.m @@ -174,6 +174,7 @@ static NSString* get_description_tag(const char* description, const char *tag, c rgTrackPeak, @"replayGainTrackPeak", codec, @"codec", @"host", @"endian", + @"lossy/lossless", @"encoding", nil]; if ( [title isEqualToString:@""] ) { @@ -315,6 +316,7 @@ static NSString* get_description_tag(const char* description, const char *tag, c [NSNumber numberWithInt:channels], @"channels", [NSNumber numberWithBool:YES], @"seekable", @"host", @"endian", + @"lossy/lossless", @"encoding", nil]; } diff --git a/Utils/SQLiteStore.h b/Utils/SQLiteStore.h index dea419593..4e887cbda 100644 --- a/Utils/SQLiteStore.h +++ b/Utils/SQLiteStore.h @@ -14,7 +14,7 @@ { @private NSString *g_databasePath; @private sqlite3 *g_database; -@private sqlite3_stmt *stmt[38]; +@private sqlite3_stmt *stmt[39]; @private NSMutableArray *databaseMirror; } diff --git a/Utils/SQLiteStore.m b/Utils/SQLiteStore.m index 3c5f74791..28ed13aa2 100644 --- a/Utils/SQLiteStore.m +++ b/Utils/SQLiteStore.m @@ -7,6 +7,7 @@ #import #import "SQLiteStore.h" +#import "Logging.h" NSString * getDatabasePath(void) { @@ -16,6 +17,8 @@ NSString * getDatabasePath(void) return [basePath stringByAppendingPathComponent:filename]; } +static int64_t currentSchemaVersion = 1; + NSArray * createSchema(void) { return @[ @@ -40,6 +43,8 @@ NSArray * createSchema(void) titleid INTEGER, \ genreid INTEGER, \ codecid INTEGER, \ + encodingid INTEGER, \ + cuesheetid INTEGER, \ track INTEGER, \ year INTEGER, \ unsigned INTEGER, \ @@ -73,7 +78,9 @@ NSArray * createSchema(void) enum { - stmt_select_string = 0, + stmt_user_version_get = 0, + + stmt_select_string, stmt_select_string_refcount, stmt_select_string_value, stmt_bump_string, @@ -119,6 +126,14 @@ enum stmt_count, }; +enum +{ + user_version_get_out_version_number = 0, +}; + +const char * query_user_version_get = "PRAGMA user_version"; + + enum { select_string_in_id = 1, @@ -264,6 +279,8 @@ enum select_track_data_out_title_id, select_track_data_out_genre_id, select_track_data_out_codec_id, + select_track_data_out_cuesheet_id, + select_track_data_out_encoding_id, select_track_data_out_track, select_track_data_out_year, select_track_data_out_unsigned, @@ -283,7 +300,7 @@ enum select_track_data_out_replaygaintrackpeak, }; -const char * query_select_track_data = "SELECT urlid, artid, albumid, albumartistid, artistid, titleid, genreid, codecid, 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, endianid, floatingpoint, totalframes, metadataloaded, seekable, volume, replaygainalbumgain, replaygainalbumpeak, replaygaintrackgain, replaygaintrackpeak FROM knowntracks WHERE (trackid = ?) LIMIT 1"; enum { @@ -309,6 +326,8 @@ enum add_track_in_title_id, add_track_in_genre_id, add_track_in_codec_id, + add_track_in_cuesheet_id, + add_track_in_encoding_id, add_track_in_track, add_track_in_year, add_track_in_unsigned, @@ -328,7 +347,7 @@ enum add_track_in_replaygaintrackpeak, }; -const char * query_add_track = "INSERT INTO knowntracks (referencecount, urlid, artid, albumid, albumartistid, artistid, titleid, genreid, codecid, 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, endianid, floatingpoint, totalframes, metadataloaded, seekable, volume, replaygainalbumgain, replaygainalbumpeak, replaygaintrackgain, replaygaintrackpeak) VALUES (1, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"; enum { @@ -347,6 +366,8 @@ enum update_track_in_title_id, update_track_in_genre_id, update_track_in_codec_id, + update_track_in_cuesheet_id, + update_track_in_encoding_id, update_track_in_track, update_track_in_year, update_track_in_unsigned, @@ -367,7 +388,7 @@ enum update_track_in_id }; -const char * query_update_track = "UPDATE knowntracks SET urlid = ?, artid = ?, albumid = ?, albumartistid = ?, artistid = ?, titleid = ?, genreid = ?, codecid = ?, 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 = ?, endianid = ?, floatingpoint = ?, totalframes = ?, metadataloaded = ?, seekable = ?, volume = ?, replaygainalbumgain = ?, replaygainalbumpeak = ?, replaygaintrackgain = ?, replaygaintrackpeak = ? WHERE trackid = ?"; enum @@ -575,18 +596,62 @@ static SQLiteStore *g_sharedStore = NULL; if (sqlite3_open([g_databasePath UTF8String], &g_database) == SQLITE_OK) { + char * error; NSArray * schemas = createSchema(); for (NSString *schema in schemas) { - char * error; if (sqlite3_exec(g_database, [schema UTF8String], NULL, NULL, &error) != SQLITE_OK) { + DLog(@"SQLite error: %s", error); return nil; } } -#define PREPARE(name) (sqlite3_prepare(g_database, query_##name, (int)strlen(query_##name), &stmt[stmt_##name], NULL)) +#define PREPARE(name) (sqlite3_prepare_v2(g_database, query_##name, (int)strlen(query_##name), &stmt[stmt_##name], NULL)) + + if (PREPARE(user_version_get)) + { + DLog(@"SQlite error: %s", error); + return nil; + } + + sqlite3_stmt * st = stmt[stmt_user_version_get]; + if (sqlite3_reset(st) || + sqlite3_step(st) != SQLITE_ROW) + { + return nil; + } + + int64_t knownVersion = sqlite3_column_int64(st, user_version_get_out_version_number); + + sqlite3_reset(st); + + if (knownVersion < currentSchemaVersion) + { + switch (knownVersion) + { + case 0: + // Schema 0 to 1: Add cuesheet and encoding text fields to the knowntracks table + if (sqlite3_exec(g_database, "ALTER TABLE knowntracks ADD encodingid INTEGER; ALTER TABLE knowntracks ADD cuesheetid INTEGER", NULL, NULL, &error)) + { + DLog(@"SQLite error: %s", error); + return nil; + } + break; + + default: + break; + } + + NSString * updateVersion = [NSString stringWithFormat:@"PRAGMA user_version = %lld", currentSchemaVersion]; + + if (sqlite3_exec(g_database, [updateVersion UTF8String], NULL, NULL, &error)) + { + DLog(@"SQLite error: %s", error); + return nil; + } + } if (PREPARE(select_string) || PREPARE(select_string_refcount) || @@ -1031,6 +1096,8 @@ static SQLiteStore *g_sharedStore = NULL; int64_t titleId = [self addString:[track rawTitle]]; int64_t genreId = [self addString:[track genre]]; int64_t codecId = [self addString:[track codec]]; + int64_t cuesheetId = [self addString:[track cuesheet]]; + int64_t encodingId = [self addString:[track encoding]]; int64_t trackNr = [[track track] intValue] | (((uint64_t)[[track disc] intValue]) << 32); int64_t year = [[track year] intValue]; int64_t unsignedFmt = [track Unsigned]; @@ -1066,6 +1133,8 @@ static SQLiteStore *g_sharedStore = NULL; sqlite3_bind_int64(st, add_track_in_title_id, titleId) || sqlite3_bind_int64(st, add_track_in_genre_id, genreId) || sqlite3_bind_int64(st, add_track_in_codec_id, codecId) || + sqlite3_bind_int64(st, add_track_in_cuesheet_id, cuesheetId) || + sqlite3_bind_int64(st, add_track_in_encoding_id, encodingId) || sqlite3_bind_int64(st, add_track_in_track, trackNr) || sqlite3_bind_int64(st, add_track_in_year, year) || sqlite3_bind_int64(st, add_track_in_unsigned, unsignedFmt) || @@ -1094,6 +1163,8 @@ static SQLiteStore *g_sharedStore = NULL; [self removeString:titleId]; [self removeString:genreId]; [self removeString:codecId]; + [self removeString:cuesheetId]; + [self removeString:encodingId]; [self removeString:endianId]; [self removeString:urlId]; @@ -1200,6 +1271,8 @@ static SQLiteStore *g_sharedStore = NULL; int64_t titleId = sqlite3_column_int64(st, select_track_data_out_title_id); int64_t genreId = sqlite3_column_int64(st, select_track_data_out_genre_id); int64_t codecId = sqlite3_column_int64(st, select_track_data_out_codec_id); + int64_t cuesheetId = sqlite3_column_int64(st, select_track_data_out_cuesheet_id); + int64_t encodingId = sqlite3_column_int64(st, select_track_data_out_encoding_id); int64_t endianId = sqlite3_column_int64(st, select_track_data_out_endian_id); [self removeArt:artId]; @@ -1211,6 +1284,8 @@ static SQLiteStore *g_sharedStore = NULL; [self removeString:titleId]; [self removeString:genreId]; [self removeString:codecId]; + [self removeString:cuesheetId]; + [self removeString:encodingId]; [self removeString:endianId]; } @@ -1223,6 +1298,8 @@ static SQLiteStore *g_sharedStore = NULL; int64_t titleId = [self addString:[track rawTitle]]; int64_t genreId = [self addString:[track genre]]; int64_t codecId = [self addString:[track codec]]; + int64_t cuesheetId = [self addString:[track cuesheet]]; + int64_t encodingId = [self addString:[track encoding]]; int64_t trackNr = [[track track] intValue] | (((uint64_t)[[track disc] intValue]) << 32); int64_t year = [[track year] intValue]; int64_t unsignedFmt = [track Unsigned]; @@ -1258,6 +1335,8 @@ static SQLiteStore *g_sharedStore = NULL; sqlite3_bind_int64(st, update_track_in_title_id, titleId) || sqlite3_bind_int64(st, update_track_in_genre_id, genreId) || sqlite3_bind_int64(st, update_track_in_codec_id, codecId) || + sqlite3_bind_int64(st, update_track_in_cuesheet_id, cuesheetId) || + sqlite3_bind_int64(st, update_track_in_encoding_id, encodingId) || sqlite3_bind_int64(st, update_track_in_track, trackNr) || sqlite3_bind_int64(st, update_track_in_year, year) || sqlite3_bind_int64(st, update_track_in_unsigned, unsignedFmt) || @@ -1287,6 +1366,8 @@ static SQLiteStore *g_sharedStore = NULL; [self removeString:titleId]; [self removeString:genreId]; [self removeString:codecId]; + [self removeString:cuesheetId]; + [self removeString:encodingId]; [self removeString:endianId]; [self removeString:urlId]; @@ -1331,6 +1412,8 @@ static SQLiteStore *g_sharedStore = NULL; int64_t titleId = sqlite3_column_int64(st, select_track_data_out_title_id); int64_t genreId = sqlite3_column_int64(st, select_track_data_out_genre_id); int64_t codecId = sqlite3_column_int64(st, select_track_data_out_codec_id); + int64_t cuesheetId = sqlite3_column_int64(st, select_track_data_out_cuesheet_id); + int64_t encodingId = sqlite3_column_int64(st, select_track_data_out_encoding_id); int64_t trackNr = sqlite3_column_int64(st, select_track_data_out_track); int64_t year = sqlite3_column_int64(st, select_track_data_out_year); int64_t unsignedFmt = sqlite3_column_int64(st, select_track_data_out_unsigned); @@ -1360,6 +1443,8 @@ static SQLiteStore *g_sharedStore = NULL; [entry setTitle:[self getString:titleId]]; [entry setGenre:[self getString:genreId]]; [entry setCodec:[self getString:codecId]]; + [entry setCuesheet:[self getString:cuesheetId]]; + [entry setEncoding:[self getString:encodingId]]; [entry setTrack:[NSNumber numberWithInteger:trackNr]]; [entry setDisc:[NSNumber numberWithInteger:discNr]]; [entry setYear:[NSNumber numberWithInteger:year]]; @@ -1442,6 +1527,8 @@ static SQLiteStore *g_sharedStore = NULL; int64_t titleId = sqlite3_column_int64(st, select_track_data_out_title_id); int64_t genreId = sqlite3_column_int64(st, select_track_data_out_genre_id); int64_t codecId = sqlite3_column_int64(st, select_track_data_out_codec_id); + int64_t cuesheetId = sqlite3_column_int64(st, select_track_data_out_cuesheet_id); + int64_t encodingId = sqlite3_column_int64(st, select_track_data_out_encoding_id); int64_t endianId = sqlite3_column_int64(st, select_track_data_out_endian_id); sqlite3_reset(st); @@ -1455,6 +1542,8 @@ static SQLiteStore *g_sharedStore = NULL; [self removeString:titleId]; [self removeString:genreId]; [self removeString:codecId]; + [self removeString:cuesheetId]; + [self removeString:encodingId]; [self removeString:endianId]; }