# Native WebM Opus reader verification brief No automated tests were added at the owner’s request. The reader is integrated into native High playback; deferred fixture coverage should include: - Parse a small WebM with Info and Tracks before Clusters; verify OpusHead channels and Q7.8 output gain, fixed 48 kHz output, CodecDelay, SeekPreRoll, and duration. - Exercise short random reads, cancellation between reads, truncated EBML varints, integer/offset overflow, metadata and block size caps, and EOF on an unknown-size Segment. - Decode SimpleBlock and BlockGroup packets, positive and negative DiscardPadding, and Xiph, fixed, and EBML lacing. Check laced packet timestamps against Opus packet durations. - Verify `prepare()` stops after metadata and the first Cluster header when SeekHead provides metadata positions; startup must not walk the track. - Seek using Cues and SeekHead into a late Cluster. Confirm seek positions at the selected Cluster start so the decoder receives preroll and negative CodecDelay timestamps. For a cue-less file, verify the index is built only on the first seek and reads Cluster/block headers while skipping frame payload ranges, then seeks to the nearest prior Cluster. - Exercise unknown-size Clusters followed by another Cluster and by Cues; malformed unknown-size nested elements must fail without scanning past a parent boundary. - Fuzz EBML element sizes and lacing headers with bounded read callbacks; no malformed input should trap or allocate beyond the documented limits. The parser is a Foundation-only transport/domain component. Its reader closure must return at most the requested number of bytes, may return a short read, and uses an empty `Data` at EOF. The async adapter must preserve cancellation and must not turn a media range failure into EOF. ## Protocol references consulted - [Matroska Element Specification](https://www.matroska.org/technical/elements.html) (IDs and element field semantics for Info, Tracks, Cluster, Block, Cues, CodecDelay, SeekPreRoll, and DiscardPadding). - [Matroska Codec Mappings: Opus](https://www.matroska.org/technical/codec_specs.html) (A_OPUS initialization, OpusHead, 48 kHz pre-skip mapping, CodecDelay, and 80 ms SeekPreRoll recommendation). - [Matroska Cues](https://www.matroska.org/technical/cues.html) and [Matroska Ordering](https://www.matroska.org/technical/ordering.html) (CueClusterPosition interpretation and the recommended seek index). - [RFC 8794: Extensible Binary Meta Language](https://www.rfc-editor.org/rfc/rfc8794) (EBML variable-length IDs and sizes). - [RFC 7845, Section 5.1](https://www.rfc-editor.org/rfc/rfc7845#section-5.1) (Opus Identification Header layout). This reader currently accepts only major version 0, mapping-family-0 mono/stereo streams because the current decoder uses the single-stream Opus API. The implementation is an independent Swift implementation based on these public format specifications; it does not copy third-party parser code. ## Native decoder and output follow-up - Decode a known stereo signal and verify left/right separation, 48 kHz sample count, OpusHead gain, codec-delay trimming, and signed discard padding. - Seek to zero and inside a packet, including while paused. Verify that the first packet's negative timestamp does not drop audible post-delay samples. - Cancel a seek while a range is pending, immediately seek elsewhere, and verify no old decoder state, PCM buffer, completion, or position is published. - Exhaust the output queue with a controlled slow range reader; the clock and Last.fm listened time must freeze until output resumes. Reject an expired range URL and verify the controller refreshes the stream at the saved time. - Pause during a seek, switch tracks during preparation, and repeat a short track to completion. Verify output ownership, queue advancement, and that cancelled playback cannot restart. - On a physical iPhone, exercise a long locked-screen session, headset removal, interruption/resume, output sample-rate changes, and remote seeking. Live evidence: `just simulator-smoke-high` passed native stereo playback, unbuffered 65%/90% seeks, pause/resume, and switching both qualities. The native build was installed with `just device-install`; the owner confirmed faster High startup and a working Lock Screen card. These checks do not replace the deferred fixture and state-transition coverage above.