Recording desktop audio?

I'm aware there are libraries to record audio from input devices and whatnot, but is there such a thing for desktop audio via a loopback of some sort?

cpal looks pretty good, but iirc it cannot route output devices as input.

Mainly looking for compatibility with Linux and Windows (preferably cross platform but not a necessity).