ASIO: TimeBase treats small backward steps in systemTime as timeGetTime wraps, so stream instants race ahead and overflow after ~10 minutes
メンテナーはふだん 1 日以内に返信
評価
調査の方向性
Start with TimeBase::to_stream_instant in src/host/asio/stream.rs and inspect how it distinguishes clock wraparound from backward jitter. The report includes a Focusrite ASIO reproduction and suggests checking callback timestamps for large jumps. Done means genuine wraps are handled without treating small backward steps as wraps, and callback instants avoid overflow; an open pull request is already linked.
索引モデルが issue の本文から書いたものです。
説明
cpal: 0.18.2, asio feature. Driver: Focusrite USB ASIO 4.150.0.432, Scarlett 2i2 1st Gen, 128-frame buffers at 48 kHz, Windows 11.
What happens
TimeBase::to_stream_instant (src/host/asio/stream.rs) treats any ns < prev as a timeGetTime() wrap, and adds TIMEGETIME_WRAP_NS (about 49.7 days) to the epoch:
let prev = self.last_ns.swap(ns, Ordering::Relaxed);
let epoch = if ns < prev {
self.epoch_ns.fetch_add(TIMEGETIME_WRAP_NS, Ordering::Relaxed) + TIMEGETIME_WRAP_NS
} else { ... };
StreamInstant::from_nanos(epoch + ns)
Focusrite's ASIOTimeInfo::systemTime jitters: from one buffer switch to the next it sometimes steps back by tens to hundreds of microseconds. Over 10 s (3,746 callbacks) I counted 78 such steps, between 17 µs and 667 µs back. The normal step between callbacks ranged from 2.4 µs to 4.7 ms, against the nominal 2.67 ms. Each backward step adds 49.7 days, so:
- the callback instant reaches about 10 years after 10 s;
epoch + nsoverflowsu64after about 10 minutes. In a debug build this panics on the audio thread. In release it wraps.
Around that point, the latency an app reads as playback.checked_duration_since(callback) came out as about 1.6 × 10¹⁶ µs.
Suggested fix
Only count a wrap when the step back is large: a real timeGetTime wrap goes back by nearly 2³² ms. For example:
let epoch = if ns < prev && prev - ns > TIMEGETIME_WRAP_NS / 2 { /* wrap */ } else { /* jitter: keep epoch */ };
Optionally, clamp so the instant never runs backwards (max(prev_instant, new)) to keep instants monotonic through the jitter.
Repro
Build an output stream on the Focusrite USB ASIO driver. Log info.timestamp().callback for each callback, and look for callback-to-callback deltas of about 4.29 × 10¹⁵ ns.
- 主要言語
- Rust
- スター
- 4k
- フォーク
- 554
- 平均マージ
- 3日 3時間
- マージ済み PR(30日)
- 4
環境構築
- Dockerfile または Docker Compose ファイルあり
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
RustAudio/cpal のほかの issue
-
aaudio: dynamic buffer tuning never grows the buffer (set_buffer_size_in_frames reports Err on success)対応中かも @dannyward630 が 3 日前に担当しました。 オープンhost - aaudio platform - android
難易度 2/5 1〜3時間 初心者へのやさしさ 79/100
メンテナーはふだん 1 日以内に返信
-
WebAudio wasm build fails with wasm-bindgen panic=unwind closures対応中かも @bogusyogi が 12 日前に担当しました。 オープンhost - webaudio platform - web
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
RustAudio/cpal#1394 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
code quality dependencies host - wasapi platform - windows
難易度 5/5 1週間以上 初心者へのやさしさ 35/100
RustAudio/cpal#1416 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
host - pipewire platform - linux
難易度 4/5 1〜2日 初心者へのやさしさ 52/100
RustAudio/cpal#1405 · コメント 2 件 ·
メンテナーはふだん 1 日以内に返信
-
WASAPI: default-device activation fails with RPC_E_CHANGED_MODE after endpoint-notification callbacks put thread-pool threads into an STA対応中かも @dannyward630 が 4 日前に担当しました。 オープンcorrectness host - wasapi platform - windows
難易度 4/5 3〜5日 初心者へのやさしさ 20/100
RustAudio/cpal#1402 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
似ている issue
-
bug dependencies kind:fix priority: P3 ready-for-agent
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
shep-pm/shep#1318 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
メンテナーはふだん 2 日以内に返信
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
swc-project/swc-next#1165 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 73/100
Alive24/shea-symphony#574 ·
-
難易度 1/5 1時間未満 初心者へのやさしさ 84/100
メンテナーはふだん 1 日以内に返信