From baef3c0585701bcba54d924fa585ed5a1382f030 Mon Sep 17 00:00:00 2001 From: Dan Kortschak Date: Fri, 23 Jul 2021 12:56:07 +0930 Subject: [PATCH] device/alsa,revid: clarify type conditions and remove redundant condition --- device/alsa/alsa_test.go | 7 +++++-- revid/audio_linux.go | 7 +++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/device/alsa/alsa_test.go b/device/alsa/alsa_test.go index 9b9ce080..ce413bc0 100644 --- a/device/alsa/alsa_test.go +++ b/device/alsa/alsa_test.go @@ -56,9 +56,12 @@ func TestDevice(t *testing.T) { err := ai.Setup(c) // 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. - 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()) - } else if err != nil { + default: t.Skip(err) } err = ai.Start() diff --git a/revid/audio_linux.go b/revid/audio_linux.go index 1553dc47..6d297463 100644 --- a/revid/audio_linux.go +++ b/revid/audio_linux.go @@ -53,9 +53,12 @@ func (r *Revid) setupAudio() error { // Configure ALSA device. r.cfg.Logger.Log(logger.Debug, "configuring input device") 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) - } else if err != nil { + default: return err } r.cfg.Logger.Log(logger.Info, "input device configured")