gpt4 book ai didi

windows - 如何最大化实时处理(Portaudio)的性能

转载 作者:行者123 更新时间:2023-12-03 01:44:27 24 4
gpt4 key购买 nike

我在我的c++实时音频处理程序中使用Portaudio库。
我想知道是否有可能在我的主要处理函数callback from the Portaudio high-priority thread中进一步减轻负担并加快处理速度:

The "callback" is a function that is called by the PortAudio engine whenever it has captured audio data, or when it needs more audio data for output.

Before we begin, it's important to realize that the callback is a delicate place. This is because some systems perform the callback in a special thread, or interrupt handler, and it is rarely treated the same as the rest of your code. For most modern systems, you won't be able to cause crashes by making disallowed calls in the callback, but if you want your code to produce glitch-free audio, you will have to make sure you avoid function calls that may take an unbounded amount of time to execute. Exactly what these are depend on your platform but almost certainly include the following: memory allocation/deallocation, I/O (including file I/O as well as console I/O, such as printf()), context switching (such as exec() or yield()), mutex operations, or anything else that might rely on the OS. If you think short critical sections are safe please go read about priority inversion. Windows amd Mac OS schedulers have no real-time safe priority inversion prevention. Other platforms require special mutex flags. In addition, it is not safe to call any PortAudio API functions in the callback except as explicitly permitted in the documentation.



目标操作系统:Windows 7(x32和x64)。

所以,我的问题是:
  • 是否值得以高(或最高,实时)进程来启动我的整个程序,如下所示(使用SetPriorityClass WinAPI函数):
    SetPriorityClass(GetCurrentProcess(), REALTIME_PRIORITY_CLASS);
  • 是否值得降低我程序的GUI 线程的优先级,如下所示:
    QThread::currentThread()->setPriority(QThread::LowPriority);
  • 这个好主意是要在需要进行某些实时操作的任何程序中最大化整个进程的优先级或降低GUI线程的优先级吗?
  • 使用ASIO driver protocol进行实时音频处理时,Windows 10是否比Windows 7更好?
  • 最佳答案

    Is it worth it to start my entire program as a high (or highest, real-time) process, like the following (using the SetPriorityClass WinAPI function)



    这取决于。 SetPriorityClass用于整个过程,而通常您只希望音频线程具有此功能。 PortAudio源代码对此有一个注释 here。然后,您肯定必须使用 SetThreadPriority调整音频线程本身的优先级。 This thread on the PA mailing list has a lot of useful information.

    其要点似乎是,它实际上将取决于用于访问声卡的Windows方式:ASIO,WASAPI等。

    关于windows - 如何最大化实时处理(Portaudio)的性能,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44735262/

    24 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com