diff --git a/revid/mtsSender_test.go b/revid/mtsSender_test.go index de1b3ef4..9a0cfab3 100644 --- a/revid/mtsSender_test.go +++ b/revid/mtsSender_test.go @@ -24,7 +24,7 @@ LICENSE for more details. You should have received a copy of the GNU General Public License - along with revid in gpl.txt. If not, see http://www.gnu.org/licenses. + in gpl.txt. If not, see http://www.gnu.org/licenses. */ package revid diff --git a/revid/senders.go b/revid/senders.go index 85f86a7d..03b4afc6 100644 --- a/revid/senders.go +++ b/revid/senders.go @@ -140,6 +140,7 @@ type mtsSender struct { discarded bool repairer *mts.DiscontinuityRepairer chunk *ring.Chunk + curPid int } // newmtsSender returns a new mtsSender. @@ -153,12 +154,6 @@ func newMtsSender(s sender, log func(lvl int8, msg string, args ...interface{})) // load takes a *ring.Chunk and extracts bytes copying into s.pkt for use by the sender. func (s *mtsSender) load(c *ring.Chunk) error { s.chunk = c - return nil -} - -// send checks the most recently loaded packet and if it is a PAT then the clip -// in s.buf is sent, otherwise the packet is added to s.buf. -func (s *mtsSender) send() error { if s.next != nil { s.buf = append(s.buf, s.next...) } @@ -169,8 +164,14 @@ func (s *mtsSender) send() error { copy(s.pkt[:], cpy) p := (*packet.Packet)(&s.pkt) - pid := p.PID() - if pid == mts.PatPid && len(s.buf) > 0 { + s.curPid = p.PID() + return nil +} + +// send checks the most recently loaded packet and if it is a PAT then the clip +// in s.buf is sent, otherwise the packet is added to s.buf. +func (s *mtsSender) send() error { + if s.curPid == mts.PatPid && len(s.buf) > 0 { err := s.fixAndSend() if err != nil { s.failed = true