处理崩溃

This commit is contained in:
2026-01-30 21:38:58 +08:00
parent cc82396195
commit d2f582b7f8
5 changed files with 71 additions and 64 deletions

View File

@@ -52,8 +52,9 @@ static NSString *const kDeepgramStreamingManagerErrorDomain =
_audioCapture = [[AudioCaptureManager alloc] init];
_audioCapture.delegate = self;
_client = [[DeepgramWebSocketClient alloc] init];
_client.delegate = self;
///
// _client = [[DeepgramWebSocketClient alloc] init];
// _client.delegate = self;
_serverURL = @"wss://api.deepgram.com/v1/listen";
_encoding = @"linear16";
@@ -81,7 +82,7 @@ static NSString *const kDeepgramStreamingManagerErrorDomain =
- (void)dealloc {
[self removeNotifications];
[self disconnect];
[self disconnectInternal];
}
- (void)start {
@@ -203,21 +204,25 @@ static NSString *const kDeepgramStreamingManagerErrorDomain =
- (void)disconnect {
dispatch_async(self.stateQueue, ^{
if (self.streaming) {
[self.audioCapture stopCapture];
self.streaming = NO;
}
[self.pendingFrames removeAllObjects];
self.pendingStart = NO;
self.keepConnection = NO;
self.shouldReconnectOnForeground = NO;
[self.client disableAudioSending];
[self stopKeepAlive];
[self.client disconnect];
[self.audioSession deactivateSession];
[self disconnectInternal];
});
}
- (void)disconnectInternal {
if (self.streaming) {
[self.audioCapture stopCapture];
self.streaming = NO;
}
[self.pendingFrames removeAllObjects];
self.pendingStart = NO;
self.keepConnection = NO;
self.shouldReconnectOnForeground = NO;
[self.client disableAudioSending];
[self stopKeepAlive];
[self.client disconnect];
[self.audioSession deactivateSession];
}
#pragma mark - AudioCaptureManagerDelegate
- (void)audioCaptureManagerDidOutputPCMFrame:(NSData *)pcmFrame {