private void CleanUpActiveStream() { if (recordingStream is not null) { //Clean up last effect recordingStream.StopRecording(); recordingStream.Dispose(); recordingStream = null; } if (fileRecordingStream is not null) { //Clean up last effect fileRecordingStream.StopRecording(); fileRecordingStream.Dispose(); fileRecordingStream = null; } if (outputDevice is not null) { outputDevice.Stop(); outputDevice.Dispose(); outputDevice = null; } }
protected virtual void Dispose(bool disposing) { if (!disposedValue) { if (disposing) { recordingStream?.Dispose(); recordingStream = null; fileRecordingStream?.Dispose(); fileRecordingStream = null; outputDevice?.Dispose(); outputDevice = null; targetOutputDevice?.Dispose(); targetOutputDevice = null; targetInputDevice?.Dispose(); targetInputDevice = null; } disposedValue = true; } }