public void stop() { if (!running) { return; } running = false; AVAudioSession.SharedInstance().SetActive(false); if (audioPlayer != null) { try { audioPlayer.Stop(); audioPlayer.Reset(); } catch (Exception) { } audioPlayer.Dispose(); audioPlayer = null; } if (audioDecoder != null) { audioDecoder.stop(); audioDecoder.Dispose(); audioDecoder = null; } if (audioEngine != null) { try { audioEngine.Stop(); audioEngine.Reset(); } catch (Exception) { } audioEngine.Dispose(); audioEngine = null; } }
public void stop() { if (!running) { return; } running = false; AVAudioSession.SharedInstance().SetActive(false); if (audioRecorder != null) { try { audioRecorder.InputNode.RemoveTapOnBus(0); audioRecorder.Stop(); audioRecorder.Reset(); } catch (Exception) { } audioRecorder.Dispose(); audioRecorder = null; } if (audioEncoder != null) { audioEncoder.stop(); audioEncoder.Dispose(); audioEncoder = null; } lock (outputBuffers) { outputBuffers.Clear(); } }