mirror of
https://github.com/AlexxIT/go2rtc.git
synced 2025-09-27 04:36:12 +08:00
Fix deadlock on write to track channel
This commit is contained in:
@@ -97,8 +97,9 @@ func NewSender(media *Media, codec *Codec) *Sender {
|
||||
buf: buf,
|
||||
}
|
||||
s.Input = func(packet *Packet) {
|
||||
// writing to nil chan - OK, writing to closed chan - panic
|
||||
s.mu.Lock()
|
||||
if s.buf != nil {
|
||||
// unblocked write to channel
|
||||
select {
|
||||
case s.buf <- packet:
|
||||
s.Bytes += len(packet.Payload)
|
||||
@@ -106,6 +107,9 @@ func NewSender(media *Media, codec *Codec) *Sender {
|
||||
default:
|
||||
s.Drops++
|
||||
}
|
||||
} else {
|
||||
s.Drops++
|
||||
}
|
||||
s.mu.Unlock()
|
||||
}
|
||||
s.Output = func(packet *Packet) {
|
||||
|
Reference in New Issue
Block a user