Optimization of execution time of audio capture call in c/c++ (ALSA)
Capture audio into a FIFO, and process the samples in that FIFO in a separate thread.  That way, timing variations in your processing thread won’t block the audio input.

Very commonly the audio input FIFO is implemented using a lock-free ring buffer so it never blocks.  A separate processing thread can poll the buffer at some suitable fixed rate (video frame rate or network data rate for a given MTU size, etc.)