Skip to content

fix(pipewire): ensure monotonic timestamps#1247

Open
roderickvd wants to merge 1 commit into
masterfrom
fix/pipewire-timestamp-overrun
Open

fix(pipewire): ensure monotonic timestamps#1247
roderickvd wants to merge 1 commit into
masterfrom
fix/pipewire-timestamp-overrun

Conversation

@roderickvd

Copy link
Copy Markdown
Member

Similar in spirit to #1246 but without the race.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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-u64 wrap 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),
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants