This file uses std::sort and does not import correct header.
Compilation with libstdc++ worked due to some indirect import, but compilation with LLVM libc++ fails.
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).
on sinkInfo callbacks, the default sink now has highest priority.
That fixes an issue that the volume indicator is not updated when
the changes the default output to another devices.
added PA_SINK_IDLE as valid state. PA_SINK_RUNNING is only true
if any sound output is happening on sink switch. Indicator should
also update when no sound is being played.
Historically we listened to /sys/class/poewr_supply inotify events,
which does not seem to work anymore.
We switched now to udev netlink kernel events.
"reload_style_on_change" would check if the target file is a symlink,
but only resolves the first link. If the symlink is acutally a chain of
symlink, such as what happens with NixOS's mkOutOfStoreSymlink, we will
not find the actual file style file.
Update the symlink resolution logic to walk down the symlink chain until
it finds a non-symlink. Also check against a the original filename
(which may be a symlink) to guard against infinitely looping on a
circular symlink chain.
This reverts commit 2d33c20231 and
reapplies various patches for memory leaks.
The reason for the revert was a bug for a maximum duration interval
which caused sleep_for() to cause unpredictable behavior.