mirror of https://bitbucket.org/ausocean/av.git
device: fix incorrect uses of MultiError and guard against misuse
This commit is contained in:
parent
49aa588aae
commit
fd7113860b
|
@ -177,7 +177,7 @@ func (d *ALSA) Setup(c config.Config) error {
|
|||
d.mode = paused
|
||||
go d.input()
|
||||
|
||||
if errs != nil {
|
||||
if len(errs) != 0 {
|
||||
return errs
|
||||
}
|
||||
return nil
|
||||
|
|
|
@ -68,5 +68,8 @@ type AVDevice interface {
|
|||
type MultiError []error
|
||||
|
||||
func (me MultiError) Error() string {
|
||||
if len(me) == 0 {
|
||||
panic("device: invalid use of MultiError")
|
||||
}
|
||||
return fmt.Sprintf("%v", []error(me))
|
||||
}
|
||||
|
|
|
@ -203,8 +203,11 @@ func (g *GeoVision) Set(c avconfig.Config) error {
|
|||
const setupDelay = 5 * time.Second
|
||||
time.Sleep(setupDelay)
|
||||
|
||||
if len(errs) != 0 {
|
||||
return errs
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Start uses an RTSP client to communicate with the GeoVision RTSP server and
|
||||
// request a stream that is then received by an RTP client, from which packets
|
||||
|
|
|
@ -135,5 +135,8 @@ func (r *Raspistill) Set(c config.Config) error {
|
|||
}
|
||||
|
||||
r.cfg = c
|
||||
if len(errs) != 0 {
|
||||
return errs
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
|
|
@ -239,8 +239,11 @@ func (r *Raspivid) Set(c config.Config) error {
|
|||
}
|
||||
|
||||
r.cfg = c
|
||||
if len(errs) != 0 {
|
||||
return errs
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func goodAWBGains(g string) bool {
|
||||
parts := strings.Split(g, ",")
|
||||
|
|
|
@ -115,8 +115,11 @@ func (w *Webcam) Set(c config.Config) error {
|
|||
c.Bitrate = defaultBitrate
|
||||
}
|
||||
w.cfg = c
|
||||
if len(errs) != 0 {
|
||||
return errs
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Start will build the required arguments for ffmpeg and then execute the
|
||||
// command, piping video output where we can read using the Read method.
|
||||
|
|
Loading…
Reference in New Issue