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)
|
errs = append(errs, errInvalidCodec)
|
||||||
c.InputCodec = defaultCodec
|
c.InputCodec = defaultCodec
|
||||||
}
|
}
|
||||||
if errs != nil {
|
|
||||||
return errs
|
|
||||||
}
|
|
||||||
d.Config = Config{
|
d.Config = Config{
|
||||||
SampleRate: c.SampleRate,
|
SampleRate: c.SampleRate,
|
||||||
Channels: c.Channels,
|
Channels: c.Channels,
|
||||||
|
@ -183,6 +180,9 @@ func (d *ALSA) Setup(c config.Config) error {
|
||||||
d.mode = paused
|
d.mode = paused
|
||||||
go d.input()
|
go d.input()
|
||||||
|
|
||||||
|
if errs != nil {
|
||||||
|
return errs
|
||||||
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -27,7 +27,6 @@ package alsa
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"errors"
|
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
@ -58,8 +57,7 @@ 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.
|
||||||
var e *device.MultiError
|
if _, ok := err.(device.MultiError); err != nil && ok {
|
||||||
if err != nil && errors.As(err, &e) {
|
|
||||||
t.Logf("errors from configuring device: %s", err.Error())
|
t.Logf("errors from configuring device: %s", err.Error())
|
||||||
} else if err != nil {
|
} else if err != nil {
|
||||||
t.Skip(err)
|
t.Skip(err)
|
||||||
|
|
|
@ -4,6 +4,7 @@ NAME
|
||||||
|
|
||||||
AUTHORS
|
AUTHORS
|
||||||
Alan Noble <alan@ausocean.org>
|
Alan Noble <alan@ausocean.org>
|
||||||
|
Trek Hopton <trek@ausocean.org>
|
||||||
|
|
||||||
LICENSE
|
LICENSE
|
||||||
revid is Copyright (C) 2019 the Australian Ocean Lab (AusOcean)
|
revid is Copyright (C) 2019 the Australian Ocean Lab (AusOcean)
|
||||||
|
@ -25,7 +26,6 @@ LICENSE
|
||||||
package revid
|
package revid
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
|
@ -44,8 +44,7 @@ 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)
|
||||||
var e *device.MultiError
|
if _, ok := err.(device.MultiError); err != nil && ok {
|
||||||
if err != nil && errors.As(err, &e) {
|
|
||||||
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 {
|
} else if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|
Loading…
Reference in New Issue