crates/veilvoice-video/src/accel.rs
veilvoice-video · 648 lines · read the source here · or on GitHub
What hardware this machine has, and the one place VeilVoice can use it.
The honest answer about the audio engine, with the number
The de-identifier is not going on a graphics card, and it would be slower if it did. That is a measurement rather than an opinion: veiling sixty seconds of audio takes about 0.58 seconds on one core of an ordinary desktop, which is roughly a hundred times faster than real time. Live mode works on 1024-sample frames, so each frame has about 21 ms to be finished in and takes about 0.05 ms.
A graphics card is fast at doing the same arithmetic to a very large batch at once. It is not fast at answering small questions quickly: getting 1024 samples onto the card, waiting for a kernel, and getting them back costs more than the whole computation. Offering a "use the GPU" switch for that work would make VeilVoice slower and would be exactly the kind of claim this project refuses to make.
Where it genuinely helps, which is video
Encoding a video is the opposite shape of problem: a great deal of the same work, on large frames, where a dedicated encoder block on the card does in hardware what libx264 does on the processor. Every current NVIDIA card has NVENC, every current AMD card has AMF, and Intel's integrated graphics have Quick Sync. That is what this crate detects and what veilvoice conversation video can be pointed at.
Detection asks the system, and can fail
There is no portable way to enumerate graphics hardware from the standard library, and every native route is FFI. So this asks a tool the platform already ships, exactly as the rest of this workspace does, and when it cannot it says so rather than reporting an empty machine.
Finding a card is not the same as being able to use it. An encoder needs a driver, and it needs the copy of ffmpeg on this machine to have been built with support for it. Adapter::caveat says so, and nothing here reports a device as usable on the strength of its name.
In plain words
Changing a voice is already about a hundred times faster than listening to it, so there is nothing for a graphics card to speed up, and pretending otherwise would just make VeilVoice slower. Making a video is different: that is real work, and most graphics cards have a dedicated chip for it.
So this finds the graphics hardware you have, tells you which of it can encode video, and lets you pick. If you have two cards, an integrated one and a separate one, you can say which. And it is honest that finding a card is not proof it will work: that also depends on your drivers and on the copy of ffmpeg you have.
WHAT THIS FILE CONTAINS
648 lines defining 17 functions (11 public), 3 types and 2 constants. Everything below is read out of the source, so it cannot disagree with the code.
The types it owns.
enum Vendorline 58 · Who made a graphics device.struct Adapterline 116 · One graphics device.struct Foundline 169 · Everything found, and anything that went wrong looking.
What happens when it runs. These are the ways in: public, and nothing else in this file calls them, so they are what an outside caller reaches first.
Vendor::encoderline 92 · The ffmpeg encoder this vendor's hardware provides, if any.Vendor::encoder_nameline 103 · What to call the encoder in front of a person.Adapter::encoderline 132 · The encoder to ask ffmpeg for, if this device has one.Adapter::caveatline 137 · What finding this device does and does not establish.Adapter::describeline 145 · One line, for a list.Found::is_answerableline 181 · Whether anything could be established at all.Found::why_recommendedline 206 · Why that one, in the words to show.
reachesrecommendedlookline 232 · Look for graphics hardware.
reacheslinux_adapters,macos_adapters,windows_adapters,adapter,tool,parse_pairs,ofusable_threadsline 428 · How many threads this machine can usefully run at once.
WHAT CALLS WHAT
The functions this file defines, and the calls between them. An edge means the callee's name appears, called, inside the caller's body. This is a syntactic reading, not a type-resolved one.
The same graph as Mermaid source
%%{init: {"theme":"base","themeVariables":{"background":"#1a1b26","primaryColor":"#1f2335","primaryTextColor":"#c0caf5","primaryBorderColor":"#7aa2f7","secondaryColor":"#16161e","tertiaryColor":"#16161e","lineColor":"#737aa2","textColor":"#c0caf5","mainBkg":"#1f2335","nodeBorder":"#7aa2f7","clusterBkg":"#16161e","clusterBorder":"#2f3549","fontFamily":"ui-monospace, SFMono-Regular, Consolas, monospace","fontSize":"14px"}}}%%
flowchart TD
n_of["Vendor::of<br/>line 73"]
n_encoder(["Vendor::encoder<br/>line 92"])
n_encoder_name(["Vendor::encoder_name<br/>line 103"])
n_encoder(["Adapter::encoder<br/>line 132"])
n_caveat(["Adapter::caveat<br/>line 137"])
n_describe(["Adapter::describe<br/>line 145"])
n_is_answerable(["Found::is_answerable<br/>line 181"])
n_recommended["Found::recommended<br/>line 192"]
n_why_recommended(["Found::why_recommended<br/>line 206"])
n_look(["look<br/>line 232"])
n_windows_adapters["windows_adapters<br/>line 256"]
n_tool["tool<br/>line 301"]
n_linux_adapters["linux_adapters<br/>line 315"]
n_macos_adapters["macos_adapters<br/>line 354"]
n_parse_pairs["parse_pairs<br/>line 380"]
n_adapter["adapter<br/>line 403"]
n_usable_threads(["usable_threads<br/>line 428"])
n_adapter --> n_of
n_linux_adapters --> n_adapter
n_linux_adapters --> n_tool
n_look --> n_linux_adapters
n_look --> n_macos_adapters
n_look --> n_windows_adapters
n_macos_adapters --> n_adapter
n_parse_pairs --> n_adapter
n_why_recommended --> n_recommended
n_windows_adapters --> n_parse_pairs
click n_of href "https://github.com/tilas01/veilvoice/blob/main/crates/veilvoice-video/src/accel.rs#L73" "open the source"
click n_encoder href "https://github.com/tilas01/veilvoice/blob/main/crates/veilvoice-video/src/accel.rs#L92" "open the source"
click n_encoder_name href "https://github.com/tilas01/veilvoice/blob/main/crates/veilvoice-video/src/accel.rs#L103" "open the source"
click n_encoder href "https://github.com/tilas01/veilvoice/blob/main/crates/veilvoice-video/src/accel.rs#L132" "open the source"
click n_caveat href "https://github.com/tilas01/veilvoice/blob/main/crates/veilvoice-video/src/accel.rs#L137" "open the source"
click n_describe href "https://github.com/tilas01/veilvoice/blob/main/crates/veilvoice-video/src/accel.rs#L145" "open the source"
click n_is_answerable href "https://github.com/tilas01/veilvoice/blob/main/crates/veilvoice-video/src/accel.rs#L181" "open the source"
click n_recommended href "https://github.com/tilas01/veilvoice/blob/main/crates/veilvoice-video/src/accel.rs#L192" "open the source"
click n_why_recommended href "https://github.com/tilas01/veilvoice/blob/main/crates/veilvoice-video/src/accel.rs#L206" "open the source"
click n_look href "https://github.com/tilas01/veilvoice/blob/main/crates/veilvoice-video/src/accel.rs#L232" "open the source"
click n_windows_adapters href "https://github.com/tilas01/veilvoice/blob/main/crates/veilvoice-video/src/accel.rs#L256" "open the source"
click n_tool href "https://github.com/tilas01/veilvoice/blob/main/crates/veilvoice-video/src/accel.rs#L301" "open the source"
click n_linux_adapters href "https://github.com/tilas01/veilvoice/blob/main/crates/veilvoice-video/src/accel.rs#L315" "open the source"
click n_macos_adapters href "https://github.com/tilas01/veilvoice/blob/main/crates/veilvoice-video/src/accel.rs#L354" "open the source"
click n_parse_pairs href "https://github.com/tilas01/veilvoice/blob/main/crates/veilvoice-video/src/accel.rs#L380" "open the source"
click n_adapter href "https://github.com/tilas01/veilvoice/blob/main/crates/veilvoice-video/src/accel.rs#L403" "open the source"
click n_usable_threads href "https://github.com/tilas01/veilvoice/blob/main/crates/veilvoice-video/src/accel.rs#L428" "open the source"
classDef entry fill:#1f2335,stroke:#7aa2f7,color:#c0caf5
class n_encoder,n_encoder_name,n_encoder,n_caveat,n_describe,n_is_answerable,n_why_recommended,n_look,n_usable_threads entry
classDef api fill:#1f2335,stroke:#7dcfff,color:#c0caf5
class n_of,n_recommended api
classDef helper fill:#1f2335,stroke:#bb9af7,color:#c0caf5
class n_windows_adapters,n_tool,n_linux_adapters,n_macos_adapters,n_parse_pairs,n_adapter helper
This site loads no third-party script, so it cannot run Mermaid; the diagram above is the same nodes and edges drawn by the generator instead. GitHub renders the source below directly.
ITEMS
| Item | Line | Documentation |
|---|---|---|
Vendor pub enum | 58 | Who made a graphics device. |
Vendor::of pub fn | 73 | The vendor a device name belongs to. |
Vendor::encoder pub fn | 92 | The ffmpeg encoder this vendor's hardware provides, if any. |
Vendor::encoder_name pub fn | 103 | What to call the encoder in front of a person. |
Adapter pub struct | 116 | One graphics device. |
Adapter::encoder pub fn | 132 | The encoder to ask ffmpeg for, if this device has one. |
Adapter::caveat pub fn | 137 | What finding this device does and does not establish. |
Adapter::describe pub fn | 145 | One line, for a list. |
Found pub struct | 169 | Everything found, and anything that went wrong looking. |
Found::is_answerable pub fn | 181 | Whether anything could be established at all. |
Found::recommended pub fn | 192 | The device to suggest, and why. |
Found::why_recommended pub fn | 206 | Why that one, in the words to show. |
look pub fn | 232 | Look for graphics hardware. |
windows_adapters fn | 256 | Ask Windows through its own management interface. |
tool fn | 301 | Resolve a tool to an absolute path, never through PATH. |
linux_adapters fn | 315 | Ask Linux through lspci. |
macos_adapters fn | 354 | Ask macOS through system_profiler. |
parse_pairs fn | 380 | name|driver lines into adapters. |
adapter fn | 403 | One adapter from a name. |
usable_threads pub fn | 428 | How many threads this machine can usefully run at once. |
WHY_NOT_THE_ENGINE pub const | 435 | Why the audio engine is not offered a graphics card, with the numbers. |
WHAT_IT_CHANGES pub const | 446 | What hardware encoding is for, and what it does not change. |