Design a Multi-Stage Audio Buffer Pipeline
Design an ordered real-time audio pipeline whose bounded stage buffers make overload, lifecycle, and ownership explicit.
For this exercise, assume an audio pipeline has capture, transform, and output stages running at a configured number of frames per second. Frames have a stable sequence number, timestamp, format, and payload. A single-owner frame lease carries each frame between stages.
Adjacent stages exchange leases through fixed-capacity FIFO buffers: ACCEPTED and ITEM transfer ownership, while FULL and CLOSED leave ownership with the caller. Accepted frames must remain ordered and every lease must be released exactly once.
Graceful close rejects new submissions and drains accepted work; a processor failure fails the whole pipeline and triggers bounded cleanup. Persistent media storage, device drivers, codec internals, and distributed processing are outside scope.
Design the object model, interfaces, interactions, and failure behavior. Then implement precise pseudocode for the bounded lease buffer.