revid/raspivid.go: wrote Stop implementation for Raspivid AVDevice implementation

This commit is contained in:
Saxon 2019-11-02 10:42:56 +10:30
parent b2a9dbf17d
commit 82903681ee
1 changed files with 11 additions and 0 deletions

View File

@ -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
}