MidiRegisterDriver is similar to MidiOpen except that the application is registered as a driver instead of a regular MidiShare client. At register time, a driver should give the necessary callbacks to be notified of the MidiShare wakeup and sleep transitions. Any registered driver must call the MidiUnregisterDriver function before leaving, by giving its reference number as an argument. MidiShare can thus be aware of the precise number of active Midi drivers. MidiShare applications owning a "context alarm" will be informed of the new driver using the MIDIOpenDriver alarm code
short MidiRegisterDriver (TDriverInfos * inf, TDriverOperation *op);
inf
- a pointer to a structure containing drivers information.
op
- a pointer to a structure containing the callbacks required to be notified of the MidiShare state changes.
typedef struct TDriverInfos { DriverName name; /* the driver name */ short version; /* its version number */ short slots; /* ignored at register time */ long reserved[2]; } TDriverInfos;Fields: see MidiGetDriverInfos
typedef struct TDriverOperation { void (* wakeup) (short refNum); void (* sleep) (short refNum); long reserved[3]; } TDriverOperation;Fields:
- wakeup : points to a function called by MidiShare at wakeup time.
- sleep : points to a function called by MidiShare at sleep time.
- reserved: reserved for future use. They should be set to zero.
The result is a unique reference number identifying the driver.
when registering, a driver should take care of the following: if MidiShare is running at register time, the driver 'wakeup' callback will be called before the MidiRegisterDriver function return. Therefore, a correct 'wakeup' callback implementation should not rely on code executed after the MidiRegisterDriver function.