geesawra.industries/hydraulophone
An unofficial YouTube Music app for iPhone, iPad, and Mac.
Native Opus playback feasibility
Status: implemented; native High and the media card confirmed on iPhone. Updated
2026-09-23. Native Opus is the default High backend. The previous WebKit
backend remains available only with the -HydraulophoneWebKitOpus diagnostic
launch argument.
Why investigate
The authenticated InnerTube High path returns playable WebM/Opus media. On the
physical iPhone, Hydraulophone's WKWebView decodes it and plays reliably when
the host AVAudioSession is deactivated. The iOS 27 Lock Screen then shows
transport controls and progress without title or artwork. Standard AAC uses
AVPlayer, activates the host playback session, and does show metadata and
artwork. A nonmixable host session interrupted WebKit playback; a mixable one
did not gain system-primary ownership. WebKit's MediaMetadata assignment
also did not populate the card. See native media evidence.
InnerTube supplies player metadata and expiring media URLs; it does not decide
which iOS process owns the Lock Screen card. The pinned AuraMusic reference
(commit 185a77d,
player utilities)
is an Android Media3 playback implementation, so its InnerTube request shapes
transfer but its audio-session behavior does not. Metrolist's
playback service
is another Android reference. Its stream URL cache proposal
concerns expiry and recovery, not iOS media-session ownership.
Native implementation
WebMOpusReader extracts individual Opus packets and timestamps from bounded
HTTP range reads. It is an original Foundation-only Swift implementation based
on the public Matroska/EBML and Opus format specifications, including Cues,
SeekHead, all three lacing modes, CodecDelay, SeekPreRoll, and signed
DiscardPadding. Startup stops at the first Cluster. Missing cluster indexes
are built on demand for seeking; media payloads are skipped while indexing.
The supported track profile is mapping-family-0 mono/stereo Opus. See the
reader brief and specification references.
alta/swift-opus
is pinned at 6f3cb6bd3ffed1fe5f06d00a962d5c191a50daf8 in project.yml.
Its Copus product builds libopus revision
101a71e03bbf860aaafb7090a0e440675cb27660 from source. Hydraulophone uses that
public C decoder through NativeOpusDecoder, which validates packet sizes,
decodes at 48 kHz, applies OpusHead output gain, and produces noninterleaved
Float32 PCM. This is an app-owned AVAudioEngine/AVAudioPlayerNode pipeline;
it does not register a codec with AVPlayer. The package and codec notices
ship in OPUS_LICENSES.txt in the application bundle.
NativeOpusByteSource keeps eight 64 KiB chunks in an ephemeral in-memory LRU.
It reuses the existing media transport's credential-free, bounded-response,
redirect-checked URLSession. It requires HTTP 206 and matching Content-Range,
and never writes URLs or audio to disk. This packet reader uses smaller reads
than the AAC AVAssetResourceLoader's 512 KiB policy because the consumer is a
sequential demuxer, not AVPlayer's resource-loading callbacks.
NativeOpusPCMSource confines the decoder and demuxer to an actor. It decodes
preroll and trims samples before the seek target and at source padding. The
main-actor output engine schedules about six seconds of PCM, reports actual
render timing, freezes the timeline on underrun, and refills before resuming.
Cancelled seeks join earlier work before resetting decoder state. The existing
controller retains queue, repeat/shuffle, Last.fm progress, retry/stream refresh,
and remote-command policy. Standard AAC continues through AVPlayer.
Native High activates the same nonmixable AVAudioSession as Standard.
On iOS 27 it uses the existing NowPlaying MediaSession; older supported iOS
versions use the native MediaPlayer publisher. The InnerTube request, proof,
format selection, timestamp alignment, and expiring URL resolution are unchanged.
The native baseline prepared only the selected track. The subsequent gapless implementation adds a bounded prepared successor and adjacent PCM scheduling on the same output node.
Recorded validation
just simulatorbuilt and launched the native path on iPhone 18 Pro / iOS 27.just simulator-smoke-highpassed with an authenticated 690.241-second stereo Opus stream: continuous playback, unbuffered 65%/90% seeks, pause/resume, and High-to-Standard-to-High switching, with no retry.- Cold native readiness took 236 ms after stream resolution; verified progress arrived at 3.319 seconds from selection. Returning to High took 92 ms to become ready after resolution and 1.997 seconds total including a seek back to the previous position. These are simulator timings, not iPhone claims.
just lintandgit diff --checkpassed. Automated tests remain deferred at the owner's request; briefs are on disk.just device-installbuilt, installed, and launched on the paired physical iPhone. The owner confirmed faster High startup and a working Lock Screen card. Device first-progress timings were 3.716 seconds cold, then 2.504, 2.731, and 2.491 seconds; native readiness added 109–280 ms after resolution. Sustained background and route/interruption validation remain follow-ups.
Remaining acceptance
- When automated tests resume, verify stereo PCM against a known signal and fixture decoding across supported iOS versions.
- Extract packets and timestamps from a small, sanitized WebM/Opus fixture, then decode them into PCM with correct channel count, sample rate, codec delay, and duration. Preserve source license and provenance if a demuxer is adapted or vendored.
- On device, verify long background playback, headphone/remote commands, interruptions, route changes, rapid cancelled seeks, and automatic queue advancement. Startup and Lock Screen operation are confirmed; dedicated coverage for those additional cases remains on the test brief.
The native path has passed the live simulator check and physical media-card confirmation. Gapless listening acceptance is tracked in the subsequent ADR.