Main loop not entered all the time
Wireplumber currently runs its main loop from GSource dispatch function like this:
pw_loop_enter (WP_LOOP_SOURCE(s)->loop);
result = pw_loop_iterate (WP_LOOP_SOURCE(s)->loop, 0);
pw_loop_leave (WP_LOOP_SOURCE(s)->loop);
This has the consequence that the main loop is not "entered" all the time when it is running, which is a behavior difference to pw_main_loop_run and pw_thread_loop.
Down the line, this causes problems, as e.g. spa_loop_invoke(main_loop, callback)
will invoke the callback in the main loop if spa_loop_invoke
is called while the main loop thread is between enter/leave, but if it is not executing the iteration, it'll invoke the callback directly in the calling thread instead of the main loop. This is unexpected and caused at least one bug see pipewire!1972 (merged)
There's a few issues here:
- Is the expectation that main loop is "entered" all the time when a SPA plugin is running wrong? -> probably no
- Should
spa_loop_invoke
behavior not depend on whether the loop is entered or now? -> probably no - Is what Wireplumber is doing wrong? -> probably yes
- Does the Pipewire API documentation say clearly enough what is right and what is wrong here? -> probably no