fix(pipewire): ensure monotonic timestamps#1247
Open
roderickvd wants to merge 1 commit into
Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR aims to prevent PipeWire stream timestamps from becoming non-monotonic when PipeWire reports unusual clock values, aligning PipeWire’s timestamp behavior with the general monotonic expectations across backends.
Changes:
- Clamp PipeWire
Time::now()-derived nanosecond values to avoid negative-to-u64wrap behavior. - Update the changelog with an Unreleased entry documenting the PipeWire timestamp fix.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
src/host/pipewire/stream.rs |
Adjusts timestamp construction from PipeWire time readings to avoid negative values when converting to StreamInstant. |
CHANGELOG.md |
Adds an Unreleased “Fixed” entry noting the PipeWire timestamp correction and adds the [Unreleased] compare link. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
306
to
311
| Some(t) => { | ||
| let delay_ns = t.delay() * 1_000_000_000i64 / t.rate().denom as i64; | ||
| ( | ||
| StreamInstant::from_nanos(t.now() as u64), | ||
| StreamInstant::from_nanos((t.now() - delay_ns.max(0)) as u64), | ||
| StreamInstant::from_nanos(t.now().max(0) as u64), | ||
| StreamInstant::from_nanos((t.now() - delay_ns.max(0)).max(0) as u64), | ||
| ) |
Comment on lines
345
to
350
| Some(t) => { | ||
| let delay_ns = t.delay() * 1_000_000_000i64 / t.rate().denom as i64; | ||
| ( | ||
| StreamInstant::from_nanos(t.now() as u64), | ||
| StreamInstant::from_nanos((t.now() + delay_ns.max(0)) as u64), | ||
| StreamInstant::from_nanos(t.now().max(0) as u64), | ||
| StreamInstant::from_nanos((t.now() + delay_ns.max(0)).max(0) as u64), | ||
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Similar in spirit to #1246 but without the race.