Limit buffer queue before Bind. (#3634)
* Limit buffer queue before Bind. * more generic
This commit is contained in:
@@ -393,10 +393,17 @@ func (b *Buffer) Write(pkt []byte) (n int, err error) {
|
|||||||
if !b.bound {
|
if !b.bound {
|
||||||
packet := make([]byte, len(pkt))
|
packet := make([]byte, len(pkt))
|
||||||
copy(packet, pkt)
|
copy(packet, pkt)
|
||||||
b.pPackets = append(b.pPackets, pendingPacket{
|
|
||||||
|
startIdx := 0
|
||||||
|
overflow := len(b.pPackets) - max(b.maxVideoPkts, b.maxAudioPkts)
|
||||||
|
if overflow > 0 {
|
||||||
|
startIdx = overflow
|
||||||
|
}
|
||||||
|
b.pPackets = append(b.pPackets[startIdx:], pendingPacket{
|
||||||
packet: packet,
|
packet: packet,
|
||||||
arrivalTime: now,
|
arrivalTime: now,
|
||||||
})
|
})
|
||||||
|
|
||||||
b.readCond.Broadcast()
|
b.readCond.Broadcast()
|
||||||
b.Unlock()
|
b.Unlock()
|
||||||
return
|
return
|
||||||
|
|||||||
Reference in New Issue
Block a user