From 9769a3c4a9ae2137fefd7891e5b26efbf74dc61c Mon Sep 17 00:00:00 2001 From: Saxon Date: Thu, 12 Sep 2019 17:08:22 +0930 Subject: [PATCH 1/2] revid: not setting up pipeline until we start --- revid/revid.go | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/revid/revid.go b/revid/revid.go index fa1156b1..6f697bd0 100644 --- a/revid/revid.go +++ b/revid/revid.go @@ -119,10 +119,6 @@ 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) - if err != nil { - return nil, err - } go r.handleErrors() return &r, nil } @@ -317,12 +313,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 +544,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 From fe49be41ad8554bac9dec5de627f9ee0cbc40489 Mon Sep 17 00:00:00 2001 From: Saxon Milton Date: Thu, 12 Sep 2019 07:47:46 +0000 Subject: [PATCH 2/2] revid: setting revid's config in revid.New --- revid/revid.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/revid/revid.go b/revid/revid.go index 6f697bd0..0f357ebd 100644 --- a/revid/revid.go +++ b/revid/revid.go @@ -119,6 +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.setConfig(c) + if err != nil { + 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 }