Skip to content

Commit 166a778

Browse files
Merge pull request #67 from Aerion/fix-buffer-output-delay
Fix buffering output delay
2 parents d3df2cb + 26388ed commit 166a778

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

pulseaudio-control.bash

+8-1
Original file line numberDiff line numberDiff line change
@@ -292,9 +292,16 @@ function listen() {
292292
# This is faster than having the script on an interval.
293293
pactl subscribe 2>/dev/null | grep --line-buffered -e "on card" -e "on sink" -e "on server" | {
294294
while read -r; do
295+
# Output the new state
296+
output
297+
295298
# Read all stdin to flush unwanted pending events, i.e. if there are
296-
# 15 events at the same time (100ms window), output is called once.
299+
# 15 events at the same time (100ms window), output is only called
300+
# twice.
297301
read -r -d '' -t 0.1 -n 10000
302+
303+
# After the 100ms waiting time, output again the state, as it may
304+
# have changed if the user did an action during the 100ms window.
298305
output
299306
done
300307
}

0 commit comments

Comments
 (0)