Fixed buffer full issue!

This commit is contained in:
Saxon Milton 2018-04-25 13:31:14 +09:30
parent 2d812363cf
commit b430224020
1 changed files with 7 additions and 4 deletions

View File

@ -374,13 +374,16 @@ func (r *revid) outputClips() {
if clip, err := r.ringBuffer.Read(); err == nil { if clip, err := r.ringBuffer.Read(); err == nil {
bytes += len(clip) bytes += len(clip)
errorCount := 0 errorCount := 0
err := r.sendClip(clip) err2 := r.sendClip(clip)
for ; err != nil; errorCount++ { for ; err2 != nil; errorCount++ {
r.Log(Warning, "Send failed trying again!") r.Log(Warning, "Send failed trying again!")
// If the clip size is not bigger than the threshold then we classify // If the clip size is not bigger than the threshold then we classify
// it as junk and we don't try to send it off again. // it as junk and we don't try to send it off again.
if len(clip) >= clipSizeThreshold { if len(clip) >= clipSizeThreshold {
err = r.sendClip(clip) err2 = r.sendClip(clip)
if err2 == nil {
break
}
} else { } else {
break break
} }
@ -389,7 +392,7 @@ func (r *revid) outputClips() {
if errorCount > maxSendFailedErrorCount { if errorCount > maxSendFailedErrorCount {
time.Sleep(time.Duration(sendFailedDelay) * time.Second) time.Sleep(time.Duration(sendFailedDelay) * time.Second)
} }
r.Log(Error, err.Error()) r.Log(Error, err2.Error())
if r.config.Output == NativeRtmp && errorCount > 5 { if r.config.Output == NativeRtmp && errorCount > 5 {
r.reboot() r.reboot()
} }