Skip to content

Improve format detection, storefront-aware catalog lookups, and true ALAC bit depth - #8

Merged
jordanmgibson merged 5 commits into
mainfrom
dragonfly-2448-final
Jul 30, 2026
Merged

jordanmgibson merged 5 commits into
mainfrom
dragonfly-2448-final

Conversation

@jordanmgibson

Copy link
Copy Markdown
Owner

Lands the fix/dragonfly-2448-detection work, rebased onto main after #5, plus review fixes:

  • Detection + conservative fallback — tier fallback now applies an honest 24/44.1 when the rate is undetermined (with a toast) instead of a tier-derived guess; catalog matching scores performer credits and album parts; storefront resolved from the OS region with an appleMusicStorefront override.
  • Live-switch tracing — timeline/agent-audio probes across the switch, rebuild, and realign, gated behind enableVerboseDiagnostics and kept out of the timing windows they measure.
  • True ALAC bit depth — read from the ALAC magic cookie (TagLib reports the legacy 16-bit field for 24-bit Hi-Res files); lossy files apply the lowest supported depth.
  • Review fixes — bounded submultiple rate selection (176.4 kHz on a 44.1/48/96 DAC lands on 96, not 44.1), storefront validation with logged token failures, wrapped toast text, docs/CHANGELOG.
  • Cache threading — the format cache reader now uses the writer's resolved storefront and CatalogResolverVersion bumps to 2 (matching logic changed).

Full suite 229/229 green.

Catalog resolver:
- Match catalog tracks whose media-session artist is the composer by also
  comparing the performers and album packed into the album field, so
  classical tracks resolve to the correct recording without loosening the
  exact-match requirement.
- Strip the leading "By " that the Windows media session adds to the artist.
- Detect the storefront from the OS region (overridable in settings) instead
  of assuming "us".
- Log the storefront, search terms, raw result counts, and top scored
  candidates so matches and misses are diagnosable.

Local files:
- When the device does not support a file's exact rate, target the highest
  supported integer submultiple (e.g. 192 kHz -> 96 kHz) rather than giving
  up, and log when a cache file cannot be parsed.

Fallback:
- When the real rate cannot be determined, default to 24/44.1 and show a
  message (tray text always, toast when enabled) instead of guessing a
  tier-specific rate.
The lost-intro symptom (track starts a few seconds in) reproduces on some
machines but not others. Add an "Intro-trace" log line carrying the transport
timeline position and the media agent's session peak at each step of the live
switch: at mute on track change, just before applying the format, when the
render stream rebuilds, and through the schedule realign (start, paused,
resumed). This shows whether and where the timeline jumps ahead of the audio
across the rebuild and realign, so the divergence can be pinned from a log.
TagLib reports the MP4 sample entry's legacy samplesize field, which is
frequently 16 even for 24-bit Hi-Res ALAC, and exposes nothing that
distinguishes ALAC from AAC in an .m4a. Walk the atom tree to the ALAC
magic cookie for the real depth; its absence identifies the stream as
AAC. Local-file resolution now applies the file's true depth (smallest
containing depth when the device lacks an exact match) and the lowest
supported depth for lossy files instead of inflating to the device max.
Probe results carry a codec label so diagnostics can explain which depth
path was taken, and .wav/.aiff imports are probed too.
- Bound the submultiple rate preference to one octave of the best
  supported rate: a 176.4 kHz file on a 44.1/48/96 DAC now lands on 96,
  not 44.1 for the sake of an integer ratio.
- Validate the resolved storefront to two ASCII letters (OS regions can
  yield M.49 numeric codes; a hand-edited override must not reach a URL
  path) and fall back through region to 'us'. Region detection is
  injectable and the storefront tests now cover the real branches.
- Log every developer-token acquisition failure: an unacquirable token
  disables catalog resolution entirely and previously did so silently.
- Wrap toast title and message text; the new rate-undetermined message
  was clipped at 20pt in a 320px window.
- Gate per-operation diagnostics (catalog search attempts, playback
  probes) behind enableVerboseDiagnostics, which was documented but read
  nowhere. Playback probes now skip their COM session enumeration
  entirely when off, reuse the transport state the caller decided on
  instead of re-reading it, and the realign probe is captured before the
  pause so it cannot lengthen the pause->play window it measures.
- Reset TrySplitOnDashSeparator out params before returning false.
- Update README (conservative fallback, appleMusicStorefront) and add
  the unreleased CHANGELOG section for the behavior changes.
The cache keys are storefront-scoped, but after the storefront became
region-dependent the reader still keyed on the static "us" default
while the writer filed entries under the resolved storefront — a merge
of two independently-correct branches that silently missed on every
lookup for non-US users. The cache reader now takes the catalog
resolver's resolved storefront, and the verification resolver is built
with the same value so re-checks search the catalog the entry came from.

CatalogResolverVersion bumps to 2: matching now scores performer
credits and album parts, so cached results from version 1 may differ
and are rebuilt.
@jordanmgibson
jordanmgibson merged commit 9ad48e5 into main Jul 30, 2026
1 check passed
@jordanmgibson
jordanmgibson deleted the dragonfly-2448-final branch July 30, 2026 03:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant