浏览代码

fix(ios) fix deadlock when selecting audio device

In WebRTC M92 the RTCAudioSession lock changed from a recursive one to a regular
mutex one, so make sure we don't attempt to lock it  while already holding the
lock.
master
Saúl Ibarra Corretgé 4 年前
父节点
当前提交
a4d516ca86
共有 1 个文件被更改,包括 11 次插入4 次删除
  1. 11
    4
      ios/sdk/src/AudioMode.m

+ 11
- 4
ios/sdk/src/AudioMode.m 查看文件

125
     return _workerQueue;
125
     return _workerQueue;
126
 }
126
 }
127
 
127
 
128
+- (BOOL)setConfigWithoutLock:(RTCAudioSessionConfiguration *)config
129
+                       error:(NSError * _Nullable *)outError {
130
+    RTCAudioSession *session = [RTCAudioSession sharedInstance];
131
+
132
+    return [session setConfiguration:config error:outError];
133
+}
134
+
128
 - (BOOL)setConfig:(RTCAudioSessionConfiguration *)config
135
 - (BOOL)setConfig:(RTCAudioSessionConfiguration *)config
129
             error:(NSError * _Nullable *)outError {
136
             error:(NSError * _Nullable *)outError {
130
 
137
 
131
     RTCAudioSession *session = [RTCAudioSession sharedInstance];
138
     RTCAudioSession *session = [RTCAudioSession sharedInstance];
132
     [session lockForConfiguration];
139
     [session lockForConfiguration];
133
-    BOOL success = [session setConfiguration:config error:outError];
140
+    BOOL success = [self setConfigWithoutLock:config error:outError];
134
     [session unlockForConfiguration];
141
     [session unlockForConfiguration];
135
 
142
 
136
     return success;
143
     return success;
196
                 break;
203
                 break;
197
             }
204
             }
198
         }
205
         }
199
-        
206
+
200
         if (port != nil) {
207
         if (port != nil) {
201
             // First remove the override if we are going to select a different device.
208
             // First remove the override if we are going to select a different device.
202
             if (isSpeakerOn) {
209
             if (isSpeakerOn) {
206
             // Special case for the earpiece.
213
             // Special case for the earpiece.
207
             if ([port.portType isEqualToString:AVAudioSessionPortBuiltInMic]) {
214
             if ([port.portType isEqualToString:AVAudioSessionPortBuiltInMic]) {
208
                 forceEarpiece = YES;
215
                 forceEarpiece = YES;
209
-                [self setConfig:earpieceConfig error:nil];
216
+                [self setConfigWithoutLock:earpieceConfig error:nil];
210
             } else if (isEarpieceOn) {
217
             } else if (isEarpieceOn) {
211
                 // Reset the config.
218
                 // Reset the config.
212
                 RTCAudioSessionConfiguration *config = [self configForMode:activeMode];
219
                 RTCAudioSessionConfiguration *config = [self configForMode:activeMode];
213
-                [self setConfig:config error:nil];
220
+                [self setConfigWithoutLock:config error:nil];
214
             }
221
             }
215
 
222
 
216
             // Select our preferred input.
223
             // Select our preferred input.

正在加载...
取消
保存