简体   繁体   English

直接渲染到 WASAPI 时,两个流之一中没有音频 output

[英]No audio output from one of two streams when rendering directly to WASAPI

I've been stuck on this problem for weeks now and Google is no help, so hopefully some here can help me.我已经被这个问题困住了好几个星期了,谷歌没有帮助,所以希望这里的一些人可以帮助我。

I am programming a software sound mixer in C++, getting audio packets from the network and Windows microphones, mixing them together as PCM, and then sending them back out over the network and to speakers/USB headsets.我正在 C++ 中编写软件混音器,从网络和 Windows 麦克风获取音频数据包,将它们作为 PCM 混合在一起,然后通过网络将它们发送回扬声器/USB 耳机。 This works.这行得通。 I have a working setup using the PortAudio library to handle the interface with Windows.我有一个使用 PortAudio 库的工作设置来处理与 Windows 的接口。 However, my supervisors think the latency could be reduced between this software and our system, so in an attempt to lower latency (and better handle USB headset disconnects) I'm now rewriting the Windows interface layer to directly use WASAPI.但是,我的主管认为该软件和我们的系统之间的延迟可以减少,因此为了降低延迟(并更好地处理 USB 耳机断开连接),我现在正在重写 Windows 接口层以直接使用 WASAPI。 I can eliminate some buffers and callbacks doing this, and theoretically use the super low latency interface if that's still not fast enough for the higher ups.我可以消除一些缓冲区和回调这样做,理论上使用超低延迟接口,如果它仍然不够快,对于更高的 ups。

I have it only partially working now, and the partially part is what is killing me here.我现在只有部分工作,而部分是在这里杀死我的原因。 Our system has the speaker and headphones as three separate mono audio streams.我们的系统将扬声器和耳机作为三个独立的 mono 音频流。 The speaker is mono, and the headset is combined from two streams to be stereo.扬声器为mono,耳机由两个流组合成立体声。 I'm outputting this to windows as two streams, one for a device of the user's choice for speaker, and one of another device of the user's choice for headset.我将其作为两个流输出到 windows,一个用于用户选择的扬声器设备,另一个用于用户选择的耳机设备。 For testing, they're both outputting to the default general stereo mix on my system.为了测试,它们都输出到我系统上的默认通用立体声混音。

I can hear the speaker perfectly fine, but I cannot hear the headset, no matter what I try.我可以很好地听到扬声器的声音,但无论我尝试什么,我都听不到耳机的声音。 They both use the same code path, they both go through a WMF resampler to convert to 2 channel audio at the sample rate Windows wants.它们都使用相同的代码路径,它们都通过 WMF 重采样器 go 以 Windows 想要的采样率转换为 2 声道音频。 But I can hear the speaker, but never the headset stream.但我可以听到扬声器,但听不到耳机 stream。

It's not an exclusive mode problem: I'm using shared mode on all streams, and I've even specifically tried cutting down the streams to only the headset, in case one was stomping the other or something, and still the headset has no audio output.这不是独占模式问题:我在所有流上都使用共享模式,我什至专门尝试将流减少到仅耳机,以防一个人踩到另一个或其他东西,但耳机仍然没有音频output。

It's not a mixer problem upstream, as I haven't modified any code from when it worked with PortAudio streams.这不是上游的混音器问题,因为我没有修改与 PortAudio 流一起使用时的任何代码。 I can see the audio passing through the mixer and to the output via my debug visualizers.我可以通过调试可视化器看到通过混音器和 output 的音频。

I can see the data going into the buffer I get from the system, when the system calls back to ask for audio.当系统回调请求音频时,我可以看到数据进入了我从系统获得的缓冲区。 I should be hearing something , static even, but I'm getting nothing.我应该听到一些东西,static 甚至,但我什么也没得到。 (At one point, I bypassed the ring buffer entirely and put random numbers directly into the buffer in the callback and I still got no sound.) (有一次,我完全绕过了环形缓冲区,并在回调中直接将随机数放入缓冲区,但仍然没有声音。)

What am I doing wrong here?我在这里做错了什么? It seems like Windows itself is the problem or something, but I don't have the expertise on Windows APIs to know what, and I'm apparently the most expert for this stuff in my company.似乎 Windows 本身就是问题之类的,但我没有 Windows API 方面的专业知识来知道什么,而且我显然是我公司中最擅长这些东西的专家。 I haven't even looked yet as to why the microphone input isn't working, and I've been stuck on this for weeks now.我什至还没有弄清楚为什么麦克风输入不起作用,而且我已经坚持了好几个星期了。 If anyone has any suggestions, it'd be much appreciated.如果有人有任何建议,将不胜感激。

Check the re-sampled streams: output the stereo stream to the speaker, and output the mono stream to the handset. Check the re-sampled streams: output the stereo stream to the speaker, and output the mono stream to the handset.

Use IAudioClient::IsFormatSupported to check supported formats for the handset.使用IAudioClient::IsFormatSupported检查手机支持的格式。

Verify your code using an mp3 file.使用 mp3 文件验证您的代码。 Use two media players to play different files with different devices simultaneously.使用两个媒体播放器同时使用不同的设备播放不同的文件。

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

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