Skip to content

mux: consume buffered samples without moving them - #299

Merged
hajimehoshi merged 1 commit into
ebitengine:mainfrom
kumagi:perf/mix-ring-buffer
Sep 15, 2026
Merged

hajimehoshi merged 1 commit into
ebitengine:mainfrom
kumagi:perf/mix-ring-buffer

Conversation

@kumagi

@kumagi kumagi commented Sep 15, 2026

Copy link
Copy Markdown
Contributor

Introducing ring buffer to improve the speed.

Consuming samples in readBufferAndAdd moved all the remaining buffered bytes to the front of the buffer on every audio callback. Track the consumed offset instead and compact the buffer lazily when it is refilled, i.e. once per wrap-around instead of once per callback.

Consuming samples in readBufferAndAdd moved all the remaining buffered
bytes to the front of the buffer on every audio callback. Track the
consumed offset instead and compact the buffer lazily when it is
refilled, i.e. once per wrap-around instead of once per callback.

@hajimehoshi hajimehoshi left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@hajimehoshi
hajimehoshi merged commit 1e2b76a into ebitengine:main Sep 15, 2026
9 checks passed
@kumagi
kumagi deleted the perf/mix-ring-buffer branch September 16, 2026 08:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants