diff --git a/LFLiveKit/capture/LFAudioCapture.m b/LFLiveKit/capture/LFAudioCapture.m index f41ba840..ef9fbb59 100755 --- a/LFLiveKit/capture/LFAudioCapture.m +++ b/LFLiveKit/capture/LFAudioCapture.m @@ -100,6 +100,7 @@ - (void)dealloc { dispatch_sync(self.taskQueue, ^{ if (self.componetInstance) { + self.isRunning = NO; AudioOutputUnitStop(self.componetInstance); AudioComponentInstanceDispose(self.componetInstance); self.componetInstance = nil; @@ -120,7 +121,11 @@ - (void)setRunning:(BOOL)running { AudioOutputUnitStart(self.componetInstance); }); } else { - self.isRunning = NO; + dispatch_sync(self.taskQueue, ^{ + self.isRunning = NO; + NSLog(@"MicrophoneSource: stopRunning"); + AudioOutputUnitStop(self.componetInstance); + }); } } @@ -191,7 +196,7 @@ - (void)handleInterruption:(NSNotification *)notification { case AVAudioSessionInterruptionOptionShouldResume: if (self.isRunning) { dispatch_async(self.taskQueue, ^{ - NSLog(@"MicrophoneSource: stopRunning"); + NSLog(@"MicrophoneSource: startRunning"); AudioOutputUnitStart(self.componetInstance); }); } @@ -234,15 +239,6 @@ static OSStatus handleInputBuffer(void *inRefCon, inNumberFrames, &buffers); - if (!source.isRunning) { - dispatch_sync(source.taskQueue, ^{ - NSLog(@"MicrophoneSource: stopRunning"); - AudioOutputUnitStop(source.componetInstance); - }); - - return status; - } - if (source.muted) { for (int i = 0; i < buffers.mNumberBuffers; i++) { AudioBuffer ab = buffers.mBuffers[i];