Audio Sample Accumulator

Audio sample accumulator is a part of the fallback process, and its main purpose is to accumulate a higher number of samples per packet before sending them to be compressed or packed by the fallback processing stages. The effect of this process is that the retransmission rate will increase which in turn increases the reliability of the wireless audio stream. When using this process, the pipeline maximum payload size must be increased to match the accumulator maximum payload size to ensure the pipeline can process the full accumulated payload, otherwise, an error SAC_ERR_PIPELINE_PAYLOAD_NOT_BIG_ENOUGH will be returned during initialization.

Audio Sample Accumulator on the TX Side

Figure 48: Audio Sample Accumulator on the TX Side

On the RX side the role of the accumulator is to guarantee a constant sample count per packet at the audio consumer. The accumulator is ran after the fallback unpacking or decompressing stages.

Extra samples are accumulated. Once enough samples are accumulated to generate another packet, the extra packet is re-enqueued into the producer queue. Since we don’t want this packet to go through the fallback pipeline, we need to implement the accumulator in a seperate pipeline. The fallback pipeline and accumulator pipeline can be linked using the sac_endpoint_link api to link the fallback pipeline’s consumer and the accumulator pipeline’s producer. They will thus share the same queue. Each pipeline are processed independently using the sac_pipeline_process api. The accumulator pipeline should be ran as long as there are packets in it’s producer queue to process all extra packets.

sac_status_t sac_status = SAC_OK;

sac_pipeline_process(fallback_pipeline, &sac_status);
ASSERT_SAC_STATUS(sac_status);
while (sac_pipeline_get_producer_buffer_load(accumulator_pipeline) > 0) {
    sac_pipeline_process(accumulator_pipeline, &sac_status);
    ASSERT_SAC_STATUS(sac_status);
}

Here we will end up with a case where the accumulator has an extra packet other than the one that will be sent out, this extra packet will be enqueued at the top of the producer queue.

Audio Sample Accumulator on the RX Side

Figure 49: Audio Sample Accumulator on the RX Side