How Ecasound -B Modifies Internal Buffering
The -B parameter in Ecasound controls the audio
processing engine's internal buffering mode, determining how the
application manages data flow between inputs, signal processing chains,
and outputs. By selecting a specific buffering strategy, users can
optimize Ecasound for high-throughput batch operations where latency
does not matter, or minimize audio delay during live, real-time
performance.
Overview of the Buffering Strategy
Ecasound processes audio in blocks of samples defined by the engine
buffer size (often set using the -b option). The
-B option dictates how aggressively Ecasound coordinates
these sample blocks across its internal pipelines, threads, and hardware
device interfaces. It determines queue depths, whether buffering favors
high-speed processing or drop-free real-time delivery, and how the
system responds to timing constraints imposed by audio hardware.
Available -B Modes
The -B option accepts several modes that directly
reshape the internal buffer pipeline:
-B:auto(Default): Ecasound inspects the connected audio objects. If all inputs and outputs are non-realtime objects (such as WAV or FLAC files on disk), it automatically routes data through non-realtime buffering. If at least one realtime endpoint is detected (such as an ALSA or JACK hardware stream), it switches to a realtime buffering model.-B:nonrt(Non-Realtime): This mode disables strict hardware-clock synchronization and allows the processing engine to run as fast as the host CPU and disk storage allow. Buffer queues expand to maximize throughput and prevent disk I/O bottlenecks from interrupting the pipeline, making it ideal for rendering and offline file processing.-B:rt(Realtime): Forces the processing loop to strictly synchronize with the sample rate of real-time audio streams. In this mode, Ecasound sizes and manages internal queues to prevent both buffer underruns (xruns) and buffer overruns, maintaining a stable balance between system stability and latency.-B:rtlowlatency(Low-Latency Realtime): Configures the internal buffering architecture to prioritize the lowest possible input-to-output delay. Buffer queues between processing modules and endpoints are kept as small as possible to eliminate latency overhead. This configuration requires a well-tuned real-time system and adequate CPU headroom, as smaller safety margins significantly increase the likelihood of buffer underruns if audio processing experiences momentary delays.
Internal Effects on Engine Mechanics
When -B is modified, Ecasound alters several specific
mechanics inside its processing core:
- Queue Sizing: In
nonrtmode, internal ring buffers and device queues are allocated with generous margins to absorb disk read/write bursts. Inrtandrtlowlatency, these queues are clamped to strictly constrained depths to prevent old audio data from accumulating. - Thread Scheduling and Execution: In real-time modes, the processing engine waits for device synchronization triggers before advancing sample blocks, aligning audio processing cycles directly with hardware interrupts. In non-realtime modes, the engine loops continuously without yielding to an external clock.
- Error Handling and Overruns: Real-time modes track and report xruns when the engine fails to deliver a block within the hardware deadline. In non-realtime mode, the concept of an underrun is suspended, as the engine simply pauses until the next block is read from disk.