Skip to content

ESP/Speaker: Reduce amplifier and playback buffer allocations - #165

Merged
ao-david merged 2 commits into
speaker/pr01-netsender-fixesfrom
speaker/pr02-audio-buffers
Oct 29, 2026
Merged

ao-david merged 2 commits into
speaker/pr01-netsender-fixesfrom
speaker/pr02-audio-buffers

Conversation

@ao-david

Copy link
Copy Markdown
Member

Stacked on #164.

Store the I2S channel handle by value instead of allocating a wrapper on
the heap. The channel is now released with i2s_del_channel() in the
TAS5805 destructor, and copying the amplifier is explicitly disabled to
prevent double frees.
Allocate the file, staging, and I2S buffers lazily on the first playback
pass and keep them for the lifetime of the amplifier. This removes the
repeated allocation and freeing of large blocks that occurred every time
play() was called. The buffers are released by the destructor.

Unsupported WAV layouts are now rejected before reading, since the file
buffer is sized for at most two channels.
@ao-david
ao-david added this pull request to stack #173 October 29, 2026 06:47
@ao-david
ao-david merged commit 1f4cbbe into main Oct 29, 2026
2 checks passed
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.

1 participant