mirror of https://bitbucket.org/ausocean/av.git
Merged in rb-write-error (pull request #271)
revid: sender ring buffers flush only if write was successful Approved-by: Alan Noble <anoble@gmail.com>
This commit is contained in:
commit
9c027d857f
|
@ -248,10 +248,12 @@ func (s *mtsSender) Write(d []byte) (int, error) {
|
||||||
if time.Now().Sub(s.prev) >= s.clipDur && s.curPid == mts.PatPid && len(s.buf) > 0 {
|
if time.Now().Sub(s.prev) >= s.clipDur && s.curPid == mts.PatPid && len(s.buf) > 0 {
|
||||||
s.prev = time.Now()
|
s.prev = time.Now()
|
||||||
_, err := s.ring.Write(s.buf)
|
_, err := s.ring.Write(s.buf)
|
||||||
|
if err == nil {
|
||||||
|
s.ring.Flush()
|
||||||
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
s.log(logger.Warning, pkg+"mtsSender: ringBuffer write error", "error", err.Error())
|
s.log(logger.Warning, pkg+"mtsSender: ringBuffer write error", "error", err.Error())
|
||||||
}
|
}
|
||||||
s.ring.Flush()
|
|
||||||
s.buf = s.buf[:0]
|
s.buf = s.buf[:0]
|
||||||
}
|
}
|
||||||
return len(d), nil
|
return len(d), nil
|
||||||
|
@ -356,10 +358,12 @@ func (s *rtmpSender) output() {
|
||||||
// Write implements io.Writer.
|
// Write implements io.Writer.
|
||||||
func (s *rtmpSender) Write(d []byte) (int, error) {
|
func (s *rtmpSender) Write(d []byte) (int, error) {
|
||||||
_, err := s.ring.Write(d)
|
_, err := s.ring.Write(d)
|
||||||
|
if err == nil {
|
||||||
|
s.ring.Flush()
|
||||||
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
s.log(logger.Warning, pkg+"rtmpSender: ring buffer write error", "error", err.Error())
|
s.log(logger.Warning, pkg+"rtmpSender: ring buffer write error", "error", err.Error())
|
||||||
}
|
}
|
||||||
s.ring.Flush()
|
|
||||||
return len(d), nil
|
return len(d), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue