device: fix incorrect uses of MultiError and guard against misuse

This commit is contained in:
Dan Kortschak 2021-07-23 12:54:34 +09:30 committed by Russell Stanley
parent 49aa588aae
commit fd7113860b
6 changed files with 20 additions and 5 deletions

View File

@ -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

View File

@ -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))
}

View File

@ -203,7 +203,10 @@ func (g *GeoVision) Set(c avconfig.Config) error {
const setupDelay = 5 * time.Second
time.Sleep(setupDelay)
return errs
if len(errs) != 0 {
return errs
}
return nil
}
// Start uses an RTSP client to communicate with the GeoVision RTSP server and

View File

@ -135,5 +135,8 @@ func (r *Raspistill) Set(c config.Config) error {
}
r.cfg = c
return errs
if len(errs) != 0 {
return errs
}
return nil
}

View File

@ -239,7 +239,10 @@ func (r *Raspivid) Set(c config.Config) error {
}
r.cfg = c
return errs
if len(errs) != 0 {
return errs
}
return nil
}
func goodAWBGains(g string) bool {

View File

@ -115,7 +115,10 @@ func (w *Webcam) Set(c config.Config) error {
c.Bitrate = defaultBitrate
}
w.cfg = c
return errs
if len(errs) != 0 {
return errs
}
return nil
}
// Start will build the required arguments for ffmpeg and then execute the