fix: name the audio device in diagnostics instead of quoting its GUID

The watchdog fired exactly as intended and said:

  no audio at all from "{0.0.1.00000000}.{6a27abfd-f277-496b-b6f1-f92ec284c636}"

which tells the operator nothing they can act on. "DAX RX 1 (FlexRadio DAX)"
points straight at the DAX panel.

Endpoint ids are what gets CONFIGURED and stored, so they are what the recorder
holds; the friendly name is resolved only when something has gone wrong. When
the endpoint cannot be found at all the id is still shown — a device that has
disappeared explains an empty recording too.
This commit is contained in:
2026-07-31 00:11:29 +02:00
parent c9f7279a01
commit a93f52d2b9
3 changed files with 39 additions and 12 deletions
+27
View File
@@ -101,3 +101,30 @@ func endpointName(dev *wca.IMMDevice, fallback string) string {
}
return fallback
}
// DeviceName resolves an endpoint id to its friendly name.
//
// Diagnostics quote the id that was CONFIGURED, which is a GUID — an operator
// told "no audio at all from {0.0.1.00000000}.{6a27abfd…}" learns nothing they
// can act on, while "no audio at all from DAX RX 1 (FlexRadio DAX)" points
// straight at the DAX panel.
//
// Falls back to the id when the endpoint cannot be found, which is itself worth
// seeing: a device that has disappeared explains an empty recording too.
func DeviceName(id string) string {
if id == "" {
return "(none)"
}
for _, list := range []func() ([]Device, error){ListInputDevices, ListOutputDevices} {
devs, err := list()
if err != nil {
continue
}
for _, d := range devs {
if d.ID == id {
return d.Name
}
}
}
return id
}
+5 -5
View File
@@ -155,7 +155,7 @@ func (r *Recorder) Start(fromDev, micDev string, prerollSec int) error {
r.lastA = time.Now()
r.srcMu.Unlock()
}); err != nil {
LogSink("recorder: capture from %q failed: %v", fromDev, err)
LogSink("recorder: capture from %q failed: %v", DeviceName(fromDev), err)
}
}()
if twoSrc {
@@ -170,7 +170,7 @@ func (r *Recorder) Start(fromDev, micDev string, prerollSec int) error {
r.lastB = time.Now()
r.srcMu.Unlock()
}); err != nil {
LogSink("recorder: capture from %q failed: %v", micDev, err)
LogSink("recorder: capture from %q failed: %v", DeviceName(micDev), err)
}
}()
}
@@ -193,11 +193,11 @@ func (r *Recorder) Start(fromDev, micDev string, prerollSec int) error {
aQuiet, bQuiet := r.lastA.IsZero(), r.lastB.IsZero()
r.srcMu.Unlock()
if aQuiet {
LogSink("recorder: no audio at all from %q after 3 s — the device opened but nothing is streaming", fromDev)
AlertSink("No audio from %s — nothing is being recorded", fromDev)
LogSink("recorder: no audio at all from %q after 3 s — the device opened but nothing is streaming", DeviceName(fromDev))
AlertSink("No audio from %s — nothing is being recorded", DeviceName(fromDev))
}
if twoSrc && bQuiet {
LogSink("recorder: no audio at all from %q after 3 s — the device opened but nothing is streaming", micDev)
LogSink("recorder: no audio at all from %q after 3 s — the device opened but nothing is streaming", DeviceName(micDev))
}
}()