From 145708c334f8c9870d9f28bed88ca1647c7b6614 Mon Sep 17 00:00:00 2001 From: Saxon1 Date: Sun, 6 May 2018 17:16:38 +0930 Subject: [PATCH] some more checks --- revid/Revid.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/revid/Revid.go b/revid/Revid.go index 08a24094..8db224a2 100644 --- a/revid/Revid.go +++ b/revid/Revid.go @@ -324,20 +324,20 @@ func (r *revid) flushData() { func (r *revid) packClips() { clipSize := 0 packetCount := 0 - for { + for r.isRunning { // Get some memory from the ring buffer for out clip var clip []byte var err error if clip, err = r.ringBuffer.Get(); err != nil { r.Log(Error, err.Error()) r.Log(Warning, "Clearing output chan!") - for clip, err = r.ringBuffer.Get(); err != nil; { + for clip, err = r.ringBuffer.Get(); err != nil && r.isRunning; { time.Sleep(time.Duration(10) * time.Millisecond) clip, err = r.ringBuffer.Get() } r.Log(Debug, "Finally got mem from ringbuffer!") } - for { + for r.isRunning { frame := r.getFrame() lenOfFrame := len(frame) if lenOfFrame > ringBufferElementSize { @@ -385,7 +385,7 @@ func (r *revid) outputClips() { } // If the ringbuffer has something we can read and send off - if clip, err := r.ringBuffer.Read(); err == nil { + if clip, err := r.ringBuffer.Read(); err == nil && r.isRunning { bytes += len(clip) errorCount := 0 r.Log(Debug,"About to send!")