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 committed by Russell Stanley
parent fd7113860b
commit baef3c0585
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")