crates/veilvoice-gui/src/probe.rs
veilvoice-gui · 426 lines · read the source here · or on GitHub
What this machine answers, so the settings it starts on were measured here.
The difference this draws
A default is a decision taken on behalf of somebody who has not been asked. There are two ways to take one. It can be written down, which means it was decided once by somebody who has never seen the machine it will run on, or it can be measured, which means the machine was asked and answered.
Most of VeilVoice's starting values are already the second kind and were not described that way. The frame rate is 0, which means the display's own rate, and crate::pace measures it from the intervals between frames rather than assuming sixty. Whether anything animates is resolved every frame against the operating system's own reduce-motion setting, which crate::reduced_motion reads from the platform. Neither of those is a number somebody chose.
The drawing path was the one that was still written down: hardware acceleration was asked for on every machine, because asking is the safe direction and a machine that cannot give a hardware context is given a software one instead. That is true and it is not free. On a machine whose only graphics device is a software renderer, the request is made, refused and fallen back from on every single launch, and the answer was never in doubt: there is no hardware there to ask for.
So this module asks.
What it asks, and what it costs
One question, through veilvoice_video::accel::look, which lists the graphics devices this system reports: lspci on Linux, the management interface on Windows, the system profiler on macOS. That is a subprocess, and a subprocess on the path that decides how the window is made would be a poor trade if it ran every launch.
It does not. The answer is wanted exactly once, on the run that has no settings file to read, and it is written into that file with everything else. Every later launch reads it back. Within a single process it is cached in a OnceLock as well, because the window is created in main before crate::settings::Settings::load runs and both want the answer.
It decides where to start, and never what is allowed
Roadmap item 170. Every value here stays a setting. The probe moves the point a first run begins from; it removes nothing, and the Settings tab and the first-run card both show what was found and let it be overridden. A measurement that could not be taken says so and falls back to asking for hardware, which is what every build before this one did on every machine.
Finding a device is not proof it works
The same caveat veilvoice_video::accel::Adapter::caveat states about encoders applies here, in one direction only. A machine that lists a real graphics card may still have a driver that accepts a hardware context and then draws badly, which from inside the process looks exactly like success and which nothing here can detect. That is why the setting exists and why the first-run card names the symptom. What the probe can establish is the other direction: a machine that lists no hardware at all will not produce any, and asking it to is a request that can only be refused.
In plain words
The first time you open VeilVoice it looks at what your computer has, instead of assuming. If your machine has no graphics hardware, it does not spend every launch asking for some. It writes down what it found, so it only has to look once, and you can change any of it afterwards.
WHAT THIS FILE CONTAINS
426 lines defining 3 functions (3 public), 1 type and 1 constant. Everything below is read out of the source, so it cannot disagree with the code.
The types it owns.
struct Machineline 77 · What was asked of this machine, and what it said.
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.
lookline 207 · Ask this machine, once per process.
reachesverdict,is_software_renderer
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_is_software_renderer["is_software_renderer<br/>line 120"]
n_verdict["verdict<br/>line 131"]
n_look(["look<br/>line 207"])
n_look --> n_verdict
n_verdict --> n_is_software_renderer
click n_is_software_renderer href "https://github.com/tilas01/veilvoice/blob/main/crates/veilvoice-gui/src/probe.rs#L120" "open the source"
click n_verdict href "https://github.com/tilas01/veilvoice/blob/main/crates/veilvoice-gui/src/probe.rs#L131" "open the source"
click n_look href "https://github.com/tilas01/veilvoice/blob/main/crates/veilvoice-gui/src/probe.rs#L207" "open the source"
classDef entry fill:#1f2335,stroke:#7aa2f7,color:#c0caf5
class n_look entry
classDef api fill:#1f2335,stroke:#7dcfff,color:#c0caf5
class n_is_software_renderer,n_verdict api
subgraph chart_key ["Key"]
direction LR
key_entry["entry: a way in: public, and nothing in this file calls it"]
key_api["api: public, and also used inside this file"]
end
class key_entry entry
class key_api api
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 |
|---|---|---|
Machine pub struct | 77 | What was asked of this machine, and what it said. |
SOFTWARE_RENDERERS const | 103 | Names a graphics device has when it is a renderer running on the processor. |
is_software_renderer pub fn | 120 | Whether a device name is one of the processor renderers. |
verdict pub fn | 131 | Read a list of graphics devices and decide what to ask the driver for. |
look pub fn | 207 | Ask this machine, once per process. |