-
Notifications
You must be signed in to change notification settings - Fork 224
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Sound Is Cracking When CPU Is Under Load #235
Comments
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. |
@MyPHS can you try the latest master please? |
I just tried and it still was cracking. |
Ok, I "fixed" this. |
Haha, wow 😅 Happy you worked it out and thanks for letting me know! |
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. When setting the priority in Task Manager to 'higher than normal' it's working fine no matter what. |
For the record, the issue lies in A possible fix using the use winapi::um::processthreadsapi::{
GetCurrentProcessorNumber, GetCurrentThread, SetThreadIdealProcessor, SetThreadPriority,
};
use winapi::um::winbase;
// https://docs.microsoft.com/en-us/windows/win32/api/processthreadsapi/nf-processthreadsapi-setthreadpriority
#[repr(u32)]
pub enum Priority {
// BackgroundModeBegin = winbase::THREAD_MODE_BACKGROUND_BEGIN,
// BackgroundModeEnd = winbase::THREAD_MODE_BACKGROUND_END,
//
// Idle = winbase::THREAD_PRIORITY_IDLE,
// Lowest = winbase::THREAD_PRIORITY_LOWEST,
// BelowNormal = winbase::THREAD_PRIORITY_BELOW_NORMAL,
// Normal = winbase::THREAD_PRIORITY_NORMAL,
// AboveNormal = winbase::THREAD_PRIORITY_ABOVE_NORMAL,
// Highest = winbase::THREAD_PRIORITY_HIGHEST,
TimeCritical = winbase::THREAD_PRIORITY_TIME_CRITICAL,
}
pub fn pin(priority: Priority) {
unsafe {
let cpu = GetCurrentProcessorNumber();
let thread = GetCurrentThread();
SetThreadIdealProcessor(thread, cpu);
SetThreadPriority(thread, priority as i32);
}
} But I'm fairly certain that needs to be applied in |
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.
The text was updated successfully, but these errors were encountered: