Skip to content

Make audio stream apply real backpressure instead of erroring#10

Open
phyceClaw wants to merge 1 commit into
phyce:python-integrationfrom
phyceClaw:fix/stream-backpressure
Open

Make audio stream apply real backpressure instead of erroring#10
phyceClaw wants to merge 1 commit into
phyce:python-integrationfrom
phyceClaw:fix/stream-backpressure

Conversation

@phyceClaw

Copy link
Copy Markdown

Summary

StreamWriter.Write returned ErrStreamLimitReached once the elastic queue exceeded 64 MiB. Because dispatchFutures pre-produces whole utterances ahead of playback, a long synthesis legitimately buffers ahead and could abort mid-stream.

Write now blocks (waiting on the existing sync.Cond) until the consumer drains space, giving real backpressure while still bounding memory. It returns an error only if the stream is closed/errored while waiting, so closing always unblocks a stalled producer. Tests updated: writer blocks then proceeds after a read; closing unblocks a blocked writer.

Testing

go test -race ./app/common/audio/... passes (output in review).

🤖 Generated with Claude Code

StreamWriter.Write returned ErrStreamLimitReached once the elastic
queue passed 64 MiB, which aborted valid long syntheses that buffer
ahead via dispatchFutures. Write now blocks on the cond until the
consumer drains space, and only returns an error if the stream is
closed/errored while waiting. Tests updated for the new semantic.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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