Merged in zombie-routine-fix (pull request #251)

revid: setup pipeline when revid.Start() is called, not on call to revid.New()

Approved-by: Alan Noble <anoble@gmail.com>
This commit is contained in:
Saxon Milton 2019-09-12 23:52:57 +00:00
commit 8adcd94f33
1 changed files with 11 additions and 5 deletions

View File

@ -119,10 +119,11 @@ type Revid struct {
// an error if construction of the new instance was not successful.
func New(c Config, ns *netsender.Sender) (*Revid, error) {
r := Revid{ns: ns, err: make(chan error)}
err := r.reset(c)
err := r.setConfig(c)
if err != nil {
return nil, err
return nil, fmt.Errorf("could not set config, failed with error: %v",err)
}
r.config.Logger.SetLevel(c.LogLevel)
go r.handleErrors()
return &r, nil
}
@ -317,12 +318,17 @@ func (r *Revid) Start() error {
}
r.config.Logger.Log(logger.Info, pkg+"starting Revid")
r.isRunning = true
var err error
err := r.reset(r.config)
if err != nil {
r.Stop()
return err
}
r.closeInput, err = r.setupInput()
if err != nil {
r.Stop()
return err
}
return err
return nil
}
// Stop closes down the pipeline. This closes encoders and sender output routines,
@ -543,7 +549,7 @@ func (r *Revid) Update(vars map[string]string) error {
}
}
r.config.Logger.Log(logger.Info, pkg+"revid config changed", "config", fmt.Sprintf("%+v", r.config))
return r.reset(r.config)
return nil
}
// startRaspivid sets up things for input from raspivid i.e. starts