@@ -74,13 +74,6 @@ + (void)setSpeakerphoneOn:(BOOL)enable {
74
74
error: &error];
75
75
if (!success)
76
76
NSLog (@" Port override failed due to: %@ " , error);
77
-
78
- success = [session setActive: YES error: &error];
79
- if (!success)
80
- NSLog (@" Audio session override failed: %@ " , error);
81
- else
82
- NSLog (@" AudioSession override via Earpiece/Headset is successful " );
83
-
84
77
} else {
85
78
[session setMode: config.mode error: &error];
86
79
BOOL success = [session setCategory: config.category
@@ -94,12 +87,6 @@ + (void)setSpeakerphoneOn:(BOOL)enable {
94
87
error: &error];
95
88
if (!success)
96
89
NSLog (@" Port override failed due to: %@ " , error);
97
-
98
- success = [session setActive: YES error: &error];
99
- if (!success)
100
- NSLog (@" Audio session override failed: %@ " , error);
101
- else
102
- NSLog (@" AudioSession override via Loudspeaker is successful " );
103
90
}
104
91
[session unlockForConfiguration ];
105
92
}
@@ -108,11 +95,13 @@ + (void)deactiveRtcAudioSession {
108
95
NSError * error = nil ;
109
96
RTCAudioSession* session = [RTCAudioSession sharedInstance ];
110
97
[session lockForConfiguration ];
111
- BOOL success = [session setActive: NO error: &error];
112
- if (!success)
113
- NSLog (@" RTC Audio session deactive failed: %@ " , error);
114
- else
115
- NSLog (@" RTC AudioSession deactive is successful " );
98
+ if ([session isActive ]) {
99
+ BOOL success = [session setActive: NO error: &error];
100
+ if (!success)
101
+ NSLog (@" RTC Audio session deactive failed: %@ " , error);
102
+ else
103
+ NSLog (@" RTC AudioSession deactive is successful " );
104
+ }
116
105
[session unlockForConfiguration ];
117
106
}
118
107
0 commit comments