device/alsa,revid: clarify type conditions and remove redundant condition

This commit is contained in:
Dan Kortschak 2021-07-23 12:56:07 +09:30
parent 60bfa3df4e
commit 95991f4c75
No known key found for this signature in database
GPG Key ID: 45817BAD958E3F0C
2 changed files with 10 additions and 4 deletions

View File

@ -56,9 +56,12 @@ func TestDevice(t *testing.T) {
err := ai.Setup(c) err := ai.Setup(c)
// Log any config errors, otherwise if there was an error opening a device, skip // Log any config errors, otherwise if there was an error opening a device, skip
// this test since not all testing environments will have recording devices. // this test since not all testing environments will have recording devices.
if _, ok := err.(device.MultiError); err != nil && ok { switch err := err.(type) {
case nil:
// Do nothing.
case device.MultiError:
t.Logf("errors from configuring device: %s", err.Error()) t.Logf("errors from configuring device: %s", err.Error())
} else if err != nil { default:
t.Skip(err) t.Skip(err)
} }
err = ai.Start() err = ai.Start()

View File

@ -53,9 +53,12 @@ func (r *Revid) setupAudio() error {
// Configure ALSA device. // Configure ALSA device.
r.cfg.Logger.Log(logger.Debug, "configuring input device") r.cfg.Logger.Log(logger.Debug, "configuring input device")
err := d.Setup(r.cfg) err := d.Setup(r.cfg)
if _, ok := err.(device.MultiError); err != nil && ok { switch err := err.(type) {
case nil:
// Do nothing.
case device.MultiError:
r.cfg.Logger.Log(logger.Warning, "errors from configuring input device", "errors", err) r.cfg.Logger.Log(logger.Warning, "errors from configuring input device", "errors", err)
} else if err != nil { default:
return err return err
} }
r.cfg.Logger.Log(logger.Info, "input device configured") r.cfg.Logger.Log(logger.Info, "input device configured")