You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat: add StreamTrait::now() and overhaul StreamInstant API (#1139)
- Adds now() to StreamTrait so callers can query the stream clock outside
the audio callback on the same time base as callback/capture/playback
timestamps.
- StreamInstant is reworked to mirror std::time::Instant with u64 storage
(all stream clocks are monotonic and non-negative) and similar functions
parameters, and return types.
Closes#472
If you implement `DeviceTrait` on your own type (via the `custom` feature), update your `build_input_stream_raw` and `build_output_stream_raw` signatures from `config: &StreamConfig` to `config: StreamConfig`. Any `config.clone()` calls before `move` closures can also be removed.
63
69
70
+
## 4. `StreamInstant` API overhaul
71
+
72
+
The `StreamInstant` API has been aligned with `std::time::Instant` and `std::time::Duration`.
73
+
74
+
### `duration_since` now returns `Duration` (saturating)
75
+
76
+
**What changed:**`duration_since` now returns `Duration` directly, saturating to `Duration::ZERO`
77
+
when the argument is later than `self`, instead of returning `Option<Duration>`.
78
+
79
+
```rust
80
+
// Before (v0.17): returned Option<Duration>, argument by reference
81
+
ifletSome(d) =callback.duration_since(&start) {
82
+
println!("elapsed: {d:?}");
83
+
}
84
+
85
+
// After (v0.18): returns Duration (saturating), argument by value
86
+
letd=callback.duration_since(start);
87
+
println!("elapsed: {d:?}");
88
+
89
+
// For the previous Option-returning behaviour, use checked_duration_since:
0 commit comments