cpal icon indicating copy to clipboard operation
cpal copied to clipboard

How to make sure that data callback of build_output_stream runs faster than data callback of build_input_stream ?

Open 21pages opened this issue 1 year ago • 0 comments

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.

image

21pages avatar Mar 28 '23 13:03 21pages