Closed simonhaines closed 2 years ago
Hi @simonhaines , I just ran into this issue myself. I have pushed a fix. Please be aware that your fork is missing the same fix for the stream finished callback. Wish I had the time / energy to do PortAudio.Net justice, maybe someday :)
Thanks @Kyle-Gagner I know what you mean regarding time/energy. I'm not sure how I missed that stream finished callback as well, but I'll switch to your branch and remove the callback-bugfix
branch in my fork.
Hi Kyle, thanks for making this library. I particularly like the PaBuffer implementation for managing native buffers.
One small issue is that passing the
Callback
method of theStreamCallbackContainer
in the call toOpenStream
creates a new delegate which is then subject to garbage collection. My fix for this is to pre-allocate the delegate in theStreamCallbackContainer
constructor ensuring it has the same lifetime. Other solutions may include usingMarshal.GetFunctionPointerForDelegate
, but this is simple and it works.I have committed my fix to the
callback-bugfix
branch of my fork here and am happy to submit a pull request if you like.