handling buffer full error better

This commit is contained in:
Saxon Milton 2018-04-24 13:47:05 +09:30
parent 7edf430f9a
commit 113293a3e0
1 changed files with 5 additions and 2 deletions

View File

@ -302,7 +302,10 @@ func (r *revid) packClips() {
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!")
r.flushData() // Keep clearing output chan until out buffer has some space
for clip, err = r.ringBuffer.Get(); err != nil {
r.flushData()
}
continue continue
} }
for { for {
@ -560,7 +563,7 @@ func (r *revid) readCamera() {
_, err := io.ReadFull(r.inputReader, data) _, err := io.ReadFull(r.inputReader, data)
switch { switch {
// We know this means we're getting nothing from the cam // We know this means we're getting nothing from the cam
case err != nil && err.Error() == "EOF" && r.isRunning: case ( err != nil && err.Error() == "EOF" && r.isRunning ) || ( err != nil && r.isRunning):
r.Log(Error, "No data from camera!") r.Log(Error, "No data from camera!")
time.Sleep(cameraRetryPeriod) time.Sleep(cameraRetryPeriod)
default: default: