mirror of https://bitbucket.org/ausocean/av.git
More checks for isRunning.
This commit is contained in:
parent
8b42c57b9e
commit
098cc19c60
|
@ -349,8 +349,8 @@ func (r *revid) packClips() {
|
|||
|
||||
for r.isRunning {
|
||||
select {
|
||||
// TODO: This is temporary, need to work out how to make this work
|
||||
// for cases when there is not packetisation.
|
||||
// TODO: This is temporary, need to work out how to make this work
|
||||
// for cases when there is not packetisation.
|
||||
case frame := <-(r.generator.GetOutputChan()):
|
||||
lenOfFrame := len(frame)
|
||||
if lenOfFrame > ringBufferElementSize {
|
||||
|
@ -377,10 +377,10 @@ func (r *revid) packClips() {
|
|||
goto finishedWithClip
|
||||
}
|
||||
default:
|
||||
time.Sleep(time.Duration(5)*time.Millisecond)
|
||||
time.Sleep(time.Duration(5) * time.Millisecond)
|
||||
}
|
||||
}
|
||||
finishedWithClip:
|
||||
finishedWithClip:
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -400,7 +400,6 @@ func (r *revid) outputClips() {
|
|||
case delay > 0:
|
||||
delay--
|
||||
}
|
||||
|
||||
// If the ringbuffer has something we can read and send off
|
||||
if clip, err := r.ringBuffer.Read(); err == nil && r.isRunning {
|
||||
bytes += len(clip)
|
||||
|
@ -408,15 +407,15 @@ func (r *revid) outputClips() {
|
|||
err2 := r.sendClip(clip)
|
||||
r.Log(Debug, "Finished send")
|
||||
|
||||
if err2 != nil && len(clip) > 11 {
|
||||
if r.isRunning && err2 != nil && len(clip) > 11 {
|
||||
r.Log(Debug, "Send failed! Trying again")
|
||||
// Try and send again
|
||||
err2 = r.sendClip(clip)
|
||||
|
||||
// if there's still an error we try and reconnect
|
||||
for err2 != nil {
|
||||
// if there's still an error we try and reconnect, unless we're stopping
|
||||
for r.isRunning && err2 != nil {
|
||||
r.Log(Debug, "Send failed a again! Trying to reconnect...")
|
||||
time.Sleep(time.Duration(5)*time.Millisecond)
|
||||
time.Sleep(time.Duration(5) * time.Millisecond)
|
||||
r.Log(Error, err2.Error())
|
||||
|
||||
if r.config.Output == NativeRtmp {
|
||||
|
@ -439,6 +438,10 @@ func (r *revid) outputClips() {
|
|||
}
|
||||
}
|
||||
|
||||
if !r.isRunning {
|
||||
break
|
||||
}
|
||||
|
||||
r.Log(Debug, "Done reading that clip from ringbuffer...")
|
||||
// let the ringbuffer know that we're done with the memory we grabbed when
|
||||
// we call ringBuffer.Get()
|
||||
|
@ -455,8 +458,6 @@ func (r *revid) outputClips() {
|
|||
prevTime = now
|
||||
bytes = 0
|
||||
}
|
||||
} else {
|
||||
//r.Log(Error, err.Error())
|
||||
}
|
||||
}
|
||||
r.Log(Info, "Not outputting clips anymore!")
|
||||
|
|
Loading…
Reference in New Issue