Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions src/wirehose/stream_registry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,28 @@ impl<D> StreamRegistry<D> {
}

/// Register a stream and its listener, evicting any with the same ID.
///
/// If a stream is already registered under `stream_id` (e.g. when a
/// capture is renewed after [`CaptureEligibility::NeedsRestart`]), the
/// evicted stream is explicitly disconnected before being handed to the
/// garbage collector - matching what [`Self::remove()`] already does.
/// Without this, dropping the evicted [`StreamRc`] alone destroys the
/// client-side stream object (see `StreamBox`'s `Drop` impl, which calls
/// `pw_stream_destroy` directly) without ever calling
/// `pw_stream_disconnect`, so the corresponding PipeWire node can be left
/// registered in the graph - orphaned from wiremix's own bookkeeping,
/// but still visible to every other client - until something else tears
/// it down.
///
/// [`CaptureEligibility::NeedsRestart`]: crate::wirehose::state::CaptureEligibility::NeedsRestart
pub fn add_stream(
&mut self,
stream_id: ObjectId,
stream: StreamRc,
listener: StreamListener<D>,
) {
if let Some(old) = self.streams.insert(stream_id, stream) {
let _ = old.disconnect();
self.garbage_streams.push(old);
if let Some(listeners) = self.listeners.get_mut(&stream_id) {
self.garbage_listeners.append(listeners);
Expand Down
Loading