fix: handshake mutex was keeping the room mutex in locked state
parent
1ff98068cd
commit
53d51d446a
|
@ -25,6 +25,7 @@ type Peer struct {
|
||||||
Conn *webrtc.PeerConnection
|
Conn *webrtc.PeerConnection
|
||||||
CanPublish bool
|
CanPublish bool
|
||||||
HandshakeLock *sync.Mutex
|
HandshakeLock *sync.Mutex
|
||||||
|
didOnce bool
|
||||||
}
|
}
|
||||||
|
|
||||||
type Room struct {
|
type Room struct {
|
||||||
|
@ -237,7 +238,7 @@ func (r *RoomRepository) updatePCTracks(roomId string) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
room := r.Rooms[roomId]
|
room := r.Rooms[roomId]
|
||||||
defer r.Unlock()
|
r.Unlock()
|
||||||
room.Lock()
|
room.Lock()
|
||||||
defer room.Unlock()
|
defer room.Unlock()
|
||||||
for _, peer := range room.Peers {
|
for _, peer := range room.Peers {
|
||||||
|
@ -278,17 +279,19 @@ func (r *RoomRepository) updatePCTracks(roomId string) {
|
||||||
for trackId, rtpSender := range alreadySentTracks {
|
for trackId, rtpSender := range alreadySentTracks {
|
||||||
if _, exists := room.Tracks[trackId]; !exists {
|
if _, exists := room.Tracks[trackId]; !exists {
|
||||||
println("[PC] remove track", trackId, "from", peer.ID)
|
println("[PC] remove track", trackId, "from", peer.ID)
|
||||||
_ = rtpSender.Stop()
|
//_ = rtpSender.Stop()
|
||||||
_ = peer.Conn.RemoveTrack(rtpSender)
|
_ = peer.Conn.RemoveTrack(rtpSender)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
room.trackLock.Unlock()
|
room.trackLock.Unlock()
|
||||||
if renegotiate {
|
if renegotiate {
|
||||||
|
go func(peer *Peer, roomId string) {
|
||||||
err := r.offerPeer(peer, roomId)
|
err := r.offerPeer(peer, roomId)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
println(`[E]`, err.Error())
|
println(`[E]`, err.Error())
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
}(peer, roomId)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue