[Media_api] Using PortMIDI in C# (.NET 2.0)
Roger Dannenberg
rbd+ at cs.cmu.edu
Sun Sep 24 11:45:58 PDT 2006
I don't know much about C#, but here are some thoughts:
The ONLY purpose of the pm_dll DLL is to attempt to close open MIDI
input ports when the program exits. (DLL's get control when a program
exits normally, where "normal" includes calling exit() and typing
control-C, but "normal" does not include instruction-level traps such as
attempting to read data through a NULL pointer.)
You can eliminate this additional protection using a compile option so
that PortMidi will not need or initialize the DLL.
There might be other mechanisms in C# to install handlers for runtime
errors and exit clean-up. If so, it might be desirable to use them
instead of pm_dll.
If a program leaves a MIDI input port open under Win32, the operating
system is likely to crash (!), so this is a serious operating system
bug. The "correct" solution is for MS to fix the gaping hole in Win32
security, but meanwhile, anything we can do to protect the system is
worth some attention, hence the clumsy but often effective pm_dll.
-Roger
More information about the media_api
mailing list