@@ -129,10 +129,10 @@ class RTCSession extends EventManager implements Owner {
129
129
String ? _tones;
130
130
131
131
// Mute/Hold state.
132
- bool ? _audioMuted;
133
- bool ? _videoMuted;
134
- bool ? _localHold;
135
- bool ? _remoteHold;
132
+ bool _audioMuted = false ;
133
+ bool _videoMuted = false ;
134
+ bool _localHold = false ;
135
+ bool _remoteHold = false ;
136
136
137
137
late RFC4028Timers _sessionTimers;
138
138
@@ -955,23 +955,22 @@ class RTCSession extends EventManager implements Owner {
955
955
*/
956
956
void mute ([bool audio = true , bool video = true ]) {
957
957
logger.d ('mute()' );
958
+ bool changed = false ;
958
959
959
- bool audioMuted = false , videoMuted = false ;
960
-
961
- if (_audioMuted == false && audio) {
962
- audioMuted = true ;
960
+ if (! _audioMuted && audio) {
963
961
_audioMuted = true ;
962
+ changed = true ;
964
963
_toggleMuteAudio (true );
965
964
}
966
965
967
- if (_videoMuted == false && video) {
968
- videoMuted = true ;
966
+ if (! _videoMuted && video) {
969
967
_videoMuted = true ;
968
+ changed = true ;
970
969
_toggleMuteVideo (true );
971
970
}
972
971
973
- if (audioMuted == true || videoMuted == true ) {
974
- _onmute (audioMuted, videoMuted );
972
+ if (changed ) {
973
+ _onmute (_audioMuted, _videoMuted );
975
974
}
976
975
}
977
976
@@ -980,29 +979,28 @@ class RTCSession extends EventManager implements Owner {
980
979
*/
981
980
void unmute ([bool audio = true , bool video = true ]) {
982
981
logger.d ('unmute()' );
983
-
984
- bool audioUnMuted = false , videoUnMuted = false ;
982
+ bool changed = false ;
985
983
986
984
if (_audioMuted == true && audio) {
987
- audioUnMuted = true ;
988
985
_audioMuted = false ;
989
986
990
987
if (_localHold == false ) {
988
+ changed = true ;
991
989
_toggleMuteAudio (false );
992
990
}
993
991
}
994
992
995
993
if (_videoMuted == true && video) {
996
- videoUnMuted = true ;
997
994
_videoMuted = false ;
998
995
999
996
if (_localHold == false ) {
997
+ changed = true ;
1000
998
_toggleMuteVideo (false );
1001
999
}
1002
1000
}
1003
1001
1004
- if (audioUnMuted == true || videoUnMuted == true ) {
1005
- _onunmute (audioUnMuted, videoUnMuted );
1002
+ if (changed ) {
1003
+ _onunmute (! _audioMuted, ! _videoMuted );
1006
1004
}
1007
1005
}
1008
1006
0 commit comments