Skip to content

feat: rename StreamTrait::play to start, add draining stop#1258

Open
roderickvd wants to merge 13 commits into
developfrom
feat/start-pause-stop
Open

feat: rename StreamTrait::play to start, add draining stop#1258
roderickvd wants to merge 13 commits into
developfrom
feat/start-pause-stop

Conversation

@roderickvd

@roderickvd roderickvd commented Jul 4, 2026

Copy link
Copy Markdown
Member

This PR introduces start/pause/stop semantics on StreamTrait with draining stop.

Playback

On playback streams, the difference between pausing and stopping is that:

  • pause halts as soon as possible, if necessary discarding buffered audio
  • stop(timeout) drains, letting buffered output finish before halting.

stop thus blocks until the buffer empties or timeout elapses.

Capture

Capture streams have nothing to drain and halt immediately on stop.

Behavior details

  • play is now deprecated and forwards to start.
  • A timeout of None waits indefinitely; Some(Duration::ZERO) halts without draining.
  • Stopped and paused streams are resumable with start.
  • Dropping a stream halts immediately without draining.

Backend support

  • All backends support draining stop, except WebAudio and AudioWorklet where the calling thread can't block.
  • On ALSA, pause now implements a soft-pause fallback when there is no hardware support.
  • While there:
    • relaxed StreamState atomics in ASIO and JACK from Acquire/Release to Relaxed (no associated data payload).
    • fixed PipeWire to no longer auto-start streams.

Related

Fixes:

@roderickvd roderickvd mentioned this pull request Jul 4, 2026
17 tasks
@roderickvd roderickvd force-pushed the feat/start-pause-stop branch 2 times, most recently from 0101f48 to f5cbdac Compare July 4, 2026 20:34
@roderickvd roderickvd requested a review from Copilot July 4, 2026 20:39

This comment was marked as resolved.

This comment was marked as resolved.

This comment was marked as resolved.

This comment was marked as resolved.

This comment was marked as resolved.

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

Copilot reviewed 32 out of 32 changed files in this pull request and generated 3 comments.

Comment thread src/lib.rs Outdated
Comment thread src/lib.rs Outdated
Comment thread src/lib.rs

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

Copilot reviewed 32 out of 32 changed files in this pull request and generated 3 comments.

Comment thread src/host/aaudio/mod.rs
Comment thread src/host/pulseaudio/stream.rs
Comment thread src/host/wasapi/stream.rs

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

Copilot reviewed 32 out of 32 changed files in this pull request and generated 2 comments.

Comment thread src/host/alsa/mod.rs Outdated
Comment thread src/host/asio/mod.rs

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

Copilot reviewed 32 out of 32 changed files in this pull request and generated 2 comments.

Comment thread src/host/aaudio/mod.rs Outdated
Comment thread CHANGELOG.md

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

Copilot reviewed 33 out of 33 changed files in this pull request and generated 1 comment.

Comment thread src/host/alsa/mod.rs
Comment on lines +1494 to 1500
// Unblock the worker in case the stream is dropped before start() was called.
// Idempotent: no effect if the worker is already running.
self.signal_ready();
self.inner.dropping.store(true, Ordering::Release);
self.latch.release();
self.inner.dropping.store(true, Ordering::Relaxed);
self.trigger.wakeup();
if let Some(handle) = self.thread.take() {
let _ = handle.join();
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