Quantcast
Channel: naudio Work Item Rss Feed
Viewing all articles
Browse latest Browse all 738

Commented Unassigned: Bug...pin the reference to the callback delegate [16495]

$
0
0
NAudio is a great library! Thanks for sharing it.
A bug fix for your review.

See \naudio_38dadb417edc\NAudio\Wave\MmeInterop\WaveCallbackInfo.cs line 75
My fix is to pin the delegate used by the WinMM callback...

private static WaveInterop.WaveCallback reference; // pin the reference to the callback delegate.
// the CG may choose to clean up the "pointer to the function" as no one is using it!
// except that WinMM is!

internal MmResult WaveOutOpen(out IntPtr waveOutHandle, int deviceNumber, WaveFormat waveFormat, WaveInterop.WaveCallback callback)
{
reference = callback;

if (reference == null)
throw new ApplicationException("callback is null");

MmResult result;
if (Strategy == WaveCallbackStrategy.FunctionCallback)
{
result = WaveInterop.waveOutOpen(out waveOutHandle, (IntPtr)deviceNumber, waveFormat, callback, IntPtr.Zero, WaveInterop.WaveInOutOpenFlags.CallbackFunction);
}
else
{
result = WaveInterop.waveOutOpenWindow(out waveOutHandle, (IntPtr)deviceNumber, waveFormat, this.Handle, IntPtr.Zero, WaveInterop.WaveInOutOpenFlags.CallbackWindow);
}
return result;
}
I'm using your library in a "busy" .NET C# SDR application.

Comments: thanks for reporting this. any reason you made it static? that would break if more than one output device was in use at once

Viewing all articles
Browse latest Browse all 738

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>