Skip to content

opus-pure 0.2.2

Latest

Choose a tag to compare

@stephenberry stephenberry released this 28 Sep 09:35

A looping playback (read, decode, trim, and at the end rewind, reset, new Trim) now allocates nothing after its first pass, which matters on an audio thread where an allocation can take a lock.

Added

  • OggOpusReader::read_packet_into fills an OggPacket the caller keeps, where read_packet returns a new one. OggPacket::default() is the empty one to start from.
  • OggOpusReader::rewind returns a seekable source to the first audio packet without reading the header pages again. It replaces rebuilding the reader to loop.

Changed

  • Reading and decoding no longer allocate once warm, loop points included: the Ogg reader reassembles packets in one reused buffer, the packet parser holds its frame table inline, the range decoder borrows the packet, and the multistream decoder reuses one buffer per stream. tests/ogg_playback_alloc.rs holds it to zero.
  • OpusDecoder::reset_state resets in place instead of building a new decoder, so it no longer allocates; a reset decoder still decodes bit for bit as a new one.
  • The Ogg reader refuses a stream whose comment header does not finish its page, as RFC 7845 §3 requires and libopusfile enforces, and caps a reassembled packet at 16 MiB, so a hostile chain of continued pages cannot grow its buffer without limit.
  • RangeCoder::shrink checks its size preconditions in release builds.

Additive otherwise: nothing was removed from the 0.2.1 public surface.