Commit Graph

79 Commits (cdcbabd72f367ea5166285796d0b3cd2b648d4e0)

Author SHA1 Message Date
Christopher Snowhill 18af8a06df [Output] [Downmixer] Optimize a bit
Rewrite some of the output and a lot of the downmixer to use Accelerate
framework instead of dumb for loops.

Signed-off-by: Christopher Snowhill <kode54@gmail.com>
2022-06-06 08:16:27 -07:00
Christopher Snowhill 8cdbc28455 Core Audio Output: Add extra safety checks
Add safety check to check if a device is actually alive when enumerating
it, and also add nil pointer checks for the device name before trying to
CFRelease it. Fixes a rare crash on device add/remove cycle, such as
Bluetooth headphones.

Signed-off-by: Christopher Snowhill <kode54@gmail.com>
2022-03-08 00:00:34 -08:00
Christopher Snowhill 6dccaa4d7f Fixes starting playback on short files
These two changes fix playback issues with either starting in the middle
of the playlist on a really short file terminating immediately instead
of queueing more files (InputNode.m), and issues with starting playback
at all on the end of a playlist on a short file. (OutputCoreAudio.m)

Fixes #246

Signed-off-by: Christopher Snowhill <kode54@gmail.com>
2022-03-05 15:53:47 -08:00
Christopher Snowhill 4f5e4eca36 Fix visualization for variable audio block sizes
IN A.D. 2101, WAR WAS BEGINNING. *boom*

Yeah, this was a dumb bug, I didn't realize that AUAudioUnit would just
arbitrarily ignore my configured block size and request a different one.

The AirPods Pro will just request 480 instead of the 512 I ask for, so
let's instead support variable block sizes, and only take up to the last
4096 samples of the chunk fed to the output device.

Signed-off-by: Christopher Snowhill <kode54@gmail.com>
2022-02-16 21:54:55 -08:00
Christopher Snowhill 25077277b3 Add bad sample cleaner for debugging
A bad sample scanner and cleaner will point out in the log whenever a
bad sample, such as infinity, or Not a Number, or even huge values over
±2.0, in case some piece of code, or a decoder, or even a bad file, has
taken over the output.

Signed-off-by: Christopher Snowhill <kode54@gmail.com>
2022-02-15 22:48:47 -08:00
Christopher Snowhill 41efc22096 Equalizer: Bring it back to the quality it had
The quality of the equalizer dialog is now up to par with what we had
before, minus all the crashes.

Signed-off-by: Christopher Snowhill <kode54@gmail.com>
2022-02-13 23:37:58 -08:00
Christopher Snowhill 344ceb173d Visualization: Increased fft size, imported code
Boy, I just be outright stealing code now. But it looks nicer now.

Fixes #234

Signed-off-by: Christopher Snowhill <kode54@gmail.com>
2022-02-13 12:18:58 -08:00
Christopher Snowhill 7ef583340d Equalizer: Replace dialog with custom job
New custom equalizer dialog, painstakingly hand assembled.
2022-02-13 11:05:32 -08:00
Christopher Snowhill 417687600b Implement visualization support and a spectrum
Borrowing some DFT code from deadbeef, this implements a simple spectrum
visualization into the main toolbar of the app.

Signed-off-by: Christopher Snowhill <kode54@gmail.com>
2022-02-12 23:04:03 -08:00
Christopher Snowhill f4f4f80f64 Restart playback on device or output format change
Now the output is restarted on the current file at the current position
if the output format has changed. This should resolve the issue finally.

Signed-off-by: Christopher Snowhill <kode54@gmail.com>
2022-02-07 22:44:56 -08:00
Christopher Snowhill 728c44242c Do not reset output sample rate automatically
This was buggy as hell, and resulted in errors. Now the user should
restart playback if they change output device formats.

Signed-off-by: Christopher Snowhill <kode54@gmail.com>
2022-02-07 22:02:17 -08:00
Christopher Snowhill 477feaab1d Now properly supports sample format changing
Sample format can now change dynamically at play time, and the player
will resample it as necessary, extrapolating edges between changes to
reduce the potential for gaps.

Currently supported formats for this:

- FLAC
- Ogg Vorbis
- Any format supported by FFmpeg, such as MP3 or AAC

Signed-off-by: Christopher Snowhill <kode54@gmail.com>
2022-02-07 19:18:45 -08:00
Christopher Snowhill acb1dd75d3 Cog Audio: Fix memory leaks with new buffering
By applying copious amounts of autorelease pools, memory is freed in a
timely manner. Prior to this, buffer objects were freed, but not being
released, and thus accumulating in memory indefinitely, as the original
threads and functions had autorelease pools that scoped the entire
thread, rather than individual function blocks that utilized the new
buffering system. This fixes memory growth caused by playback.

Signed-off-by: Christopher Snowhill <kode54@gmail.com>
2022-02-07 04:06:36 -08:00
Christopher Snowhill 1ef8df675f Cog Audio: Implement support for channel config
This implements the basic output and mixing support for channel config
bits, optionally set by the input plugin.

Signed-off-by: Christopher Snowhill <kode54@gmail.com>
2022-02-07 01:10:05 -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 62edb39761 Cog Audio: Major rewrite of audio buffering
Rewrite attempt number two. Now using array lists of audio chunks, with
each chunk having its format and optionally losslessness stashed along
with it. This replaces the old virtual ring buffer method. As a result
of this, the HRIR toggle now works instantaneously.

Signed-off-by: Christopher Snowhill <kode54@gmail.com>
2022-02-06 03:08:34 -08:00
Christopher Snowhill 0131f7c925 Revert "Core Audio output: Rewrote major portions"
This reverts commit 637ea4efe1.
2022-02-05 04:14:03 -08:00
Christopher Snowhill 637ea4efe1 Core Audio output: Rewrote major portions
After all this rewriting, down or upmixing the audio is now handled with
the lowest latency possible, meaning that toggling the HRIR option now
takes effect immediately.

Signed-off-by: Christopher Snowhill <kode54@gmail.com>
2022-02-05 03:45:02 -08:00
Christopher Snowhill 9e5a70c9ae Cog Audio: Dealt with a major retain cycle leak
This seals up a major memory leak of the playback state whenever a chain
is released on stop or on manual track change. CogAudioMulti was
retaining the input node due to its listeners, and InputNode was not
releasing the listeners when asked to stop running. This is fixed now.

Fixes #221

Signed-off-by: Christopher Snowhill <kode54@gmail.com>
2022-01-29 21:31:19 -08:00
Christopher Snowhill cc2b27d43f Core Audio output: Potential shutdown fix
The thread wait on shutdown had the potential to lock up waiting for the
thread to shut down. Now it should at least spam the semaphores, so that
the thread should progress to shutdown a lot quicker.

Signed-off-by: Christopher Snowhill <kode54@gmail.com>
2022-01-27 00:09:40 -08:00
Christopher Snowhill bbce6880d7 Core Audio output: Add a quick safety fix
Add a safety fix for pausing and shutting down, so that we don't call
into AUAudioUnit's stopHardware function unless the stream has already
been started by the output.

Signed-off-by: Christopher Snowhill <kode54@gmail.com>
2022-01-26 15:42:28 -08:00
Christopher Snowhill c7c3c82c18 Core Audio output: Change end of file timing
Reduce the timing at which an end of file notification is sent to the
main thread from 16384 bytes to 8192 bytes. This may help with playback
of a lot of really small files, and skipping tracks.

Signed-off-by: Christopher Snowhill <kode54@gmail.com>
2022-01-25 21:55:08 -08:00
Christopher Snowhill ec7009f3fc Equalizer: Instances of GraphicEQ AU are now relinquished to the main thread for destruction instead of being destroyed by the Core Audio Output shutdown 2022-01-24 19:49:43 -08:00
Christopher Snowhill 494ad84ea7 Cog Audio: Made ring buffer locking mechanism more secure and/or smarter 2022-01-23 19:36:33 -08:00
Christopher Snowhill 502e52d699 Core Audio output: Hopefully stop buffer looping on device stop 2022-01-22 14:37:37 -08:00
Christopher Snowhill 6011982a63 Equalizer: Correctly activate the equalizer when starting playback 2022-01-22 12:59:59 -08:00
Christopher Snowhill 178b32cbdf Core Audio output: Remove all delayed track end events when buffer reset 2022-01-19 14:54:04 -08:00
Christopher Snowhill 576f1a702a Core Audio output: Hopefully really fix deadlock issue 2022-01-19 14:50:48 -08:00
Christopher Snowhill 16a58e87a0 Core Audio output: Attempt to fix deadlock near track transitions when buffer resets occur 2022-01-19 14:38:48 -08:00
Christopher Snowhill 6f0a737123 Cog Audio: Implement HDCD decoding 2022-01-19 02:08:57 -08:00
Christopher Snowhill f2feb3bcd7 Equalizer: Fix applying equalizer presets on automatic track change 2022-01-19 01:23:59 -08:00
Christopher Snowhill 31e5cd9337 Core Audio output: Add debugging code for logging output to disk, only enabled at compile time as necessary 2022-01-19 00:41:42 -08:00
Christopher Snowhill 9085cf18df Core Audio output: Fix crash on playback reaching the end of the playlist 2022-01-18 16:48:37 -08:00
Christopher Snowhill 5c0a510848 Core Audio output: Add various minor changes 2022-01-18 16:43:58 -08:00
Christopher Snowhill 83ad969d9b Equalizer: Add option for presets to track the music genre tags 2022-01-17 20:43:08 -08:00
Christopher Snowhill 87c771c67c Equalizer: Add option to toggle the equalizer on or off 2022-01-17 01:22:15 -08:00
Christopher Snowhill c8057e1037 Fix bug in new Core Audio output code 2022-01-16 14:08:17 -08:00
Christopher Snowhill 71b2f7a4f2 Implement graphic equalizer 2022-01-16 07:32:47 -08:00
Christopher Snowhill 8eb2b4c4a3 Cog Audio: Finally fix track glitching on lots of tiny tracks 2022-01-15 02:52:35 -08:00
Christopher Snowhill fbef034903 Cog Audio: Further overhaul output buffering and track queue code 2022-01-15 02:09:26 -08:00
Christopher Snowhill 5ab728b205 Cog Audio: Overhaul output buffering yet again, adding an extra buffer stage between the converter and the output thread 2022-01-14 22:46:41 -08:00
Christopher Snowhill 3cc5b46a0e Cog Audio: Improve end of track handling 2022-01-14 10:17:41 -08:00
Christopher Snowhill e6124335d1 Cog Audio: Change output callback to always retry reading for sample data until the requested buffer is filled, or until the playback either ends or is torn down. This prevents gaps when the preceding ring buffer wraps around. 2022-01-13 23:02:01 -08:00
Christopher Snowhill 5fef62dd03 Cog Audio: Implemented device output and input file format changing support 2022-01-12 21:31:22 -08:00
Christopher Snowhill 8664bacc60 Core Audio output: Correctly terminate output when requested to stop, preventing a case where multiple outputs were draining the playback buffer at once 2022-01-12 16:04:41 -08:00
Christopher Snowhill f8e3b0e1ee Core Audio output: Some more minor changes 2022-01-11 22:06:41 -08:00
Christopher Snowhill 557e0bd399 Core Audio output: Fix so it stops properly 2022-01-11 20:38:17 -08:00
Christopher Snowhill 7d4841b1c6 Core Audio output: Don't upmix unless output device requests it by default 2022-01-11 18:18:38 -08:00
Christopher Snowhill 4dd46a1b5b Core Audio output: Fix output stopping properly 2022-01-11 07:52:44 -08:00
Christopher Snowhill 72210c67e4 Replaced AudioQueue output with AUAudioUnit 2022-01-11 07:06:40 -08:00