mirror of https://bitbucket.org/ausocean/av.git
device/webcam: don't close closed chan
This commit is contained in:
parent
0dfb2df939
commit
2f85dbcdf6
|
@ -197,6 +197,10 @@ func (w *Webcam) Start() error {
|
|||
|
||||
// Stop will kill the ffmpeg process and close the output pipe.
|
||||
func (w *Webcam) Stop() error {
|
||||
if !w.isRunning {
|
||||
return nil
|
||||
}
|
||||
w.isRunning = false
|
||||
close(w.done)
|
||||
if w.cmd == nil || w.cmd.Process == nil {
|
||||
return errors.New("ffmpeg process was never started")
|
||||
|
@ -205,12 +209,7 @@ func (w *Webcam) Stop() error {
|
|||
if err != nil {
|
||||
return fmt.Errorf("could not kill ffmpeg process: %w", err)
|
||||
}
|
||||
err = w.out.Close()
|
||||
if err == nil {
|
||||
w.isRunning = false
|
||||
return nil
|
||||
}
|
||||
return err
|
||||
return w.out.Close()
|
||||
}
|
||||
|
||||
// Read implements io.Reader. If the pipe is nil a read error is returned.
|
||||
|
|
Loading…
Reference in New Issue