typedef struct _MIDI_INFO { ULONG Key; #define MIDI_INFO_KEY (*(ULONG *)"Midi") KSPIN_LOCK DeviceSpinLock; #if DBG BOOLEAN LockHeld; #endif LARGE_INTEGER RefTime; LIST_ENTRY QueueHead; PVOID HwContext; PMIDI_INTERFACE_ROUTINE HwStartMidiIn, HwStopMidiIn; BOOLEAN (* HwMidiRead)(struct _MIDI_INFO *, PUCHAR); VOID (* HwMidiOut)(struct _MIDI_INFO *, PUCHAR, int); BOOLEAN fMidiInStarted; UCHAR InputPosition; UCHAR InputBytes; UCHAR MidiInputByte[64]; } MIDI_INFO, *PMIDI_INFO;
The MIDI_INFO structure contains context information for an external MIDI device.
The function is called when SoundMIDIDispatch
receives a IOCTL_MIDI_SET_STATE command. See \src\mmedia\soundlib\midi.c.
The function is called when SoundMIDIDispatch
receives a IRP_MJ_CLEANUP command. For more information, see \src\mmedia\soundlib\midi.c.
BOOLEAN (* HwMidiRead)(struct _MIDI_INFO *, PUCHAR)
The _MIDI_INFO* parameter points to a MIDI_INFO structure and the PUCHAR parameter receives the read byte. The function returns TRUE if a byte was read, and FALSE otherwise.
The function is called when SoundMIDIDispatch receives a IRP_MJ_READ command. For more information, see \src\mmedia\soundlib\midi.c.
This function executes at an IRQL of DISPATCH_LEVEL, so it cannot be pageable
and it cannot reference pageable code or data. Also, the only synchronization
method it can use is calling KeStallExecutionProcessor.
VOID (* HwMidiOut)(struct _MIDI_INFO *, PUCHAR, int)
The first parameter points to a MIDI_INFO structure, the second parameter points to a mapped buffer of bytes, and the third parameter contains the buffer size.
The function is called when SoundMIDIDispatch
receives a IOCTL_MIDI_PLAY command. For more information, see \src\mmedia\soundlib\midi.c.
A single MIDI_INFO structure can be used to support simultaneous MIDI input and output. MIDI_INFO is defined in midi.h.
Allocate a MIDI_INFO structure from the nonpaged memory pool by calling ExAllocatePool, then zero it by calling RtlZeroMemory. To initialize a MIDI_INFO structure, call SoundInitMidiIn.
To create a MIDI device object, call SoundCreateDevice and specify a MIDI_INFO structure pointer for the DeviceSpecificData parameter.