audio_wasapi_input.h
Windows audio capture (WASAPI, shared mode, event driven).
#include <sonore/audio_wasapi_input.h>- 1type
- 1other declaration
- Guides: Platforms and formats
On this page
Design notes
The mirror of audio_wasapi.h, and deliberately a separate object rather than a second mode of that one: capture has its own device, its own client, its own event and its own thread, and the only thing the two share is the ring between them. Folding them together would mean one object with two of everything and a flag deciding which half is real.
Shared mode again, for the same reason: it is the path that works on every Windows box without exclusive mode or format negotiation. Where capture differs is that the DEVICE's rate is not ours to accept (the output picked the rate first and the DSP is prepared at it), so this asks Windows to convert, and only refuses if Windows will not.
Types 1
One capture device in WASAPI shared mode, handed to the render side through an AudioRing: the standalone's live input on Windows. See the file comment for why it is its own object rather than a mode of WasapiOutput.
open(index, rate) runs on the MAIN thread after the output has settled the rate, since the DSP is already prepared at it; index 0 is the system default. Windows is asked to convert to that rate, and when it will not and the rates differ -- or the device's own mix is not 32-bit float -- open() fails and error() says so. run() starts a capture thread of its own that writes stereo float into the ring: a mono device feeds both sides, and channels past the second are not used. The render thread takes it with read(), which never blocks or allocates and pads a short read with silence; droppedFrames() and starvedFrames() count what did not fit and what was not there. stop() and the destructor run on the thread that called open(). A device that goes away sets takeDeviceLost().
Aliases 1
- using
using PlatformAudioInput = WasapiInputThe live-input backend the standalone uses on this platform.standalone::PlatformAudioInput · audio_wasapi_input.h:513