Commit Graph

16 Commits

Author SHA1 Message Date
afb1ee5422 audio_backend: fix crash
Getting crashes when called before we have proper information.
2025-04-11 14:53:47 -05:00
6d28740896 Add locking for interacting with the pulseaudio thread
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).
2024-12-03 19:37:36 +01:00
e3095c6d1d clang-format 2024-09-21 13:25:36 +02:00
d6bfeb5a44 added is running condition to default_sink_is_running check 2024-09-21 13:25:36 +02:00
8b1d73690d added running check to default sink return condition 2024-09-21 13:25:36 +02:00
9c47b2e9dd removed debug logging 2024-09-21 13:25:36 +02:00
dedee8cd14 pulseaudio: show correct sink volume on default output changes
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.
2024-09-21 13:25:36 +02:00
23274a9d57 pulseaudio: Consider ignored sinks never running
If the current sink happens to be ignored it is never considered running
so it will be replaced with another sink.
2024-07-06 01:30:11 +03:00
d66685a3aa util: clang-tidy 2024-07-02 10:38:58 -05:00
14d168c254 pulseaudio: extract context connecting into connectContext() 2024-01-27 23:47:39 +08:00
167f04a4df pulseaudio: reconnect context when pulseaudio server restarts
When pulseaudio server restarts, the context is not reconnect
automatically. So the pulseaudio module will stop updating.
2024-01-25 23:59:32 +08:00
ecbcf242d5 feat: allow unmuting by moving the pulseaudio slider 2023-10-15 17:52:12 -03:00
c3779dd16e refactor: move backlight backend out of backlight module 2023-10-15 17:52:12 -03:00
442a4b0da0 feat: pulseaudio slider module 2023-10-15 17:52:12 -03:00
c9e129cda2 feat: allow setting volume directly 2023-10-15 17:52:12 -03:00
64d7fae03a refactor: move pulseaudio handling to separate class 2023-10-15 17:52:12 -03:00