/// <summary> /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources. /// </summary> public void Dispose() { using (_writer) Flush(); _encoder?.Dispose(); }
public void stop() { if (!running) { return; } running = false; if (audioRecorder != null) { try { audioRecorder.StopRecording(); } catch (Exception) { } audioRecorder.Dispose(); audioRecorder = null; } if (audioEncoder != null) { audioEncoder.stop(); audioEncoder.Dispose(); audioEncoder = null; } lock (outputBuffers) { outputBuffers.Clear(); } }
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(); } }
/// <summary> /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources. /// </summary> public void Dispose() { _audioProvider.Dispose(); _audioEncoder.Dispose(); }
public void stop() { if (!running) { return; } running = false; if (echoCanceller != null) { try { echoCanceller.Release(); echoCanceller.Dispose(); } catch (Exception) { } echoCanceller = null; } if (noiseSuppressor != null) { try { noiseSuppressor.Release(); noiseSuppressor.Dispose(); } catch (Exception) { } noiseSuppressor = null; } if (audioRecorder != null) { try { audioRecorder.Stop(); audioRecorder.Release(); } catch (Exception) { } audioRecorder.Dispose(); audioRecorder = null; } if (audioEncoder != null) { audioEncoder.stop(); audioEncoder.Dispose(); audioEncoder = null; } buffer = null; shortsBuffer = null; bufferSize = 0; lock (outputBuffers) { outputBuffers.Clear(); } AudioManager am = (AudioManager)MainActivity.Instance.GetSystemService(Context.AudioService); if (Build.VERSION.SdkInt < BuildVersionCodes.O) { if (focusListener != null) { #pragma warning disable CS0618 // Type or member is obsolete am.AbandonAudioFocus(focusListener); #pragma warning restore CS0618 // Type or member is obsolete focusListener.Dispose(); focusListener = null; } } else { if (focusListener != null) { if (focusRequest != null) { am.AbandonAudioFocusRequest(focusRequest); focusRequest.Dispose(); focusRequest = null; } focusListener.Dispose(); focusListener = null; } } }