mirror of https://bitbucket.org/ausocean/av.git
Merged in alsa-err (pull request #426)
alsa: improve error handling Approved-by: Saxon Milton
This commit is contained in:
commit
4bff0f25f5
|
@ -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
|
||||
}
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -4,6 +4,7 @@ NAME
|
|||
|
||||
AUTHORS
|
||||
Alan Noble <alan@ausocean.org>
|
||||
Trek Hopton <trek@ausocean.org>
|
||||
|
||||
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
|
||||
|
|
Loading…
Reference in New Issue