Commit graph

671 commits

Author SHA1 Message Date
Christopher Snowhill
a0a9f79592 HRTF: Fix deadlock with restarting motion tracking
Some checks failed
Check if Cog buildable / Build Universal Cog.app (push) Has been cancelled
Motion tracking was storing a strong reference to the HRTF DSP node,
which was resulting in the DSP not shutting down or restarting properly,
leading to playback hanging.

Signed-off-by: Christopher Snowhill <kode54@gmail.com>
2025-06-24 05:00:54 -07:00
Christopher Snowhill
47f50052be Housecleaning: More project file cleanups
Some checks are pending
Check if Cog buildable / Build Universal Cog.app (push) Waiting to run
This also fixes code signing for VGMStream bundle. All frameworks or
bundles which nest other frameworks or libraries must themselves be
signed first in building, not just on embedding.

Signed-off-by: Christopher Snowhill <kode54@gmail.com>
2025-06-24 03:54:22 -07:00
Christopher Snowhill
b5a999999a HRTF: Re-enable motion control on newer systems
Motion control, which requires macOS 14.0, was broken completely, ever
since the changes made to the code so it could compile on older Xcode
versions.

Signed-off-by: Christopher Snowhill <kode54@gmail.com>
2025-06-24 03:54:09 -07:00
Christopher Snowhill
234fb63267 Housecleaning: Cleaned up a bunch of warnings
And a bunch of potential memory leaks, and some misbehavior that could
occur due to not checking for errors properly.

Signed-off-by: Christopher Snowhill <kode54@gmail.com>
2025-06-24 03:54:05 -07:00
Christopher Snowhill
d220667deb Output: Halve volume when downmixing to mono
Signed-off-by: Christopher Snowhill <kode54@gmail.com>
2025-06-24 03:54:02 -07:00
Christopher Snowhill
972a7604bd Maintenance: Update project file settings
Some checks are pending
Check if Cog buildable / Build Universal Cog.app (push) Waiting to run
Promote or demote all projects to Xcode 12.0, remove signing from any
libraries or frameworks that still have it, and clear identities in the
project files, so that they will derive from the out of repo local
settings file, and will stop inserting my ID into projects every time
they are modified.

Signed-off-by: Christopher Snowhill <kode54@gmail.com>
2025-06-24 00:40:03 -07:00
Christopher Snowhill
5ea0640c68 Output: Remove function override from header
This function should be derived from the superclass.

Signed-off-by: Christopher Snowhill <kode54@gmail.com>
2025-06-24 00:39:55 -07:00
Christopher Snowhill
9951b7cb6a Output: Add more setup and format error checking
Some checks failed
Check if Cog buildable / Build Universal Cog.app (push) Has been cancelled
Add setup error checking and failure states, and also add a failure
state for format changes while the device is already running, in case it
returns a nil format structure.

Signed-off-by: Christopher Snowhill <kode54@gmail.com>
2025-06-22 20:59:26 -07:00
Christopher Snowhill
857ea20512 Project: Change path to project relative
Some checks failed
Check if Cog buildable / Build Universal Cog.app (push) Has been cancelled
From group relative.

Signed-off-by: Christopher Snowhill <kode54@gmail.com>
2025-06-20 19:44:05 -07:00
Christopher Snowhill
01ea0435d0 Metadata: Add helper for optional values
Add NSDictionary initWithOptionalObjects:forKeys:count: helper, to work
around several places that may have been setting nil dictionary valies
on placeholder dictionaries. Hopefully this fixes the crash someone
logged recently.

Signed-off-by: Christopher Snowhill <kode54@gmail.com>
2025-06-20 19:44:00 -07:00
Christopher Snowhill
43e4dc4955 Bug Fix: Check memory allocations for FFT state
Signed-off-by: Christopher Snowhill <kode54@gmail.com>
2025-06-13 18:50:02 -07:00
Christopher Snowhill
7988d3be32 Bug Fix: Free FFT/DFT state on shutdown
Signed-off-by: Christopher Snowhill <kode54@gmail.com>
2025-06-13 18:49:58 -07:00
Christopher Snowhill
b693c946b8 Bug Fix: Zero out DFT state pointer on free
Signed-off-by: Christopher Snowhill <kode54@gmail.com>
2025-06-13 18:49:53 -07:00
Christopher Snowhill
6340b08308 Visualization: Rewrite FFT calculation code
Some checks are pending
Check if Cog buildable / Build Universal Cog.app (push) Waiting to run
This code, based on some other vDSP information I found, performs the
DFT in a different fashion, and also pre-converts the spectrum data into
decibel levels, so the DeaDBeeF analyzer calculation code doesn't need
to convert the values itself any more.

Maybe this will also get rid of the use after free problem somewhere in
the audio code? Who knows?

Signed-off-by: Christopher Snowhill <kode54@gmail.com>
2025-06-12 19:56:43 -07:00
Christopher Snowhill
78ec3d39eb Bug Check: Handle null pointers in FFT code
This shouldn't happen, but it should be guarded properly nonetheless.

Signed-off-by: Christopher Snowhill <kode54@gmail.com>
2025-06-12 19:56:38 -07:00
Christopher Snowhill
23be3b7f03 Bug Fix: Prevent track transition race condition
A race on the source queue setter could cause a crash. Prevent that by
not attempting to set a nil input node.

Signed-off-by: Christopher Snowhill <kode54@gmail.com>
2025-06-11 19:03:25 -07:00
Christopher Snowhill
cb9c4d9c01 Bug Fix: Stop track fades from hanging on occasion
Track fades could hang if fired in rapid succession. Now each fade will
be guaranteed to resume input feeding upon removing the current input to
the background fade-out queue.

Signed-off-by: Christopher Snowhill <kode54@gmail.com>
2025-06-11 19:03:21 -07:00
Christopher Snowhill
dfd95b0a37 Rubberband: Fix end of track reset for threading
This end of track restart notification may come from a different thread
than the processing thread. Wait on the thread to complete.

Signed-off-by: Christopher Snowhill <kode54@gmail.com>
2025-06-07 05:43:50 -07:00
Christopher Snowhill
0e06f5457c Bug Fix: Add some safety checks to URL handlers
Some checks failed
Check if Cog buildable / Build Universal Cog.app (push) Has been cancelled
A few places could have used nil checks, but there shouldn't be anything
passing nil URLs to these. Well, just in case, at least it won't lead to
crashes or something...

Signed-off-by: Christopher Snowhill <kode54@gmail.com>
2025-06-06 01:27:54 -07:00
Christopher Snowhill
048bc7c30d Converter Node: Change volume scale observer
This should fix an exception being thrown because the observer wasn't
registered, or known to be registered. Only register it when it will be
used, and only unregister it if it was registered.

Signed-off-by: Christopher Snowhill <kode54@gmail.com>
2025-05-03 01:56:29 -07:00
Christopher Snowhill
5753c48245 HDCD: Stop dynamically halving the volume
Some checks failed
Check if Cog buildable / Build Universal Cog.app (push) Has been cancelled
Apparently, this doesn't work too well with real HDCD tracks, and causes
all sorts of weird volume issues. Just leave the volume alone, and let
HDCD decoding make tracks louder, possibly, rather than try to halve the
volume automatically on a detector that isn't terribly good.

Signed-off-by: Christopher Snowhill <kode54@gmail.com>
2025-04-24 14:55:33 -07:00
Christopher Snowhill
3b4313d844 HDCD: Fix how unsigned audio may be processed
Unsigned will alter the input, so move it like the other integer sample
processors do.

Signed-off-by: Christopher Snowhill <kode54@gmail.com>
2025-04-24 14:55:29 -07:00
Christopher Snowhill
a92973c6aa HDCD: Make HDCD extension processing optional
Some checks are pending
Check if Cog buildable / Build Universal Cog.app (push) Waiting to run
And disabled by default, at that. I can't actually hear the difference
of Peak Extension in the Rock track I have that claims to use it. And
Low Level Range Extension is more trouble than it's worth on tracks that
use it by mistake, or maliciously, if the case may be. I may add track
tag level control in the future.

Signed-off-by: Christopher Snowhill <kode54@gmail.com>
2025-04-23 21:44:06 -07:00
Christopher Snowhill
9a23ff9ff9 Audio Output: Optimize fader function
Now using Accelerate methods to calculate and multiply ramps per channel
and add the remainder if necessary.

Signed-off-by: Christopher Snowhill <kode54@gmail.com>
2025-03-27 17:13:47 -07:00
Christopher Snowhill
2282538c42 Bug Fix: Fix inserting empty chunks on track ends
This code did not check the number of samples in a packet before adding
it to the output buffer, which apparently had the potential to cause the
output code to emit up to 512 samples of silence between tracks. This,
as one can guess, is a bad thing, and causes noticeable gapping between
tracks.

Signed-off-by: Christopher Snowhill <kode54@gmail.com>
2025-03-26 20:10:13 -07:00
Christopher Snowhill
73951d6fe7 Bug Fix: Fix output logging, switch log method
Output logging, a debugging feature that is only enabled at build time
if I need to chase down some audio mixing or output bug, was not logging
anything at all. Change to use Cocoa file writing methods, and actually
implement the output writer function again.

This code is left disabled 99% of the time anyway, and especially in
release builds. Like the node logging code elsewhere, it has the
potential to be very noisy and consume massive amounts of disk space.

Signed-off-by: Christopher Snowhill <kode54@gmail.com>
2025-03-26 20:10:08 -07:00
Christopher Snowhill
8c019c7302 Bug Fix: Include soxr latency in memory allocation
This should be included, for safety purposes, in case the rounding up to
the nearest multiple of 256 samples doesn't bump the buffer size enough.

Signed-off-by: Christopher Snowhill <kode54@gmail.com>
2025-03-26 20:10:03 -07:00
Christopher Snowhill
9b683a9c56 Bug Fix: Reorder LPC scratch memory for alignment
The double members should be ordered first so they are aligned to an 8
byte boundary. The rest are fine as-is.

Signed-off-by: Christopher Snowhill <kode54@gmail.com>
2025-03-23 00:05:19 -07:00
Christopher Snowhill
7cb010e337 Code Fix: Add nullability flags to Vis Manager
The Visualization Manager PCM/FFT copy function was already observing
these parameters for null input and only returning output to the ones
which were not null. This just makes it clear that they are both
optional parameters. This is useful for future visualization adventures,
allowing PCM copy without invoking the FFT processing, or requesting FFT
without also having to keep the PCM.

This is mostly only a compile time change, and has no noticeable effect
on the current runtime behavior, as the only consumers of the Visualizer
data currently request both PCM and FFT.

Signed-off-by: Christopher Snowhill <kode54@gmail.com>
2025-03-13 19:51:22 -07:00
Christopher Snowhill
2401536e5c Crash Fix: Only selectively register observer
This affects User Defaults, but only has any effect on ChunkLists which
are being used for conversion, and only if they're processing DSD source
material. Thus, the observer should only be added on the one stream that
is converting DSD, and should definitely be removed when the object is
deallocated.

This fixes a serious crash bug that mostly appears to only affect Intel
Macs, and has no major side effects on Apple Silicon that I can tell.
It's a good thing I still own an Intel Mac or two to test on, even if
they are both trapped on older releases of macOS.

Signed-off-by: Christopher Snowhill <kode54@gmail.com>
2025-03-13 19:51:12 -07:00
Christopher Snowhill
a1bbfbe3ac Bug Fix: Track advancing when Rubber Band disabled
Apparently I somehow didn't notice this situation because I still had
Rubber Band enabled, and existing users kept it enabled ever since I
introduced it.

Signed-off-by: Christopher Snowhill <kode54@gmail.com>
2025-03-11 14:30:09 -07:00
Christopher Snowhill
2cc7ff9c4a Core Audio: Implement proper fade on seek
Whew, what a mess! And this may pave the way for crossfading.

Signed-off-by: Christopher Snowhill <kode54@gmail.com>
2025-03-10 23:09:03 -07:00
Christopher Snowhill
54c9f30e8a Bug Fix: Don't display notification on seek
Signed-off-by: Christopher Snowhill <kode54@gmail.com>
2025-03-10 23:08:57 -07:00
Christopher Snowhill
a09907ccd9 Metadata: Move encoding helper to CogAudio
Move this commonly used string decoding helper to the CogAudio framework
and import it in every plugin that uses it.

Signed-off-by: Christopher Snowhill <kode54@gmail.com>
2025-03-10 14:55:56 -07:00
Christopher Snowhill
5d73246926 Bug Fix: Handle invalid UTF-8 decoding errors
Apparently, stringWithUTF8String: just returns nil when the encoding is
not UTF-8, rather than throwing an exception.

Signed-off-by: Christopher Snowhill <kode54@gmail.com>
2025-03-10 14:55:51 -07:00
Christopher Snowhill
532d22b9bb App Store: Add encryption attestation
Finally add this to Info.plist properties to save a few seconds on
submissions.

Signed-off-by: Christopher Snowhill <kode54@gmail.com>
2025-03-09 23:50:35 -07:00
Christopher Snowhill
f8ee7e5e46 Core Audio: Fix pausing glitches
Signed-off-by: Christopher Snowhill <kode54@gmail.com>
2025-03-09 14:43:16 -07:00
Christopher Snowhill
afeb614481 Bug Fix: Actually perform a fade in
It doesn't fade if we don't advance the sample pointer. Ugh.

Signed-off-by: Christopher Snowhill <kode54@gmail.com>
2025-03-08 00:38:56 -08:00
Christopher Snowhill
63a5239346 Core Audio: Slight change to audio fade in on seek
Signed-off-by: Christopher Snowhill <kode54@gmail.com>
2025-03-08 00:38:50 -08:00
Christopher Snowhill
0570ebedea Core Audio: Increase fade duration to 125ms
Signed-off-by: Christopher Snowhill <kode54@gmail.com>
2025-03-07 23:44:46 -08:00
Christopher Snowhill
1d8803e6f2 Core Audio: Shut off device after fade out
And resume playback before fade in.

Signed-off-by: Christopher Snowhill <kode54@gmail.com>
2025-03-07 23:44:24 -08:00
Christopher Snowhill
46aac2fa91 Core Audio: Add a slight fading to operations
Add 10 millisecond fade to seeking, pausing and unpausing, and stopping
on command.

Signed-off-by: Christopher Snowhill <kode54@gmail.com>
2025-03-07 23:22:29 -08:00
Christopher Snowhill
ff5a1c6c2c Bug Fix: Prevent hangs when starting paused
This happens when the player is resumed paused, sometimes near the end
of a track.

Signed-off-by: Christopher Snowhill <kode54@gmail.com>
2025-03-07 20:14:39 -08:00
Christopher Snowhill
d3f99f8987 Bug Fix: Simplification of chunk duration check
This only needs to check that the chunk is empty, not its exact
duration.

Signed-off-by: Christopher Snowhill <kode54@gmail.com>
2025-03-07 17:28:09 -08:00
Christopher Snowhill
aafe817a1f Bug Fix: Correct playback of DSD formats
DSD formats were buffering incorrectly and terminating way too soon.

Signed-off-by: Christopher Snowhill <kode54@gmail.com>
2025-03-07 17:28:04 -08:00
Christopher Snowhill
36a2d8efd5 Bug Fix: Restart converter on format change
The converter doesn't just require an output format call, it also
requires this input format change callback to actually signal it to
reopen the converter process with a new format setup.

Signed-off-by: Christopher Snowhill <kode54@gmail.com>
2025-03-07 05:39:17 -08:00
Christopher Snowhill
17b8647052 Bug Fix: Ensure robust output format changes
Output format mostly requires stopping and restarting the output device,
and this also prevents us from using the latency function properly,
which apparently always returns 0 for output devices anyway. These
changes also prevent the output callback from hanging when resets occur.

Signed-off-by: Christopher Snowhill <kode54@gmail.com>
2025-03-07 05:39:12 -08:00
Christopher Snowhill
25d6f6ea7c Quality of Life: Make buildable with old Xcode
Make the code mostly buildable with Xcode as old as 13.2.1, for debug
testing on Big Sur.

Signed-off-by: Christopher Snowhill <kode54@gmail.com>
2025-03-07 04:39:59 -08:00
Christopher Snowhill
b41fd74f31 Bug Fix: Default output device changes monitoring
Fix default output device logging, and also the preferences if no
default device happens to be set.

Signed-off-by: Christopher Snowhill <kode54@gmail.com>
2025-03-06 14:41:28 -08:00
Christopher Snowhill
72bfe1c846 Bug Fix: Latency reporting for high latency output
Fixes visualization latency under virtual machines, at least. Not sure
which local or native systems would be reporting high latency here, but
this should fix them as well.

Signed-off-by: Christopher Snowhill <kode54@gmail.com>
2025-03-06 13:14:41 -08:00