underlying pipewire stream is never destroyed
Current implementation of pipewire-rs stream bindings doesn't destroy the underlying stream object. This causes leaks of file descriptors and causes issues for applications that creates and destroys streams multiple times during its lifetime.
Also every time on_process
callback is called it just creates a new stream instance around the pipewire stream pointer and passes it to the closure. Currently this means you cannot fix the issue by simply calling pw_stream_destroy
in the drop handler for stream.
If stream really is intended to just be a wrapper around a pointer then some other mechanism to allow easy cleanup after mainloop.quit()
is called need to be provided.
Ideally the issue with on_process
is resolved so one can rely on drop just working as expected for pipewire::Stream
.
On the other hand I suppose a quick fix would be this:
impl<D> std::ops::Drop for Stream<D> {
fn drop(&mut self) {
if ! matches!(self._alive, KeepAlive::<D>::Temp ) {
unsafe {
println!("stream dropped");
pw_sys::pw_stream_destroy(self.as_ptr());
}
}
}
}