handle data race between updateState and OnStateChange (#727)

Signed-off-by: shishir gowda <shishir@livekit.io>
This commit is contained in:
shishirng authored and David Zhao committed 2022-05-27 12:39:35 -07:00
1 parent cbbd553f8e
commit 8048a89d5e
1 file changed
+2
+2
View File
@@ -431,6 +431,8 @@ func (p *ParticipantImpl) OnTrackPublished(callback func(types.LocalParticipant,
}
func (p *ParticipantImpl) OnStateChange(callback func(p types.LocalParticipant, oldState livekit.ParticipantInfo_State)) {
p.lock.Lock()
defer p.lock.Unlock()
p.onStateChange = callback
}