mirror of https://bitbucket.org/ausocean/av.git
revid-cli: correctly using ns.Mode() and ns.SetMode()
This commit is contained in:
parent
6171c4e999
commit
ee7eb84d26
|
@ -266,18 +266,30 @@ func run(cfg revid.Config) error {
|
|||
log.Log(logger.Fatal, pkg+"could not initialise revid", "error", err.Error())
|
||||
}
|
||||
|
||||
// Update revid to get latest config settings from netreceiver.
|
||||
if err = rv.Update(vars); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// If mode on netreceiver isn't paused then we can start revid.
|
||||
if ns.Mode() != paused {
|
||||
if err = rv.Start(); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
for {
|
||||
if err := send(&ns, rv); err != nil {
|
||||
log.Log(logger.Error, pkg+"polling failed", "error", err.Error())
|
||||
if err := ns.Run(); err != nil {
|
||||
log.Log(logger.Error, pkg+"Run Failed. Retrying...")
|
||||
time.Sleep(netSendRetryTime)
|
||||
continue
|
||||
}
|
||||
|
||||
if vs != ns.VarSum() {
|
||||
// If var sum hasn't change we continue
|
||||
if vs == ns.VarSum() {
|
||||
continue
|
||||
}
|
||||
|
||||
vars, err := ns.Vars()
|
||||
if err != nil {
|
||||
log.Log(logger.Error, pkg+"netSender failed to get vars", "error", err.Error())
|
||||
|
@ -286,32 +298,25 @@ func run(cfg revid.Config) error {
|
|||
}
|
||||
vs = ns.VarSum()
|
||||
|
||||
switch ns.Mode() {
|
||||
case paused:
|
||||
if rv.IsRunning() {
|
||||
log.Log(logger.Info, pkg+"pausing revid")
|
||||
if err = rv.Stop(); err != nil {
|
||||
log.Log(logger.Error, pkg+"failed to stop revid", "error", err.Error())
|
||||
continue
|
||||
}
|
||||
ns.SetMode(paused)
|
||||
}
|
||||
case normal:
|
||||
if err = rv.Update(vars); err != nil {
|
||||
return err
|
||||
}
|
||||
ns.SetMode(normal)
|
||||
|
||||
switch ns.Mode() {
|
||||
case paused:
|
||||
case normal:
|
||||
if err = rv.Start(); err != nil {
|
||||
return err
|
||||
}
|
||||
case burst:
|
||||
if err = rv.Start(); err != nil {
|
||||
return err
|
||||
}
|
||||
ns.SetMode(burst)
|
||||
time.Sleep(rv.Config().BurstPeriod)
|
||||
time.Sleep(time.Duration(rv.Config().BurstPeriod))
|
||||
if err = rv.Stop(); err != nil {
|
||||
return err
|
||||
}
|
||||
ns.SetMode(paused)
|
||||
}
|
||||
ns.SetMode(paused, &vs)
|
||||
}
|
||||
sleepTime, _ := strconv.Atoi(ns.Param("mp"))
|
||||
time.Sleep(time.Duration(sleepTime) * time.Second)
|
||||
|
|
|
@ -488,7 +488,7 @@ func (r *Revid) Update(vars map[string]string) error {
|
|||
}
|
||||
}
|
||||
|
||||
return r.Start()
|
||||
return nil
|
||||
}
|
||||
|
||||
// outputClips takes the clips produced in the packClips method and outputs them
|
||||
|
|
Loading…
Reference in New Issue