mirror of https://bitbucket.org/ausocean/av.git
Increased debugging messages and also potentially fixed blocking issue
This commit is contained in:
parent
3ce4fae82b
commit
8179b371e6
|
@ -346,8 +346,12 @@ func (r *revid) packClips() {
|
||||||
}
|
}
|
||||||
r.Log(Debug, "Finally got mem from ringbuffer!")
|
r.Log(Debug, "Finally got mem from ringbuffer!")
|
||||||
}
|
}
|
||||||
|
|
||||||
for r.isRunning {
|
for r.isRunning {
|
||||||
frame := r.getFrame()
|
select {
|
||||||
|
// 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)
|
lenOfFrame := len(frame)
|
||||||
if lenOfFrame > ringBufferElementSize {
|
if lenOfFrame > ringBufferElementSize {
|
||||||
r.Log(Warning, fmt.Sprintf("Frame was too big: %v bytes, getting another one!", lenOfFrame))
|
r.Log(Warning, fmt.Sprintf("Frame was too big: %v bytes, getting another one!", lenOfFrame))
|
||||||
|
@ -372,6 +376,9 @@ func (r *revid) packClips() {
|
||||||
packetCount = 0
|
packetCount = 0
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
default:
|
||||||
|
time.Sleep(time.Duration(5)*time.Millisecond)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -396,31 +403,42 @@ 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 && r.isRunning {
|
if clip, err := r.ringBuffer.Read(); err == nil && r.isRunning {
|
||||||
bytes += len(clip)
|
bytes += len(clip)
|
||||||
r.Log(Debug, "About to send!")
|
r.Log(Debug, "About to send")
|
||||||
err2 := r.sendClip(clip)
|
err2 := r.sendClip(clip)
|
||||||
r.Log(Debug, "Finished send!")
|
r.Log(Debug, "Finished send")
|
||||||
|
|
||||||
if err2 != nil && len(clip) > 11 {
|
if err2 != nil && len(clip) > 11 {
|
||||||
|
r.Log(Debug, "Send failed! Trying again")
|
||||||
// Try and send again
|
// Try and send again
|
||||||
err2 = r.sendClip(clip)
|
err2 = r.sendClip(clip)
|
||||||
|
|
||||||
// if there's still an error we try and reconnect
|
// if there's still an error we try and reconnect
|
||||||
for err2 != nil {
|
for 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())
|
r.Log(Error, err2.Error())
|
||||||
|
|
||||||
if r.config.Output == NativeRtmp {
|
if r.config.Output == NativeRtmp {
|
||||||
|
r.Log(Debug, "Ending current rtmp session...")
|
||||||
r.rtmpInst.EndSession()
|
r.rtmpInst.EndSession()
|
||||||
}
|
}
|
||||||
if r.ringBuffer.Full() {
|
if r.ringBuffer.Full() {
|
||||||
|
r.Log(Debug, "Flushing incoming data...")
|
||||||
r.flushData()
|
r.flushData()
|
||||||
}
|
}
|
||||||
|
|
||||||
if r.config.Output == NativeRtmp {
|
if r.config.Output == NativeRtmp {
|
||||||
|
r.Log(Debug, "Restarting rtmp session...")
|
||||||
r.rtmpInst.StartSession()
|
r.rtmpInst.StartSession()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
r.Log(Debug, "Trying to send again with new connection...")
|
||||||
// and if the ring buffer is full then we flush the incoming data
|
// and if the ring buffer is full then we flush the incoming data
|
||||||
err2 = r.sendClip(clip)
|
err2 = r.sendClip(clip)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
r.Log(Debug, "Done reading that clip from ringbuffer...")
|
||||||
// let the ringbuffer know that we're done with the memory we grabbed when
|
// let the ringbuffer know that we're done with the memory we grabbed when
|
||||||
// we call ringBuffer.Get()
|
// we call ringBuffer.Get()
|
||||||
if err := r.ringBuffer.DoneReading(); err != nil {
|
if err := r.ringBuffer.DoneReading(); err != nil {
|
||||||
|
|
Loading…
Reference in New Issue