简体   繁体   English

WASAPI独占/事件模式导致嗡嗡声

[英]WASAPI Exclusive/Event mode leads to buzzing noise

When I open an exclusive mode audio stream on one of my speakers, there is a strange buzzing noise. 当我在一个扬声器上打开独占模式音频流时,发出奇怪的嗡嗡声。 This buzzing noise does not happen under the same conditions on my other devices, nor does it happen in exclusive push mode or shared mode in general. 这种嗡嗡声在其他设备上的相同条件下不会发生,通常也不在独占推送模式或共享模式下发生。

The problem seems to be that WASAPI is setting the periodicity to be 5 milliseconds higher than what I requested, for no reason in particular. 问题似乎是WASAPI将周期设置为比我请求的周期高5毫秒,而没有特别的原因。 I've tried 10 ms to see timeGetTime() to reveal a period of 15 ms, so I tried requesting 15 ms instead. 我尝试10 ms来查看timeGetTime()以揭示15 ms的时间段,所以我尝试请求15 ms。 The period then became 20 ms. 周期变为20毫秒。 This does not happen with my other devices, which are streamed under the same conditions as the problem device, and timeGetTime() reveals a periodicity equal to that requested. 我的其他设备在与问题设备相同的条件下进行流传输,而这不会发生,并且timeGetTime()揭示了与请求的周期相等的周期。 Is this a glitch in a driver somewhere, or might I be making an assumption in my code that I shouldn't be? 这是某个地方的驱动程序故障,还是我可能在代码中做出了我不应该这样做的假设?

UPDATE: The buzzing noise goes away when I send a packet of silence before starting the stream. 更新:当我在启动流之前发送一个静默数据包时,嗡嗡声消失了。 I'm not sure how this affects the periodicity, so I'm still looking for an explanation. 我不确定这会如何影响周期性,因此我仍在寻找解释。

Thanks go to Maurits from MSDN for helping me figure out the answer. 感谢MSDN的Maurits帮助我找出答案。

The WASAPI documentation instructs that a period of audio should be sent to the device before starting to avoid start-up glitches. WASAPI文档指示在开始之前应将一段音频发送到设备,以避免启动故障。 The buzzing noise heard here qualifies as one of those. 这里听到的嗡嗡声可算是其中之一。 The reason that only my amp, which is a USB connected device, had this problem while other non-USB devices did not (the other two devices include the built-in laptop speakers and an HDMI-connected TV monitor) is because it uses a different kind of streaming than the other two ("standard streaming" instead of "standard looped streaming"). 只有我的放大器是USB连接的设备,而其他非USB设备却没有(其他两个设备包括内置笔记本电脑扬声器和HDMI连接的电视监视器)却出现此问题,是因为它使用了与其他两种不同的流媒体类型(“标准流媒体”而不是“标准循环流媒体”)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM