cpal
cpal copied to clipboard
How to make sure that data callback of build_output_stream runs faster than data callback of build_input_stream ?
Audio data is collected on one computer and transferred to another computer for playback. If the acquisition frequency is higher than the playback frequency, the delay will increase.
There is a StreamConfig
which can set buffer_size
and sample_rate
, and there is a timeout
on version 15.1, but it is unused on wasapi for windows.
Default output stream config:
SupportedStreamConfig { channels: 2, sample_rate: SampleRate(48000), buffer_size: Range { min: 0, max: 4294967295 }, sample_format: F32 }
All supported output stream configs:
1.1. SupportedStreamConfigRange { channels: 2, min_sample_rate: SampleRate(48000), max_sample_rate: SampleRate(48000), buffer_size: Range { min: 0, max: 4294967295 }, sample_format: F32 }
It seems that the only parameter I can adjust is buffer_size
, but it doesn't help.
https://github.com/RustAudio/cpal/blob/17e7ab61fd4055d46ed793660f8d889a2895f572/src/traits.rs#L153 Another way is to change the build_output_stream callback data length, now it is 1024.