av: addressing PR feedback

This commit is contained in:
Saxon 2019-04-22 15:14:08 +09:30
parent cbad00b6e6
commit 9ba72fac62
3 changed files with 37 additions and 9 deletions

View File

@ -24,7 +24,7 @@ LICENSE
for more details. for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with revid in gpl.txt. If not, see http://www.gnu.org/licenses. in gpl.txt. If not, see http://www.gnu.org/licenses.
*/ */
package revid package revid
@ -92,17 +92,17 @@ type Revid struct {
// lexTo, encoder and packer handle transcoding the input stream. // lexTo, encoder and packer handle transcoding the input stream.
lexTo func(dest io.Writer, src io.Reader, delay time.Duration) error lexTo func(dest io.Writer, src io.Reader, delay time.Duration) error
// mwc will hold the multiWriteCloser that writes to encoders from the lexer. // encoders will hold the multiWriteCloser that writes to encoders from the lexer.
encoders io.WriteCloser encoders io.WriteCloser
// isRunning is used to keep track of revid's running state between methods. // isRunning is used to keep track of revid's running state between methods.
isRunning bool isRunning bool
// err will channel errors from revid routines to the handle errors routine.
err chan error
// wg will be used to wait for any processing routines to finish. // wg will be used to wait for any processing routines to finish.
wg sync.WaitGroup wg sync.WaitGroup
// err will channel errors from revid routines to the handle errors routine.
err chan error
} }
// New returns a pointer to a new Revid with the desired configuration, and/or // New returns a pointer to a new Revid with the desired configuration, and/or
@ -307,7 +307,7 @@ func (r *Revid) Stop() {
r.config.Logger.Log(logger.Info, pkg+"closing pipeline") r.config.Logger.Log(logger.Info, pkg+"closing pipeline")
err := r.encoders.Close() err := r.encoders.Close()
if err != nil { if err != nil {
r.config.Logger.Log(logger.Error, pkg+"got error while closing pipeline", "error", err.Error()) r.config.Logger.Log(logger.Error, pkg+"failed to close pipeline", "error", err.Error())
} }
if r.cmd != nil && r.cmd.Process != nil { if r.cmd != nil && r.cmd.Process != nil {

View File

@ -1,3 +1,31 @@
/*
NAME
revid_test.go
DESCRIPTION
See Readme.md
AUTHORS
Saxon A. Nelson-Milton <saxon@ausocean.org>
Alan Noble <alan@ausocean.org>
LICENSE
This is Copyright (C) 2019 the Australian Ocean Lab (AusOcean).
It is free software: you can redistribute it and/or modify them
under the terms of the GNU General Public License as published by the
Free Software Foundation, either version 3 of the License, or (at your
option) any later version.
It is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
in gpl.txt. If not, see http://www.gnu.org/licenses.
*/
package revid package revid
import ( import (

View File

@ -298,7 +298,7 @@ func (s *rtmpSender) output() {
defer s.wg.Done() defer s.wg.Done()
return return
default: default:
// If chunk is nil then we're ready to get another from the ringBuffer. // If chunk is nil then we're ready to get another from the ring buffer.
if chunk == nil { if chunk == nil {
var err error var err error
chunk, err = s.ring.Next(0) chunk, err = s.ring.Next(0)
@ -342,7 +342,7 @@ func (s *rtmpSender) output() {
func (s *rtmpSender) Write(d []byte) (int, error) { func (s *rtmpSender) Write(d []byte) (int, error) {
_, err := s.ring.Write(d) _, err := s.ring.Write(d)
if err != nil { if err != nil {
s.log(logger.Warning, pkg+"rtmpSender: ringBuffer write error", "error", err.Error()) s.log(logger.Warning, pkg+"rtmpSender: ring buffer write error", "error", err.Error())
} }
s.ring.Flush() s.ring.Flush()
return len(d), nil return len(d), nil