mirror of
https://github.com/bluenviron/mediamtx.git
synced 2025-12-30 06:51:59 -08:00
OnConnectionStateChange of pion/webrtc is not thread safe. Add a mutex to make it thread safe.
This commit is contained in:
parent
8ffdd9c80e
commit
64b8fd3554
1 changed files with 4 additions and 0 deletions
|
|
@ -345,8 +345,12 @@ func (c *webRTCConn) runInner(ctx context.Context) error {
|
|||
pcConnected := make(chan struct{})
|
||||
pcDisconnected := make(chan struct{})
|
||||
pcClosed := make(chan struct{})
|
||||
var stateChangeMutex sync.Mutex
|
||||
|
||||
pc.OnConnectionStateChange(func(state webrtc.PeerConnectionState) {
|
||||
stateChangeMutex.Lock()
|
||||
defer stateChangeMutex.Unlock()
|
||||
|
||||
select {
|
||||
case <-pcClosed:
|
||||
return
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue