fix: restore sample rate switching and add restart option - #217
Open
kush2shah wants to merge 1 commit into
Open
Conversation
Builds on the v3 log-streaming rework and makes it actually switch, plus hardens process/app lifecycle. - LogReader: pass `--level debug` to `log stream`. The Music format lines we parse (`play> cm>>` / asbdSampleRate / sdBitDepth) are logged at debug level, which `log stream` withholds unless debug level is requested. Without this the reader received zero entries and nothing ever switched. - LogReader: terminate the `log stream` subprocess on quit/restart (it was otherwise orphaned), buffer partial pipe reads so split lines parse correctly, and respawn the stream if it dies so switching doesn't silently stop. - Consolidate to a single shared OutputDevices / MediaRemoteController. Both AppDelegate and MenuBarController were each creating their own, so two log readers and two controllers raced to set the device sample rate. - OutputDevices: bound the format collection so it doesn't grow for the life of the app. - Add a "Restart LosslessSwitcher" menu item; clean up child processes in applicationWillTerminate. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01RprYxphRxr3sFMoySavZzW
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Builds on top of the
v3log-streaming rework. In testing on macOS 27, v3 detected tracks but never actually switched the device sample rate. This PR fixes that and hardens the process/app lifecycle, and adds a Restart option.The switching fix (main one)
Music logs the format lines this branch parses —
play> cm>>/asbdSampleRate/sdBitDepth— at debug level.log streamwithholds debug-level messages unless you explicitly request them, soLogReaderwas receiving zero entries and nothing ever switched.Verified directly with the app's exact predicate:
--level debug:0lines--level debug: full stream, including e.g.... play> cm>> mediaFormatinfo '<private>' , ... sdFormatID = alac, ... sdBitDepth = 16 bit, asbdSampleRate = 44.1 kHzAfter adding the flag, driving track changes shows the pipeline resolving the device format end-to-end (
NEAREST FORMAT [...mSampleRate: 44100.0...]).Other fixes
AppDelegateandMenuBarControllerwere each creating their ownOutputDevices+MediaRemoteController, so two log readers and two controllers raced to set the device sample rate (and doubled the helper processes). Consolidated to one shared instance owned byAppDelegate.LogReadernow terminates thelog streamsubprocess on quit/restart (it was previously orphaned), buffers partial pipe reads so a line split across two reads still parses, and respawns the stream if it dies so switching doesn't silently go dead.New feature
applicationWillTerminate, which both Quit and Restart go through.Testing
xcodebuild ... build).log streamsubprocess (was two before consolidation).log streamprocess.Note: because these are debug-level logs, this is validated against how Music logs on current macOS; if a future Music build moves the format line to a different category/level the predicate would need revisiting.
🤖 Generated with Claude Code