Merged in raspivid-close-of-closed-chan-fix (pull request #395)

device/raspivid: fix closing of closed done chan
This commit is contained in:
Saxon Milton 2020-04-02 13:13:20 +00:00
commit d577b078a5
1 changed files with 3 additions and 0 deletions

View File

@ -305,6 +305,9 @@ func (r *Raspivid) Read(p []byte) (int, error) {
// Stop will terminate the raspivid process and close the output pipe. // Stop will terminate the raspivid process and close the output pipe.
func (r *Raspivid) Stop() error { func (r *Raspivid) Stop() error {
if r.isRunning == false {
return nil
}
close(r.done) close(r.done)
if r.cmd == nil || r.cmd.Process == nil { if r.cmd == nil || r.cmd.Process == nil {
return errors.New("raspivid process was never started") return errors.New("raspivid process was never started")