wasapi,延迟m_audioclient-> start()
该应用使用Wasapi从麦克风中捕获声音。
此代码初始化m_audioclient
类型iaudioclient*
。
const LONG CAPTURE_CLIENT_LATENCY = 50 * 10000;
DWORD loopFlag = m_IsLoopback ? AUDCLNT_STREAMFLAGS_LOOPBACK : 0;
hr = m_AudioClient->Initialize(AUDCLNT_SHAREMODE_SHARED
, AUDCLNT_STREAMFLAGS_EVENTCALLBACK | AUDCLNT_STREAMFLAGS_NOPERSIST | loopFlag
, CAPTURE_CLIENT_LATENCY, 0, m_WaveFormat->GetRawFormat(), NULL);
然后,我使用m_audioclient-> start()
和m_audioclient-> stop()
暂停或简历捕获。
美国m_audioclient-> start()
采用5-6
ms,但有时需要大约150 ms
,这对于应用程序来说太多了。
如果我曾经打电话m_audioclient-> start()
,那么在下一个下一个ocaudioclient-> start()
5 seconds> seconds> seconds> seconds> seconds>秒钟将很快快但是在大约10-15
秒后,m_audioclient-> start()
的下一个呼叫将吸收logner(150 ms
)。因此,看起来它可以保持几秒钟的状态,然后需要再次到达该状态,这需要一些时间。
在另一台计算机上,这延迟永远不会发生,m_audioclient-> start()
的每个呼叫都大约30 ms
在第三台计算机平均持续时间m_audioclient-> start()
是140 ms
,但峰值值大于1 s
。
我在所有3台机器上运行相同的代码。在大多数情况下,michrophone并不相同,它是麦克风阵列Realtek高清音频
。
有人可以解释为什么在持续时间内这些峰值m_audioclient-> start()
发生以及如何解决它?
The app captures sound from a microphone using WASAPI.
This code initializes m_AudioClient
that is of type IAudioClient*
.
const LONG CAPTURE_CLIENT_LATENCY = 50 * 10000;
DWORD loopFlag = m_IsLoopback ? AUDCLNT_STREAMFLAGS_LOOPBACK : 0;
hr = m_AudioClient->Initialize(AUDCLNT_SHAREMODE_SHARED
, AUDCLNT_STREAMFLAGS_EVENTCALLBACK | AUDCLNT_STREAMFLAGS_NOPERSIST | loopFlag
, CAPTURE_CLIENT_LATENCY, 0, m_WaveFormat->GetRawFormat(), NULL);
Then I use m_AudioClient->Start()
and m_AudioClient->Stop()
to pause or resume capturing.
Usaually m_AudioClient->Start()
takes 5-6
ms, but sometimes it takes about 150 ms
which is too much for the application.
If I once call m_AudioClient->Start()
then subsecuent calls of m_AudioClient->Start()
during next 5
seconds will be fast but after about 10-15
seconds next call of m_AudioClient->Start()
will take logner (150 ms
). So looks like it keeps some state several seconds and after that it needs to get to that state again which takes some time.
On another machine this delays never happen, every call of m_AudioClient->Start()
takes about 30 ms
On the third machine average duration of m_AudioClient->Start()
is 140 ms
but peak values are about 1 s
.
I run the same code on all 3 machines. The michrophone is not exatly the same on most cases it is Microphone Array Realtek High Definition Audio
.
Can somebody explain why these peak values for the duration m_AudioClient->Start()
happen and how I can fix it?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论