potential fix

This commit is contained in:
Saxon Milton 2018-04-25 16:55:42 +09:30
parent 0960b6e7e5
commit 929f9992f3
2 changed files with 12 additions and 3 deletions

View File

@ -71,7 +71,7 @@ const (
defaultRunDuration = 2 * 43200
noOfConfigconfigFlags = 19
revidStopTime = 5
prepTime = 15
prepTime = 20
loggerVerbosity = 4
)

View File

@ -294,7 +294,9 @@ func (r *revid) getFramePacketization() []byte {
// flushDataPacketization removes data from the revid inst's coutput chan
func (r *revid) flushData() {
<-(r.outputChan)
for len(r.outputChan) > 0 {
<-(r.outputChan)
}
}
// packClips takes data segments; whether that be tsPackets or mjpeg frames and
@ -308,11 +310,18 @@ func (r *revid) packClips() {
var err error
if clip, err = r.ringBuffer.Get(); err != nil {
r.Log(Error, err.Error())
r.reboot()
r.Log(Warning, "Clearing output chan!")
// Keep clearing output chan until out buffer has some space
for clip, err = r.ringBuffer.Get(); err != nil; {
r.flushData()
err2 := r.rtmpInst.EndSession()
if err2 != nil {
r.Log(Error, err2.Error())
}
err3 := r.rtmpInst.StartSession()
if err3 != nil {
r.Log(Error, err3.Error())
}
clip, err = r.ringBuffer.Get()
}
r.Log(Debug, "Finally got mem from ringbuffer!")