Windows AudioGraph not consuming AudioFrames when there is no physical device in the graph

  Kiến thức lập trình

I am using the Windows AudioGraph APIs to generate, and conditionally mix with an input device, app generated audio and write it to an output file.

The graph is an AudioFrameInputNode and zero or more AudioDeviceInputNodes connected to an AudioSubmixNode, which is then connected to an AudioFileOutputNode.

The app generates AudioFrames and adds them to the AudioFrameInputNode so they can be mixed with any mics that are selected by the user (if any), and the final output written to (.m4a) file.

I have run into an issue where if no input devices are being mixed into the node, the graph doesn’t seem to process any frames from the AudioFrameInputNode. After 64 frames are inserted, attempting to add more throws an error that there are “Too many input frames”, as documented on the AudioFrameInputNode docs.

I recall running into this issue once before but don’t remember how exactly I fixed/worked around it. I think it required me to add an AudioDeviceOutputNode with OutgoingGain set to 0.0, but I’d like to avoid this extra undesired processing if possible.