web-audio-api-rs icon indicating copy to clipboard operation
web-audio-api-rs copied to clipboard

Output latency with Jack backend doesn't seem to work

Open b-ma opened this issue 1 year ago • 3 comments

see #293

b-ma avatar Jun 19 '23 06:06 b-ma

The change in #293 works around timestamp.playback.duration_since(&timestamp.callback) returning None. Checking https://docs.rs/cpal/latest/cpal/struct.StreamInstant.html this can only happen when callback is later than playback (docs: https://docs.rs/cpal/latest/cpal/struct.OutputStreamTimestamp.html ). Which is indeed puzzling and requires some further investigation of cpal+jack

orottier avatar Jun 19 '23 11:06 orottier

The playback timestamp is not updated and falls behind the callback timestamp on the second invocation:

[2023-06-19T11:10:26Z INFO  web_audio_api::io::cpal] Output device: Ok("cpal_client_out")
[2023-06-19T11:10:26Z DEBUG web_audio_api::io::cpal] Attempt output stream with prefered config: StreamConfig { channels: 2, sample_rate: SampleRate(48000), buffer_size: Fixed(1024) }
[2023-06-19T11:10:26Z DEBUG web_audio_api::io::cpal] Determining output latency for callback OutputCallbackInfo { timestamp: OutputStreamTimestamp { callback: StreamInstant { secs: 5929, nanos: 915391332 }, playback: StreamInstant { secs: 5929, nanos: 936641333 } } }
[2023-06-19T11:10:26Z DEBUG web_audio_api::io::cpal] Output stream set up successfully
stereo
[2023-06-19T11:10:27Z DEBUG web_audio_api::io::cpal] Determining output latency for callback OutputCallbackInfo { timestamp: OutputStreamTimestamp { callback: StreamInstant { secs: 5930, nanos: 455891332 }, playback: StreamInstant { secs: 5929, nanos: 936641333 } } }
thread '<unnamed>' panicked at 'assertion failed: timestamp.callback <= timestamp.playback', src/io/cpal.rs:429:5

uklotzde avatar Jun 19 '23 11:06 uklotzde

Probably best to report it to cpal then. There's similar (but different) shenanigans happening for ALSA timestamps: https://github.com/RustAudio/cpal/issues/710

orottier avatar Jun 19 '23 18:06 orottier