Esempio n. 1
0
/*
 * fluid_midishare_open_driver
 */
static int fluid_midishare_open_driver (fluid_midishare_midi_driver_t* dev)
{
    /* gcc wanted me to use {0,0} to initialize the reserved[2] fields */
    TDriverInfos infos = { MSHDriverName, 100, 0, { 0, 0 } };
    TDriverOperation op = { fluid_midishare_wakeup, fluid_midishare_sleep, { 0, 0, 0 } };

    /* register to MidiShare */
#if defined(MACINTOSH) && defined(MACOS9)
    dev->upp_wakeup_ptr = NewDriverPtr(fluid_midishare_wakeup);
    dev->upp_sleep_ptr = NewDriverPtr(fluid_midishare_sleep);

    op.wakeup = (WakeupPtr)dev->upp_wakeup_ptr;
    op.sleep = (SleepPtr)dev->upp_sleep_ptr;

    dev->refnum = MidiRegisterDriver(&infos, &op);
    if (dev->refnum < 0) {
        FLUID_LOG(FLUID_ERR, "Can not open MidiShare Application client");
        return 0;
    }
    dev->slotRef = MidiAddSlot (dev->refnum, MSHSlotName, MidiOutputSlot);
    dev->upp_alarm_ptr = NewRcvAlarmPtr(fluid_midishare_midi_driver_receive);
    dev->upp_task_ptr = NewTaskPtr(fluid_midishare_keyoff_task);
    MidiSetRcvAlarm(dev->refnum, dev->upp_alarm_ptr);
#else
    dev->refnum = MidiRegisterDriver(&infos, &op);
    if (dev->refnum < 0) {
        FLUID_LOG(FLUID_ERR, "Can not open MidiShare Application client");
        return 0;
    }
    dev->slotRef = MidiAddSlot (dev->refnum, MSHSlotName, MidiOutputSlot);
    MidiSetRcvAlarm(dev->refnum, fluid_midishare_midi_driver_receive);
#endif
    return 1;
}
	void MidiInputDeviceMidiShare::OpenDriver()
	{
		/* gcc wanted me to use {0,0} to initialize the reserved[2] fields */
		TDriverInfos infos = { MSHDriverName, 100, 0, { 0, 0 } };
		TDriverOperation op = { WakeUp, Sleep, { 0, 0, 0 } }; 
		hRefnum = MidiRegisterDriver(&infos, &op);
		if (hRefnum < 0) {
			throw MidiInputException("MidiShare driver can not be opened");	
		}
		hSlotRef = MidiAddSlot(hRefnum,MSHSlotName,MidiOutputSlot);
		MidiSetRcvAlarm(hRefnum,ReceiveEvents);
	}