~ knotless Search/
↑↓ move↵ open⇧↵ all results

geesawra.industries/hydraulophone

An unofficial YouTube Music app for iPhone, iPad, and Mac.

0
0
main
102 lines · 6.1 KB Raw History

Gapless playback assessment

Status: High gapless listening confirmed on physical iPhone; Standard remains a follow-up. Updated 2026-09-23.

Current architecture

Standard AAC resolves and installs one AVPlayer item at a time. High Opus uses a native WebM reader, libopus decoder, and AVAudioEngine output with about six seconds of scheduled PCM. The native High path and its Lock Screen card are confirmed on the physical iPhone.

High now resolves the immediate automatic successor during the final 45 seconds of the current track. NativeOpusPreparedTrack owns a separate range source, decoder, and decoded first buffer. At the current source's EOF, the engine schedules that first buffer immediately after the last current buffer on the same AVAudioPlayerNode. It does not stop/reconnect the node or reactivate the audio session at a normal boundary. The six-second scheduling budget spans both tracks; no complete media file is downloaded or persisted as a prefetch.

The last current buffer's .dataPlayedBack completion advances the queue and updates title, artwork, duration, progress, commands, and Last.fm occurrence state. A continuous render clock is translated to each track's local position. Mono is duplicated into stereo so both source layouts share one 48 kHz stereo output format. Codec delay and signed discard padding govern PCM trimming; approximate player-response duration must not truncate decoded audio.

Preparation follows queue occurrence identity, including Repeat One/All and shuffle. Queue changes, seek, manual selection, quality/session changes, and stop cancel stale preparation. If a queue edit changes a successor whose PCM is already scheduled, the app reseeks the current position to flush those buffers: selective unscheduling is unavailable, so this explicit edit may cause a short interruption. Pause/resume retains the scheduled boundary. Prefetch failure leaves the current track playing and falls back to ordinary fresh stream resolution at the end. It does not loop requests on every tick.

These are Hydraulophone playback choices. The existing timestamp-aligned InnerTube resolver remains unchanged; each preparation uses its ordinary High proof/player/format flow. Protocol reference remains AuraMusic YTPlayerUtils.kt at 185a77d31733047de06cbec619d40731755a0ec1. No new dependency, credentials, URL persistence, or media cache on disk is introduced.

Feasible improvement

First target reduced transition gaps within one backend and one quality:

  • Standard AAC can resolve the next occurrence while the current item plays, create a second AVPlayerItem, and queue it in an AVQueuePlayer. Queue edits, manual skips, and repeat/shuffle changes must invalidate stale prefetched items by queue-occurrence identity. The existing player is an AVPlayer, so this needs a deliberate refactor rather than a drop-in flag.
  • High Opus can resolve the next occurrence and decode its first buffers while the current track is playing, then schedule both tracks on the same player node. Keep one active source and one bounded prefetch. Carry queue-occurrence identity and track boundary markers through the output so title/artwork, progress, repeat/shuffle, and Last.fm switch only when the new track becomes audible. Codec delay and discard padding already pass through the native reader, but source boundary continuity still needs measurement. See the native Opus implementation.
  • Stream URLs are temporary playback results. Prefetch only the immediate next queue occurrence, discard it on queue/session/quality changes, and re-resolve after rejection or expiry. Do not persist URLs or reuse a rejected URL.

Apple documents AVQueuePlayer as managing a sequence of player items and starting the next item when the current one ends. That supports same-backend preparation but does not promise sample-accurate, cross-backend transitions. AVQueuePlayer documentation

Limits and acceptance

AAC-to-Opus or Opus-to-AAC transitions cross AVPlayer and AVAudioEngine. They cannot share a prepared decoder or a single item queue in the current design; a brief handoff gap is realistic. Eliminating that boundary would require a common decoded-audio output/mixer or moving both formats into one backend, which is a larger playback architecture decision.

Even within one backend, separate source encodes can contain encoder delay or padding. The app can avoid a network-resolution pause, but must not promise sample-perfect album gaplessness until source timing and decoder behavior have been measured. Validate with tracks that have known continuous transitions, record backend/quality at each boundary, and separately check repeat-one, manual next, expiring URLs, retries, and queue mutation.

Validation and next work

just simulator, just device-install, and just lint passed for the initial High implementation. The device build was installed and launched successfully, and just device-console attached for the owner's listening check. The physical console recorded gapless transition node_restarted=false during playback. The owner then confirmed the transition using Protest the Hero tracks: “It’s perfect.” This records successful subjective listening on the physical iPhone alongside the continuous-output scheduling evidence. The exact track pair was not specified; no sample-level acoustic measurement is claimed. Automated tests remain deferred; the scenarios are recorded in gapless-playback.md. Repeat/shuffle, queue mutation, interruptions, and longer locked-device playback still need dedicated acceptance. A debug transition marker records whether the common output node was preserved, without song identifiers or stream URLs.

Next measure transition silence and stale-prefetch cancellation, then consider AVQueuePlayer for Standard. Keep cross-quality handoff behavior explicit.