mirror of
https://github.com/livekit/livekit.git
synced 2026-07-28 18:39:41 +00:00
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 {
|
||||
packet := make([]byte, len(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,
|
||||
arrivalTime: now,
|
||||
})
|
||||
|
||||
b.readCond.Broadcast()
|
||||
b.Unlock()
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user