diff options
author | xegineering <me@xegineering.eu> | 2025-01-12 09:25:47 +0100 |
---|---|---|
committer | xegineering <me@xegineering.eu> | 2025-01-12 09:25:47 +0100 |
commit | 788b502b1ec4382558e9996aee5b6cb7a87f76e3 (patch) | |
tree | 89d5dbd609404e4b1c78a16a0ac1a6b33f86073b /soundbox/pipewire.go | |
parent | bde7e0d767e5e0b1072d05eff58bef16f5858e28 (diff) | |
download | soundbox-go-788b502b1ec4382558e9996aee5b6cb7a87f76e3.tar soundbox-go-788b502b1ec4382558e9996aee5b6cb7a87f76e3.tar.zst soundbox-go-788b502b1ec4382558e9996aee5b6cb7a87f76e3.zip |
Fix 100 % CPU usage
The `default` statement in the PipeWire reading caused 100 % CPU usage.
Introducing a one millisecond delay there fixes the issue.
Diffstat (limited to 'soundbox/pipewire.go')
-rw-r--r-- | soundbox/pipewire.go | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/soundbox/pipewire.go b/soundbox/pipewire.go index 7ee38a2..02ad1d6 100644 --- a/soundbox/pipewire.go +++ b/soundbox/pipewire.go @@ -15,6 +15,7 @@ import ( "os/exec" "runtime" "sync" + "time" "unsafe" ) @@ -54,6 +55,7 @@ func (pwc pwCapture) Read(p []byte) (int, error) { return 0, io.EOF } default: + time.Sleep(time.Millisecond) // avoid 100 % busy polling return 0, nil } } |