Skip to content

core: keep pw loop entered exactly when it is running

P V requested to merge pvir/wireplumber:fix-pw-loop into master

See #638 (closed)

It is intended that the Pipewire loops are "entered" the whole time they are running, i.e. are going to process further events. Currently we enter/leave for single iterations, which is not right.

Fix by entering the loop on initial GSource idle callback, and leaving at finalize.

That the loop has to be left from the same thread it was entered from is a bit hard to do with GSources, as the finalize callback appears not guaranteed to be called from any particular thread. I didn't find a fully general way to do this, so this puts additional constraints on how WpLoopSource (and WpCore) are to be cleaned up.

core: fix WpLoopSource lifecycle

Currently nothing removes the WpLoopSource from the main context, and we moreover are creating and leaking unused WpLoopSources when sharing same pw_context between multiple WpCore.

Fix this by keeping track of the WpLoopSource in the pw_context user data, only creating them when needed, and finalizing it after the context is destroyed.

Merge request reports