Commit Graph

98 Commits (7e516f8cfe6fc2d3e3867d5523d2372568245a4c)

Author SHA1 Message Date
Christopher Snowhill 8f4fb4a44c [Sandbox Broker] Greatly speed up path resolving
The fragment remover need not detect whether the given path is a folder
or a file, as it is only removing hash marked fragments, not actually
removing the entire filename if it's only a file and not a folder like
the old versions used to. This greatly speeds up access, especially on
network shares.

Signed-off-by: Christopher Snowhill <kode54@gmail.com>
2022-07-06 00:04:28 -07:00
Christopher Snowhill 740613b95a [Sandbox] Ask for permission for container folders
Ask for permission to access the folders containing container files,
such as .CUE sheets, or .M3U or .PLS playlists.

Signed-off-by: Christopher Snowhill <kode54@gmail.com>
2022-07-03 22:37:11 -07:00
Christopher Snowhill 099588b7bd Restore the File Tree, now with a chooser button
Revert "Remove the file tree, as Sandbox does not permit"

This reverts commit 35400e1320.

This also changes how the File Tree choosing works.

Signed-off-by: Christopher Snowhill <kode54@gmail.com>
2022-06-30 16:59:35 -07:00
Christopher Snowhill d739e68e8e [Sandbox] Synchronize write accesses to storage
Synchronize writing to the bookmark storage to the main thread.

Signed-off-by: Christopher Snowhill <kode54@gmail.com>
2022-06-29 19:41:03 -07:00
Christopher Snowhill 4ce180fb2a [Sandbox] Fix URL fragment removal function
This should be deleting from the #, including the #.

Signed-off-by: Christopher Snowhill <kode54@gmail.com>
2022-06-29 19:39:47 -07:00
Christopher Snowhill 7d26150c26 [Sandbox] Support bookmarking individual files
Individually added files, directly opened by the user, may now store
bookmarks in settings.

Signed-off-by: Christopher Snowhill <kode54@gmail.com>
2022-06-29 12:00:25 -07:00
Christopher Snowhill 35400e1320 Remove the file tree, as Sandbox does not permit
The Sandbox does not permit such controls to exist.

Signed-off-by: Christopher Snowhill <kode54@gmail.com>
2022-06-29 12:00:12 -07:00
Christopher Snowhill 29c070a616 [Sandbox] Automatically save folder bookmarks
Signed-off-by: Christopher Snowhill <kode54@gmail.com>
2022-06-28 23:15:08 -07:00
Christopher Snowhill 8b7418857d [Sandbox] Reduce entitlements granted by default
Since App Store approval decided these suddenly matter.

Signed-off-by: Christopher Snowhill <kode54@gmail.com>
2022-06-28 23:14:53 -07:00
Christopher Snowhill 66262c2a71 [Sandbox Broker] Synchronize full access operation
Full access should be synchronized, otherwise rapid access to the same
path from different threads will cause crashes.

Signed-off-by: Christopher Snowhill <kode54@gmail.com>
2022-06-27 01:00:11 -07:00
Christopher Snowhill dd65665990 [Sandbox Broker] Bypass entitled paths
Include entitlement granted user folders in the permission check, so
that if the file or folder is nested under one of them, it allocates a
static permission object, rather than querying the list of configured
paths every time. This also prevents the player from popping open the
path grant / suggester dialog every time a default path is in the file
set listed, which should provide some relief to most users.

Signed-off-by: Christopher Snowhill <kode54@gmail.com>
2022-06-26 23:52:38 -07:00
Christopher Snowhill 870a5afed7 [Sandbox Broker] Fix deadlock and crash
The crash was because we weren't copying the results array before
iterating over it, and the deadlock was because this was forced to go
through the main thread, rather than going through its calling thread,
which could lock up if the main thread was busy working with the Sandbox
Broker object.

Signed-off-by: Christopher Snowhill <kode54@gmail.com>
2022-06-24 17:04:39 -07:00
Christopher Snowhill ec393d186a [Sandbox Broker] Copy results array
Hopefully this heads off a crash elsewhere.

Signed-off-by: Christopher Snowhill <kode54@gmail.com>
2022-06-24 17:04:16 -07:00
Christopher Snowhill 80adb85b36 [Path Suggester] Automatically pop where required
The Path Suggester will now automatically open when new files are added
to the playlist and a given path is not in the sandbox settings. It will
also pop for both the File Tree and MIDI SoundFont path configuration
settings being changed.

Signed-off-by: Christopher Snowhill <kode54@gmail.com>
2022-06-24 00:29:50 -07:00
Christopher Snowhill f3f3d436ba [Sandbox Broker] Synchronize storage access
Synchronize storage access to main thread only, to prevent enumeration
from hitting a case of the main thread writing to the storage.

Signed-off-by: Christopher Snowhill <kode54@gmail.com>
2022-06-23 23:35:26 -07:00
Christopher Snowhill bc23ed6c24 [Sandbox Configuration] Fix nil pointer issues
Solve some nil pointer issues with the Sandbox configuration code being
set with invalid paths.

Signed-off-by: Christopher Snowhill <kode54@gmail.com>
2022-06-21 16:12:28 -07:00
Christopher Snowhill e8dacdabda [Sandbox] Add Playlist Path Suggester
Add a dialog for suggesting sandbox paths to the Preferences general
page, in the context menu.

Signed-off-by: Christopher Snowhill <kode54@gmail.com>
2022-06-21 02:45:45 -07:00
Christopher Snowhill 5cb08291bf [Sandbox / Core Data] Refine global variable usage
Refine the global variable usage, eliminating double underscore prefixes
and trusting that static global variables will exist in the object where
the class was created. Got rid of that nasty NSApplication extension
hack that was previously in use.

Signed-off-by: Christopher Snowhill <kode54@gmail.com>
2022-06-21 00:01:07 -07:00
Christopher Snowhill 4ac566c308 [Sandbox Broker] Allow to be passed directory URLs
Allow opening directory URLs as-is, rather than treating them like
files. Return the full path if the caller requests opening on a
directory.

Signed-off-by: Christopher Snowhill <kode54@gmail.com>
2022-06-20 23:39:07 -07:00
Christopher Snowhill 8dddf6a115 [Sandbox] Refine broker to return handle to token
Sandbox Broker now returns a handle to the exact path object that was
retained by the caller, so it will be released correctly, regardless of
what happens to the list of bookmarked paths.

Also refined the bookmark path comparison function. For existing paths,
it will find the first match. For new paths, it will prefer the longest
path instead, to try to find the deepest matching bookmark.

Signed-off-by: Christopher Snowhill <kode54@gmail.com>
2022-06-20 22:10:43 -07:00
Christopher Snowhill 3153159658 [Sandbox] Make Sandbox prefer the longest path
The Sandbox Broker should prefer the token with the longest matching
path, not the shortest.

Signed-off-by: Christopher Snowhill <kode54@gmail.com>
2022-06-20 16:16:04 -07:00
Christopher Snowhill c23bece62c Reintroducing App Sandbox, and more
- Implemented App Sandboxing in a more friendly manner.
- All sandboxed paths will need to be set in Preferences. Set as loose
  a path as you want. The shortest path will be preferred.
- Removed Last.fm client support, as it was non-functional by now,
  unfortunately. Maybe something better can come in the future.
- Added support for insecure SSL to the HTTP/S reader, in case anyone
  needs streams which are "protected" by self-signed or expired
  certificates, without having to futz around by adding certificates to
  the system settings, especially for expired certificates that can't
  otherwise be dodged this way.

If you want to import your old playlists to the new version, copy the
contents of `~/Library/Application Support/Cog` to the alternate sandbox
path: `~/Library/Containers/org.cogx.cog/Data/Library/Application `...
...continued...`Support/Cog`. The preferences file will migrate to the
new version automatically.

Signed-off-by: Christopher Snowhill <kode54@gmail.com>
2022-06-20 03:35:29 -07:00
Christopher Snowhill 8cb46b4f15 [Legacy SQLite Store] Handle errors with database
Handle missing track items in the databse more gracefully, by deleting
the track entries before passing them on to the caller, so problems do
not occur later.

Signed-off-by: Christopher Snowhill <kode54@gmail.com>
2022-06-18 18:41:14 -07:00
Christopher Snowhill 39f4d09c1a Use NSNumber Literals as much as possible
Replaced a bunch of [NSNumber numberWith...] with NSNumber Literals.

