Now cache around NSData objects of individual pieces of album art, unique by their byte contents. And the artwork image cacher will also use the art ID keys from the database as the cache keys for NSImages, so they'll not only be only read once per unique image, but also tracks can have unique artwork per track, if the files so feature it. Signed-off-by: Christopher Snowhill <kode54@gmail.com>
60 lines
2 KiB
Objective-C
60 lines
2 KiB
Objective-C
//
|
|
// NSTableViewDataSource+sqlite.h
|
|
// Cog
|
|
//
|
|
// Created by Christopher Snowhill on 12/22/21.
|
|
//
|
|
|
|
#ifndef NSTableViewDataSource_sqlite_h
|
|
#import "PlaylistEntry.h"
|
|
#import <Cocoa/Cocoa.h>
|
|
#import <sqlite3.h>
|
|
|
|
@interface SQLiteStore : NSObject {
|
|
@private
|
|
NSString *g_databasePath;
|
|
@private
|
|
sqlite3 *g_database;
|
|
@private
|
|
sqlite3_stmt *stmt[39];
|
|
@private
|
|
NSMutableArray *databaseMirror;
|
|
NSMutableDictionary *artTable;
|
|
}
|
|
|
|
@property(nonatomic, readwrite) NSString *databasePath;
|
|
@property(nonatomic, assign, readwrite) sqlite3 *database;
|
|
|
|
+ (SQLiteStore *)sharedStore;
|
|
|
|
- (id)init;
|
|
- (void)dealloc;
|
|
|
|
- (void)trackUpdate:(PlaylistEntry *)track;
|
|
|
|
- (void)playlistInsertTracks:(NSArray *)tracks atIndex:(int64_t)index progressCall:(void (^)(double progress))callback;
|
|
- (void)playlistInsertTracks:(NSArray *)tracks atObjectIndexes:(NSIndexSet *)indexes progressCall:(void (^)(double progress))callback;
|
|
- (void)playlistRemoveTracks:(int64_t)index forCount:(int64_t)count progressCall:(void (^)(double progress))callback;
|
|
- (void)playlistRemoveTracksAtIndexes:(NSIndexSet *)indexes progressCall:(void (^)(double progress))callback;
|
|
- (PlaylistEntry *)playlistGetItem:(int64_t)index;
|
|
- (PlaylistEntry *)playlistGetCachedItem:(int64_t)index;
|
|
- (int64_t)playlistGetCount;
|
|
|
|
- (void)playlistMoveObjectsInArrangedObjectsFromIndexes:(NSIndexSet *)indexSet toIndex:(NSUInteger)insertIndex progressCall:(void (^)(double))callback;
|
|
- (void)playlistMoveObjectsFromIndex:(NSUInteger)fromIndex toArrangedObjectIndexes:(NSIndexSet *)indexSet progressCall:(void (^)(double))callback;
|
|
|
|
- (void)syncPlaylistEntries:(NSArray *)entries progressCall:(void (^)(double progress))callback;
|
|
|
|
- (void)queueAddItem:(int64_t)playlistIndex;
|
|
- (void)queueAddItems:(NSArray *)playlistIndexes;
|
|
- (void)queueRemoveItem:(int64_t)queueIndex;
|
|
- (void)queueRemovePlaylistItems:(NSArray *)playlistIndexes;
|
|
- (int64_t)queueGetEntry:(int64_t)queueIndex;
|
|
- (int64_t)queueGetCount;
|
|
- (void)queueEmpty;
|
|
|
|
@end
|
|
|
|
#define NSTableViewDataSource_sqlite_h
|
|
|
|
#endif /* NSTableViewDataSource_sqlite_h */
|