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
parent e3c5d01a97
commit 60bfa3df4e
No known key found for this signature in database
GPG Key ID: 45817BAD958E3F0C
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