@@ -55,12 +55,12 @@ type PeerConnection struct {
5555
5656 idpLoginURL * string
5757
58- isClosed * atomicBool
58+ isClosed * atomic. Bool
5959 isGracefullyClosingOrClosed bool
6060 isCloseDone chan struct {}
6161 isGracefulCloseDone chan struct {}
62- isNegotiationNeeded * atomicBool
63- updateNegotiationNeededFlagOnEmptyChain * atomicBool
62+ isNegotiationNeeded * atomic. Bool
63+ updateNegotiationNeededFlagOnEmptyChain * atomic. Bool
6464
6565 lastOffer string
6666 lastAnswer string
@@ -124,11 +124,11 @@ func (api *API) NewPeerConnection(configuration Configuration) (*PeerConnection,
124124 Certificates : []Certificate {},
125125 ICECandidatePoolSize : 0 ,
126126 },
127- isClosed : & atomicBool {},
127+ isClosed : & atomic. Bool {},
128128 isCloseDone : make (chan struct {}),
129129 isGracefulCloseDone : make (chan struct {}),
130- isNegotiationNeeded : & atomicBool {},
131- updateNegotiationNeededFlagOnEmptyChain : & atomicBool {},
130+ isNegotiationNeeded : & atomic. Bool {},
131+ updateNegotiationNeededFlagOnEmptyChain : & atomic. Bool {},
132132 lastOffer : "" ,
133133 lastAnswer : "" ,
134134 greaterMid : - 1 ,
@@ -296,7 +296,7 @@ func (pc *PeerConnection) onNegotiationNeeded() {
296296 // 4.7.3.1 If the length of connection.[[Operations]] is not 0, then set
297297 // connection.[[UpdateNegotiationNeededFlagOnEmptyChain]] to true, and abort these steps.
298298 if ! pc .ops .IsEmpty () {
299- pc .updateNegotiationNeededFlagOnEmptyChain .set (true )
299+ pc .updateNegotiationNeededFlagOnEmptyChain .Store (true )
300300
301301 return
302302 }
@@ -306,15 +306,15 @@ func (pc *PeerConnection) onNegotiationNeeded() {
306306// https://www.w3.org/TR/webrtc/#dfn-update-the-negotiation-needed-flag
307307func (pc * PeerConnection ) negotiationNeededOp () {
308308 // 4.7.3.2.1 If connection.[[IsClosed]] is true, abort these steps.
309- if pc .isClosed .get () {
309+ if pc .isClosed .Load () {
310310 return
311311 }
312312
313313 // 4.7.3.2.2 If the length of connection.[[Operations]] is not 0,
314314 // then set connection.[[UpdateNegotiationNeededFlagOnEmptyChain]] to
315315 // true, and abort these steps.
316316 if ! pc .ops .IsEmpty () {
317- pc .updateNegotiationNeededFlagOnEmptyChain .set (true )
317+ pc .updateNegotiationNeededFlagOnEmptyChain .Store (true )
318318
319319 return
320320 }
@@ -328,18 +328,18 @@ func (pc *PeerConnection) negotiationNeededOp() {
328328 // clear the negotiation-needed flag by setting connection.[[NegotiationNeeded]]
329329 // to false, and abort these steps.
330330 if ! pc .checkNegotiationNeeded () {
331- pc .isNegotiationNeeded .set (false )
331+ pc .isNegotiationNeeded .Store (false )
332332
333333 return
334334 }
335335
336336 // 4.7.3.2.5 If connection.[[NegotiationNeeded]] is already true, abort these steps.
337- if pc .isNegotiationNeeded .get () {
337+ if pc .isNegotiationNeeded .Load () {
338338 return
339339 }
340340
341341 // 4.7.3.2.6 Set connection.[[NegotiationNeeded]] to true.
342- pc .isNegotiationNeeded .set (true )
342+ pc .isNegotiationNeeded .Store (true )
343343
344344 // 4.7.3.2.7 Fire an event named negotiationneeded at connection.
345345 if handler , ok := pc .onNegotiationNeededHandler .Load ().(func ()); ok && handler != nil {
@@ -513,7 +513,7 @@ func (pc *PeerConnection) onConnectionStateChange(cs PeerConnectionState) {
513513// SetConfiguration updates the configuration of this PeerConnection object.
514514func (pc * PeerConnection ) SetConfiguration (configuration Configuration ) error { //nolint:gocognit,cyclop
515515 // https://www.w3.org/TR/webrtc/#dom-rtcpeerconnection-setconfiguration (step #2)
516- if pc .isClosed .get () {
516+ if pc .isClosed .Load () {
517517 return & rtcerr.InvalidStateError {Err : ErrConnectionClosed }
518518 }
519519
@@ -623,7 +623,7 @@ func (pc *PeerConnection) CreateOffer(options *OfferOptions) (SessionDescription
623623 switch {
624624 case useIdentity :
625625 return SessionDescription {}, errIdentityProviderNotImplemented
626- case pc .isClosed .get ():
626+ case pc .isClosed .Load ():
627627 return SessionDescription {}, & rtcerr.InvalidStateError {Err : ErrConnectionClosed }
628628 }
629629
@@ -763,7 +763,7 @@ func (pc *PeerConnection) updateConnectionState(
763763 connectionState := PeerConnectionStateNew
764764 switch {
765765 // The RTCPeerConnection object's [[IsClosed]] slot is true.
766- case pc .isClosed .get ():
766+ case pc .isClosed .Load ():
767767 connectionState = PeerConnectionStateClosed
768768
769769 // Any of the RTCIceTransports or RTCDtlsTransports are in a "failed" state.
@@ -844,7 +844,7 @@ func (pc *PeerConnection) CreateAnswer(*AnswerOptions) (SessionDescription, erro
844844 return SessionDescription {}, & rtcerr.InvalidStateError {Err : ErrNoRemoteDescription }
845845 case useIdentity :
846846 return SessionDescription {}, errIdentityProviderNotImplemented
847- case pc .isClosed .get ():
847+ case pc .isClosed .Load ():
848848 return SessionDescription {}, & rtcerr.InvalidStateError {Err : ErrConnectionClosed }
849849 case pc .signalingState .Get () != SignalingStateHaveRemoteOffer &&
850850 pc .signalingState .Get () != SignalingStateHaveLocalPranswer :
@@ -891,7 +891,7 @@ func (pc *PeerConnection) CreateAnswer(*AnswerOptions) (SessionDescription, erro
891891//nolint:gocognit,cyclop
892892func (pc * PeerConnection ) setDescription (sd * SessionDescription , op stateChangeOp ) error {
893893 switch {
894- case pc .isClosed .get ():
894+ case pc .isClosed .Load ():
895895 return & rtcerr.InvalidStateError {Err : ErrConnectionClosed }
896896 case NewSDPType (sd .Type .String ()) == SDPTypeUnknown :
897897 return & rtcerr.TypeError {
@@ -995,7 +995,7 @@ func (pc *PeerConnection) setDescription(sd *SessionDescription, op stateChangeO
995995 if err == nil {
996996 pc .signalingState .Set (nextState )
997997 if pc .signalingState .Get () == SignalingStateStable {
998- pc .isNegotiationNeeded .set (false )
998+ pc .isNegotiationNeeded .Store (false )
999999 pc .mu .Lock ()
10001000 pc .onNegotiationNeeded ()
10011001 pc .mu .Unlock ()
@@ -1010,7 +1010,7 @@ func (pc *PeerConnection) setDescription(sd *SessionDescription, op stateChangeO
10101010//
10111011//nolint:cyclop
10121012func (pc * PeerConnection ) SetLocalDescription (desc SessionDescription ) error {
1013- if pc .isClosed .get () {
1013+ if pc .isClosed .Load () {
10141014 return & rtcerr.InvalidStateError {Err : ErrConnectionClosed }
10151015 }
10161016
@@ -1081,7 +1081,7 @@ func (pc *PeerConnection) LocalDescription() *SessionDescription {
10811081//
10821082//nolint:gocognit,gocyclo,cyclop,maintidx
10831083func (pc * PeerConnection ) SetRemoteDescription (desc SessionDescription ) error {
1084- if pc .isClosed .get () {
1084+ if pc .isClosed .Load () {
10851085 return & rtcerr.InvalidStateError {Err : ErrConnectionClosed }
10861086 }
10871087
@@ -1886,7 +1886,7 @@ func (pc *PeerConnection) undeclaredRTPMediaProcessor() { //nolint:cyclop
18861886 return
18871887 }
18881888
1889- if pc .isClosed .get () {
1889+ if pc .isClosed .Load () {
18901890 if err = srtpReadStream .Close (); err != nil {
18911891 pc .log .Warnf ("Failed to close RTP stream %v" , err )
18921892 }
@@ -2076,7 +2076,7 @@ func (pc *PeerConnection) GetTransceivers() []*RTPTransceiver {
20762076//
20772077//nolint:cyclop
20782078func (pc * PeerConnection ) AddTrack (track TrackLocal ) (* RTPSender , error ) {
2079- if pc .isClosed .get () {
2079+ if pc .isClosed .Load () {
20802080 return nil , & rtcerr.InvalidStateError {Err : ErrConnectionClosed }
20812081 }
20822082
@@ -2118,7 +2118,7 @@ func (pc *PeerConnection) AddTrack(track TrackLocal) (*RTPSender, error) {
21182118
21192119// RemoveTrack removes a Track from the PeerConnection.
21202120func (pc * PeerConnection ) RemoveTrack (sender * RTPSender ) (err error ) {
2121- if pc .isClosed .get () {
2121+ if pc .isClosed .Load () {
21222122 return & rtcerr.InvalidStateError {Err : ErrConnectionClosed }
21232123 }
21242124
@@ -2186,7 +2186,7 @@ func (pc *PeerConnection) AddTransceiverFromKind(
21862186 kind RTPCodecType ,
21872187 init ... RTPTransceiverInit ,
21882188) (t * RTPTransceiver , err error ) {
2189- if pc .isClosed .get () {
2189+ if pc .isClosed .Load () {
21902190 return nil , & rtcerr.InvalidStateError {Err : ErrConnectionClosed }
21912191 }
21922192
@@ -2231,7 +2231,7 @@ func (pc *PeerConnection) AddTransceiverFromTrack(
22312231 track TrackLocal ,
22322232 init ... RTPTransceiverInit ,
22332233) (t * RTPTransceiver , err error ) {
2234- if pc .isClosed .get () {
2234+ if pc .isClosed .Load () {
22352235 return nil , & rtcerr.InvalidStateError {Err : ErrConnectionClosed }
22362236 }
22372237
@@ -2259,7 +2259,7 @@ func (pc *PeerConnection) AddTransceiverFromTrack(
22592259//nolint:cyclop
22602260func (pc * PeerConnection ) CreateDataChannel (label string , options * DataChannelInit ) (* DataChannel , error ) {
22612261 // https://w3c.github.io/webrtc-pc/#peer-to-peer-data-api (Step #2)
2262- if pc .isClosed .get () {
2262+ if pc .isClosed .Load () {
22632263 return nil , & rtcerr.InvalidStateError {Err : ErrConnectionClosed }
22642264 }
22652265
@@ -2380,7 +2380,7 @@ func (pc *PeerConnection) close(shouldGracefullyClose bool) error { //nolint:cyc
23802380 // some overlapping close cases when both normal and graceful close are used
23812381 // that should be idempotent, but be cautioned when writing new close behavior
23822382 // to preserve this property.
2383- isAlreadyClosingOrClosed := pc .isClosed .swap (true )
2383+ isAlreadyClosingOrClosed := pc .isClosed .Swap (true )
23842384 isAlreadyGracefullyClosingOrClosed := pc .isGracefullyClosingOrClosed
23852385 if shouldGracefullyClose && ! isAlreadyGracefullyClosingOrClosed {
23862386 pc .isGracefullyClosingOrClosed = true
@@ -2668,7 +2668,7 @@ func (pc *PeerConnection) startTransports(
26682668 }
26692669
26702670 pc .dtlsTransport .internalOnCloseHandler = func () {
2671- if pc .isClosed .get () || pc .api .settingEngine .disableCloseByDTLS {
2671+ if pc .isClosed .Load () || pc .api .settingEngine .disableCloseByDTLS {
26722672 return
26732673 }
26742674
0 commit comments