revid/revid.go: cleaned up prcoessFrom (added deger for waitgroup.Done and added info log)

This commit is contained in:
Saxon 2020-01-24 20:15:40 +10:30
parent 0f5aaf6cb5
commit 4e7e5ebca3
1 changed files with 3 additions and 2 deletions

View File

@ -857,17 +857,19 @@ func (r *Revid) Update(vars map[string]string) error {
// processFrom is run as a routine to read from a input data source, lex and
// then send individual access units to revid's encoders.
func (r *Revid) processFrom(in device.AVDevice, delay time.Duration) {
defer r.wg.Done()
restart:
err := in.Start()
if err != nil {
r.err <- fmt.Errorf("could not start input device: %w", err)
r.wg.Done()
return
}
// Lex data from input device, in, until finished or an error is encountered.
// For a continuous source e.g. a camera or microphone, we should remain
// in this call indefinitely unless in.Stop() is called and an io.EOF is forced.
r.cfg.Logger.Log(logger.Info, pkg+"lexing")
err = r.lexTo(r.filters[0], in, delay)
switch err {
case nil, io.EOF, io.ErrUnexpectedEOF:
@ -886,5 +888,4 @@ restart:
}
r.cfg.Logger.Log(logger.Info, pkg+"finished lexing")
r.wg.Done()
}