Skip to content

feat: add native loop end points #498

Description

@Kunstderfug

Description

Add a native end point for loop regions. flutter_soloud already exposes a loop start through loopingStartAt and getLoopPoint / setLoopPoint, but looping always wraps at the natural end of the source. This makes sample-accurate regions inside a longer source impossible.

The end point needs to be enforced by the native mixer while it fills source buffers. Dart-side timers or post-buffer checks can overshoot the requested boundary.

Requirements

  • Add an optional loopingEndAt parameter alongside loopingStartAt on the regular, 3D, source, and bus playback APIs.
  • Add live-handle getLoopEndPoint and setLoopEndPoint APIs; null clears the end point and restores natural-EOF looping.
  • Treat a region as half-open: [loop start, loop end).
  • Reject negative start values and end values that are not later than the start.
  • Enforce the boundary in native source-frame reads without overshooting a mixer block, including the inaudible-tick path.
  • If an end point is beyond the source duration, keep the existing natural-EOF behavior.
  • Preserve current first-pass behavior for each playback API and require a source that can seek back to the loop start.
  • Cover short regions, exact buffer boundaries, natural EOF fallback, clearing the end point, and invalid ranges with deterministic tests.
  • Keep FFI and web/WASM APIs in parity and document the new contract.

Additional Context

The missing end point was discussed while loop-start support was introduced in #43, and the underlying SoLoud limitation was also called out in jarikomppa/soloud#15. The implementation should live at the generic mixer seam so it works consistently across supported source types rather than only for one decoder.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions