marioortizmanero / polybar-pulseaudio-control

A feature-full Polybar module to control PulseAudio
MIT License
466 stars 49 forks source link

Optimize listen function #65

Closed Aerion closed 2 years ago

Aerion commented 2 years ago

With multiple occurrences of pulseaudio-control started, I noticed that on quick changes (i.e. volume or iterating through the sinks), the cpu usage increased a lot for the action.

pactl is quite noisy, and a single event can generate multiple matching lines.

This commit reduces the calls to output to one per 100ms.

marioortizmanero commented 2 years ago

Awesome. I've roughly measured the performant effect and you can actually see it. When generating lots of events (mainly increasing or decreasing the volume rapidly), htop reports 8-9% CPU load with the previous implementation. Now it's always under 2%.

Props for the idea! Merging once CI runs, thanks again.