mirror of
https://github.com/jpochyla/psst.git
synced 2026-04-27 07:25:52 +03:00
[GH-ISSUE #235] Sound Is Cracking When CPU Is Under Load #172
Labels
No labels
api
bug
build
documentation
duplicate
enhancement
good first issue
help wanted
idea
invalid
linux
lowprio
macos
pull-request
upstream
windows
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/psst#172
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @ghost on GitHub (Dec 18, 2021).
Original GitHub issue: https://github.com/jpochyla/psst/issues/235
Describe the bug
Sound is cracking when computer is under load.
To Reproduce
Spin up some heavy load.
Expected behavior
Sound should not be cracking.
Screenshots
Not applicable.
Environment
Additional context
Solution: Start psst with higher priority automatically. This has proven to work in the past couple days I've used psst.
Probable enchancement: Make the audio buffer larger. I guess this might help. Not sure though.
@jpochyla commented on GitHub (Dec 21, 2021):
Yes I've noticed this as well. We use audio buffer of 128KB, but I guess that increasing this would just help with some short spikes? There's also a couple of crates for raising the thread priority.
@jpochyla commented on GitHub (Dec 21, 2021):
@myphs can you try the latest master please?
@ghost commented on GitHub (Dec 22, 2021):
I just tried and it still was cracking.
@ghost commented on GitHub (Dec 30, 2021):
Ok, I "fixed" this.
It was an issue with my mouse and my headset, which were both connected via USB 3. When I moved the mouse the sound started crackling.
I didn't realize this earlier, but it happens with other software, too. It just happend, that I switched USB ports for my mouse and headset just after I got psst and I was listening to music via psst when doing CPU intensive work. But just a few minutes ago I listened music with foobar2000 and it happened, too, for some reason. Of course it would never happen, when I was watching movies, because I wouldn't move the mouse.
So.
When both, mouse and headset, are connected to USB 3 on my docking station, the bandwidth is apparently diminished as such, that the USB soundcard for my headset won't get enough data and hence the crackling sound.
Connecting the mouse to a USB 2 port instead fixed the issue, because afaik USB 2 and 3 use different controllers.
@jpochyla commented on GitHub (Dec 31, 2021):
Haha, wow 😅 Happy you worked it out and thanks for letting me know!
@ghost commented on GitHub (Jan 6, 2022):
Sadly I have to reopen this because apparently it's both: the mouse but also when under load (or something else? 🤔).
The crackling happens when I e. g. open up a few tabs in Firefox at the same time.
Zero crackling with Foobar2000.
Also I ran a stress test assuming the crackling should be constant and actually it wasn't that bad but still happening every few seconds.
When setting the priority in Task Manager to 'higher than normal' it's working fine no matter what.
@alcore commented on GitHub (Mar 7, 2022):
For the record, the issue lies in
cpal, which does not set a high/real-time priority on its playback thread on Windows.(Was part of the reason why I decided to drop cpal in my projects and roll my own)
A possible fix using the
winapicrate looks roughly like this:But I'm fairly certain that needs to be applied in
cpalwhich does not give its user ownership over the actual thread. A hackaround would be to invoke that (once) in the buffer filling callback you give tocpal- since that's run in the relevant thread - but that's obviously far from optimal.