Signed-off-by: Christopher Snowhill <kode54@gmail.com>
2022-06-17 06:39:02 -07:00
Christopher Snowhill 4c95c943ef [Playlist Storage] Rewrite to use Core Data
Completely rewrite the playlist storage once again, this time with a
much faster Core Data implementation. It still uses a little magic for
Album Artwork consolidation, but string consolidation doesn't seem to be
needed to reduce the disk storage size. Works much faster than my silly
implementation, too.

Old implementations are still kept for backwards compatibility with
existing playlists.

Signed-off-by: Christopher Snowhill <kode54@gmail.com>
2022-06-16 07:14:33 -07:00
Christopher Snowhill a4f40971dd [SQLite Store] Every schema upgrade should process
Every schema upgrade process should fall through to the next highest
version number, so they should all run, if the user has somehow upgraded
their database from such an old version.

Signed-off-by: Christopher Snowhill <kode54@gmail.com>
2022-06-12 01:57:47 -07:00
Christopher Snowhill 90b83f8f51 [Various] Clean up various warnings
Various warnings related to uninitialized variables, or setting values
to variables that would not be used later or would be overwritten by per
loop initializers.

Signed-off-by: Christopher Snowhill <kode54@gmail.com>
2022-06-11 13:42:42 -07:00
Christopher Snowhill 2c7285382c [SQLite Store] Add type checks to add string/art
String and art adder functions now perform type checks, in case of
memory errors that somehow result in classes changing type. Which in
itself is a strange thing to happen.

Signed-off-by: Christopher Snowhill <kode54@gmail.com>
2022-06-10 18:26:45 -07:00
Christopher Snowhill e69ddb3578 [SQLite Store] Restructure add art/string code
Restructure the add string or art functions so they don't take a pointer
to a pointer, which may have caused issues when receiving a nil string
from the caller. Instead, take a plain pointer, and return the object,
returning the ID of the object to a pointer to an int64_t.

Also change several prototypes and functions to use _Nonnull or
_Nullable where appropriate.

Signed-off-by: Christopher Snowhill <kode54@gmail.com>
2022-06-10 18:10:47 -07:00
Christopher Snowhill e96a4efa68 [Metadata Loading] Added null pointer guards
This prevents crashes where inputs were not returning either properties
or metadata blocks and the file open cache was attempting to cache the
resulting nil pointer as if it were valid. Also prevent the metadata
redundant string coalescing from processing nil objects as well, in case
it's used that way somewhere else.

Signed-off-by: Christopher Snowhill <kode54@gmail.com>
2022-06-09 23:18:51 -07:00
Christopher Snowhill fef8821cf6 [Visualizer] Add extra condition to visible check
Add an extra condition to the visibility check, which is similar to the
previous version of this check, which now guards against the window it
is hosted in not being visible.

Signed-off-by: Christopher Snowhill <kode54@gmail.com>
2022-06-09 00:43:23 -07:00
Christopher Snowhill 1728debe94 [Visualizer] Bring back CoreGraphics visualizer
For legacy systems that do not support Metal. The Metal SceneKit view
does work on even 10.13.6, if a Metal GPU is present in the system.

Signed-off-by: Christopher Snowhill <kode54@gmail.com>
2022-06-08 21:32:52 -07:00
Christopher Snowhill da4630f4c5 Add a metadata loader cache
Promote the Plugin Controller source file to Objective-C++, and add a
simple data cache that holds on to requests for up to 5 seconds after
their last access, for preventing spammed requests from hitting files
over and over. This is apparently really relevant to the CUESheet reader
and its embedded CUESheet handling, as that tends to reread the same
file over and over as it populates the playlist with tracks. The nested
reader can also lead to repeated reading even on files without CUESheets
embedded.

Signed-off-by: Christopher Snowhill <kode54@gmail.com>
2022-02-26 23:24:32 -08:00
Christopher Snowhill 1da6cf2557 Deduplicate artwork using hashes
Artwork deduplication should be done with hashes, not by full data
comparison. This should be a lot faster loading artwork from files now,
especially if the playlist already contains a lot of unique artwork.

Signed-off-by: Christopher Snowhill <kode54@gmail.com>
2022-02-22 23:10:02 -08:00
Christopher Snowhill 5c3050c0d3 Playlist loader store: Adopt more correct method
This is a more correct method of identifying the supported classes to
coalesce into unique pointers through the storage array. I completely
forgot about this method, oops.

