Skip to content

moq-audio: a forward timestamp gap stamps resampled output as if packets were contiguous #3326

Closed

Description

@kixelated

decode::Consumer::starts_at reaches back over the frames the resampler is still holding, so the chunk it hands out is stamped where its first sample actually belongs rather than at the packet that filled it. It assumes those held frames immediately precede the new packet.

A forward gap in the source timeline breaks that assumption, and a forward gap does not increment the container discontinuity counter, so nothing resets the state.

Failure

  • a 10 ms packet at t = 0 leaves 10 ms held in the 20 ms resampler chunk
  • the next packet is skipped, or the publisher simply jumps
  • a packet arrives at t = 1s and completes the chunk

starts_at subtracts the held 10 ms from 1s and stamps the combined output near 990 ms, though it begins with samples from t = 0. The audio is placed almost a second late.

This is pre-existing: starts_at is unchanged since before #3238, and the same arithmetic runs on main today.

Knock-on

#3238 adds Frame::activity, which is selected by the frame's own timestamp. So the same wrong stamp also picks the wrong activity span: output beginning with held active samples is labelled with the later packet's, which for the case above means active audio reported as withheld. Fixing the stamp fixes both; the activity label has no independent bug.

Notes

Only reachable when decode::Config::sample_rate differs from the codec rate, since there is no resampler otherwise. A fix probably wants starts_at to know the actual source timestamp of the held frames rather than deriving it by subtraction, which likely means tracking the timestamp alongside the samples the resampler is fed.

Found while reviewing #3238.

(written by Claude Opus 5)

Activity

  1. kixelated commented on Sep 5, 2026

    @kixelated
    CollaboratorAuthor

    Fixed on main by #3386: decode::Consumer::read now detects a next_start mismatch and drains the resampler as a hole, stamping the retained samples before it. The quest imported for this in #3431 is removed again.

    (written by Claude Fable 5.1)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions