From 25d68cf1248c174a78357d8d3a0b0aefab5509de Mon Sep 17 00:00:00 2001 From: Scott Date: Thu, 30 Jan 2020 11:22:11 +1030 Subject: [PATCH] device/raspivid: implement IsRunning method for raspivid --- device/raspivid/raspivid.go | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/device/raspivid/raspivid.go b/device/raspivid/raspivid.go index 4168098f..d47fc346 100644 --- a/device/raspivid/raspivid.go +++ b/device/raspivid/raspivid.go @@ -107,11 +107,12 @@ var AutoWhiteBalanceModes = [...]string{ // Raspivid is an implementation of AVDevice that provides control over the // raspivid command to allow reading of data from a Raspberry Pi camera. type Raspivid struct { - cfg config.Config - cmd *exec.Cmd - out io.ReadCloser - log config.Logger - done chan struct{} + cfg config.Config + cmd *exec.Cmd + out io.ReadCloser + log config.Logger + done chan struct{} + isRunning bool } // New returns a new Raspivid. @@ -287,6 +288,7 @@ func (r *Raspivid) Start() error { if err != nil { return fmt.Errorf("could not start raspivid command: %w", err) } + r.isRunning = true return nil } @@ -310,11 +312,11 @@ func (r *Raspivid) Stop() error { if err != nil { return fmt.Errorf("could not kill raspivid process: %w", err) } + r.isRunning = false return r.out.Close() } // IsRunning is used to determine if the pi's camera is running. func (r *Raspivid) IsRunning() bool { - panic("not implemented") - return false + return r.isRunning }