Signed-off-by: Christopher Snowhill <kode54@gmail.com>
2022-02-17 03:01:34 -08:00
Christopher Snowhill 2a27435f7e Dictionary merge: Correctly drop empty data tags
This allows for TagLib to handle artwork reading where the file built-in
readers fail, such as the FFmpeg reader, which would require parsing the
stream data for artwork packets, a really wacky convention to have.

Signed-off-by: Christopher Snowhill <kode54@gmail.com>
2022-02-17 03:00:35 -08:00
Christopher Snowhill 007ec3696d SQLite Store: Properly read strings into memory
Strings read from the database were not being stashed in the memory
store, which caused things like blank tags instead of correct metadata.

Signed-off-by: Christopher Snowhill <kode54@gmail.com>
2022-02-17 02:58:57 -08:00
Christopher Snowhill 5611d08df1 Reduce memory usage of adding tracks
Significantly reduce the memory footprint of adding tracks to the
playlist, by coalescing the NSString and NSData objects in the info
dictionaries as they are being loaded in the background, into a common
data set which will then be discarded when the whole job is completed.

Signed-off-by: Christopher Snowhill <kode54@gmail.com>
2022-02-16 21:38:43 -08:00
Christopher Snowhill d30746bffa Extend deduplication to loading artwork on open
When adding tracks, deduplicate their artwork when loading to memory.

Signed-off-by: Christopher Snowhill <kode54@gmail.com>
2022-02-16 17:06:13 -08:00
Christopher Snowhill 3de43b55a7 Significantly reduce memory usage all around
Added a string dictionary for deduplication of metadata, and actually
initialize both it and the art dictionary on startup, so they actually
work like they should.

Signed-off-by: Christopher Snowhill <kode54@gmail.com>
2022-02-16 16:57:47 -08:00
Christopher Snowhill 67fcd2bb27 NSDictionary+Merge: Support overwriting empty
Support overwriting empty fields of NSNumber or NSString form with
values from the merging dictionary. Correctly overwrite the value from
the first dictionary with values from the second if the first contains
empty strings or zeroed numbers.

Signed-off-by: Christopher Snowhill <kode54@gmail.com>
2022-02-14 19:55:20 -08:00
Christopher Snowhill bf88c57454 Minor artwork caching changes
Art ID should be set on new files when they are stored into the
database, and the album art property should be affected by assigning to
the artId property, since it affects the caching identifier.

Signed-off-by: Christopher Snowhill <kode54@gmail.com>
2022-02-10 22:45:26 -08:00
Christopher Snowhill 740fdfa883 Attempt to wrangle memory usage from artwork
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>
2022-02-10 22:37:37 -08:00
Christopher Snowhill b927f4c02b Replace more NSDictionary use with literals
Use literals to initialize fixed NSDictionary objects in various places.

Signed-off-by: Christopher Snowhill <kode54@gmail.com>
2022-02-08 19:56:04 -08:00
Christopher Snowhill 95fb65527f Playlist Entry / SQLite: Add channel config field
Add channel config field to PlaylistEntry and the SQLite backing store.

Signed-off-by: Christopher Snowhill <kode54@gmail.com>
2022-02-07 01:11:30 -08:00
Christopher Snowhill 85c7073649 Reformat my own source code with clang-format
Signed-off-by: Christopher Snowhill <kode54@gmail.com>
2022-02-06 21:49:27 -08:00
Christopher Snowhill b0fca5127f SQLite Store: Fix updating track entries
Track entries are updated when files are added and their metadata is
later loaded. The refresh cycle was failing, because dbIndex was unset
in the new tracks, for some reason. Now it will set this when updating
the track item, assuming it read from the database in the first place.

This fixes metadata being loaded properly on adding tracks to the
playlist, as well as reloading track data manually.

Fixes #218, hopefully.

Signed-off-by: Christopher Snowhill <kode54@gmail.com>
2022-01-27 00:11:14 -08:00
Christopher Snowhill d8b16e44c7 SQLite Store / Drag and Drop: Now correctly store changes made by dragging playlist entries around to the database 2022-01-24 06:07:13 -08:00
Christopher Snowhill 6cf7d1d615 SQLite Store: Create and update database schema version properly 2022-01-22 12:43:26 -08:00
Christopher Snowhill 0c4d5002f6 Metadata: Now supports storing cuesheet tags and encoding quality status properties 2022-01-21 22:38:54 -08:00