From 82903681eeb4260ce5ec4749654887ddab5cf24f Mon Sep 17 00:00:00 2001 From: Saxon Date: Sat, 2 Nov 2019 10:42:56 +1030 Subject: [PATCH] revid/raspivid.go: wrote Stop implementation for Raspivid AVDevice implementation --- revid/raspivid.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/revid/raspivid.go b/revid/raspivid.go index f5ff0e75..d28f521f 100644 --- a/revid/raspivid.go +++ b/revid/raspivid.go @@ -213,3 +213,14 @@ func (r *Raspivid) Start() error { func (r *Raspivid) Read(p []byte) (int, error) { return r.out.Read(p) } + +func (r *Raspivid) Stop() error { + if r.cmd == nil || r.cmd.Process == nil { + return errors.New("raspivid process was never started") + } + err := r.cmd.Process.Kill() + if err != nil { + return fmt.Errorf("could not kill raspivid process: %w", err) + } + return nil +}