some more checks

This commit is contained in:
Saxon1 2018-05-06 17:16:38 +09:30
parent 94e174b641
commit 145708c334
1 changed files with 4 additions and 4 deletions

View File

@ -324,20 +324,20 @@ func (r *revid) flushData() {
func (r *revid) packClips() { func (r *revid) packClips() {
clipSize := 0 clipSize := 0
packetCount := 0 packetCount := 0
for { for r.isRunning {
// Get some memory from the ring buffer for out clip // Get some memory from the ring buffer for out clip
var clip []byte var clip []byte
var err error var err error
if clip, err = r.ringBuffer.Get(); err != nil { if clip, err = r.ringBuffer.Get(); err != nil {
r.Log(Error, err.Error()) r.Log(Error, err.Error())
r.Log(Warning, "Clearing output chan!") 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) time.Sleep(time.Duration(10) * time.Millisecond)
clip, err = r.ringBuffer.Get() clip, err = r.ringBuffer.Get()
} }
r.Log(Debug, "Finally got mem from ringbuffer!") r.Log(Debug, "Finally got mem from ringbuffer!")
} }
for { for r.isRunning {
frame := r.getFrame() frame := r.getFrame()
lenOfFrame := len(frame) lenOfFrame := len(frame)
if lenOfFrame > ringBufferElementSize { if lenOfFrame > ringBufferElementSize {
@ -385,7 +385,7 @@ func (r *revid) outputClips() {
} }
// If the ringbuffer has something we can read and send off // 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) bytes += len(clip)
errorCount := 0 errorCount := 0
r.Log(Debug,"About to send!") r.Log(Debug,"About to send!")