处理崩溃
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user