Before this commit, Waybar would sometimes get into a state
where it would consume 100% of a CPU core, and the pulseaudio widget
would stop responding to volume adjustments.
In this state, the pulseaudio mainloop thread would spin, with the
counter of enabled defer events at 1, but no actual enabled defer
event in the list to get the counter back to zero after an iteration
in the mainloop.
This could happen if the unsynchronized interactions with the mainloop
thread happened to modify the list of deferred events at the same
time as the mainloop.
This commit introduces locking in accordance with the PulseAudio
documentation on the threaded mainloop:
> The lock needs to be held whenever you call any PulseAudio function that
> uses an object associated with this main loop. Those objects include
> pa_mainloop, pa_context, pa_stream and pa_operation, and the various event
> objects (pa_io_event, pa_time_event, pa_defer_event).
When using `window-rewrite`, the `class<>` rule would previously only
match against the `app_id` of a window. However, XWayland windows don't
have an app ID.
This change falls back to checking the `class` window property if there
is no app ID to support matching against XWayland windows.
This Patch allows the stretching of modules-{left,center,right} as well
add a "expand" flag to AModule. This allows one module to consume the
leftover space.
To allow the left or right modules to fully consume the center, the
changes also include a way to remove the center box (center_)
altogether.
Both flags are wrong, because:
- the active group member can be fullscreened.
- technically, a grouped window can be solo as well, because only the active group member is shown, the other members are hidden. Also you can have a group consisting of only one window.
The waybar process does not exit instantaneously.
Signals may be recevied after main has started freeing resources.
When a worker thread is in `fgets` this time window can last forever.
An easy way to duplicate the crash is pressing ^C twice with a Hyprland module.
Thread 1 "waybar" received signal SIGSEGV, Segmentation fault.
spdlog::sinks::sink::should_log (this=0x5f620b542ca5,
msg_level=spdlog::level::info)
at /usr/src/debug/spdlog/spdlog-1.14.1/include/spdlog/sinks/sink-inl.h:13
13 return msg_level >= level_.load(std::memory_order_relaxed);
(gdb) p $_siginfo._sifields._sigfault.si_addr
$1 = (void *) 0x5f620b542cad
- The module only fetches nodes for "node-type". This causes the 'onMixerChanged' log to spam whenever two or more
wireplumber modules were registered on different nodes. To reduce this the unknown node warning will now only print
if the node is not the focus of any current module.
- Adds microphone support etc to the wireplumber module.
The existing module hardcodes the selected node type to "Audio/Sink". This feature allows the user to override this
via `"node-type": "Audio/Source"`.
- Unlike the pulseaudio module, this change does not try to see the module manage both input and output. The same effect
can be achieved by running two instances of the wireplumber module.
This approach:
- Works around some of the complexity overhead that seem to have caused similar PRs to stall.
- Using separate module instances also allows both the microphone and speaker levels to be controlled with a scroll
wheel. This is something a unified module like pulseaudio struggles with.
- Similarly, separate instances allows the source volume level to be exposed as the state. Ie- the linear-gradient
css patterns can be applied to both input and output.