public PortAudioInputStream(int numInputChannels, PaSampleFormat sampleFormat, double sampleRate, uint framesPerBuffer, StreamCallback streamCallback, IntPtr userData) : base(sampleFormat, numInputChannels) { HandleError(PortAudioInterop.Pa_OpenDefaultStream( out handle, numInputChannels, 0, (IntPtr)sampleFormat, sampleRate, (IntPtr)framesPerBuffer, ToPaStreamCallback(streamCallback, false), userData )); }
public PortAudioOutputStream(int numOutputChannels, PaSampleFormat sampleFormat, double sampleRate, uint framesPerBuffer, StreamCallback streamCallback, object userData) : base(sampleFormat, numOutputChannels) { var gch = userData == null ? default(GCHandle) : GCHandle.Alloc(userData, GCHandleType.Pinned); try { HandleError(PortAudioInterop.Pa_OpenDefaultStream( out handle, 0, numOutputChannels, (IntPtr)sampleFormat, sampleRate, (IntPtr)framesPerBuffer, ToPaStreamCallback(streamCallback, true), userData != null ? gch.AddrOfPinnedObject() : IntPtr.Zero)); } finally { if (userData != null) { gch.Free(); } } }