diff --git a/device/alsa/alsa.go b/device/alsa/alsa.go index 9c10e021..be2117a4 100644 --- a/device/alsa/alsa.go +++ b/device/alsa/alsa.go @@ -142,9 +142,6 @@ func (d *ALSA) Setup(c config.Config) error { errs = append(errs, errInvalidCodec) c.InputCodec = defaultCodec } - if errs != nil { - return errs - } d.Config = Config{ SampleRate: c.SampleRate, Channels: c.Channels, @@ -183,6 +180,9 @@ func (d *ALSA) Setup(c config.Config) error { d.mode = paused go d.input() + if errs != nil { + return errs + } return nil } diff --git a/device/alsa/alsa_test.go b/device/alsa/alsa_test.go index 8124e131..6c2b5a77 100644 --- a/device/alsa/alsa_test.go +++ b/device/alsa/alsa_test.go @@ -27,7 +27,6 @@ package alsa import ( "bytes" - "errors" "io/ioutil" "os" "strconv" @@ -58,8 +57,7 @@ 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. - var e *device.MultiError - if err != nil && errors.As(err, &e) { + if _, ok := err.(device.MultiError); err != nil && ok { t.Logf("errors from configuring device: %s", err.Error()) } else if err != nil { t.Skip(err) diff --git a/revid/audio_linux.go b/revid/audio_linux.go index caac84e1..f7455b5e 100644 --- a/revid/audio_linux.go +++ b/revid/audio_linux.go @@ -4,6 +4,7 @@ NAME AUTHORS Alan Noble + Trek Hopton LICENSE revid is Copyright (C) 2019 the Australian Ocean Lab (AusOcean) @@ -25,7 +26,6 @@ LICENSE package revid import ( - "errors" "fmt" "strconv" @@ -44,8 +44,7 @@ func (r *Revid) setupAudio() error { // Configure ALSA device. r.cfg.Logger.Log(logger.Debug, "configuring input device") err := d.Setup(r.cfg) - var e *device.MultiError - if err != nil && errors.As(err, &e) { + if _, ok := err.(device.MultiError); err != nil && ok { r.cfg.Logger.Log(logger.Warning, "errors from configuring input device", "errors", err) } else if err != nil { return err