winecoreaudio: Move midi_out_data to the unixlib.
Signed-off-by: Huw Davies <huw@codeweavers.com> Signed-off-by: Andrew Eikum <aeikum@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
bf502e3685
commit
1a1ef23079
|
@ -463,6 +463,52 @@ static DWORD midi_out_close(WORD dev_id, struct notify_context *notify)
|
|||
return MMSYSERR_NOERROR;
|
||||
}
|
||||
|
||||
static void midi_send(MIDIPortRef port, MIDIEndpointRef dest, UInt8 *buffer, unsigned len)
|
||||
{
|
||||
Byte packet_buf[512];
|
||||
MIDIPacketList *packet_list = (MIDIPacketList *)packet_buf;
|
||||
MIDIPacket *packet = MIDIPacketListInit(packet_list);
|
||||
|
||||
packet = MIDIPacketListAdd(packet_list, sizeof(packet_buf), packet, mach_absolute_time(), len, buffer);
|
||||
if (packet) MIDISend(port, dest, packet_list);
|
||||
}
|
||||
|
||||
static DWORD midi_out_data(WORD dev_id, DWORD data)
|
||||
{
|
||||
struct midi_dest *dest;
|
||||
UInt8 bytes[3];
|
||||
OSStatus sc;
|
||||
|
||||
TRACE("dev_id = %d data = %08x\n", dev_id, data);
|
||||
|
||||
if (dev_id >= num_dests)
|
||||
{
|
||||
WARN("bad device ID : %d\n", dev_id);
|
||||
return MMSYSERR_BADDEVICEID;
|
||||
}
|
||||
|
||||
bytes[0] = data & 0xff;
|
||||
bytes[1] = (data >> 8) & 0xff;
|
||||
bytes[2] = (data >> 16) & 0xff;
|
||||
|
||||
dest = dests + dev_id;
|
||||
if (dest->caps.wTechnology == MOD_SYNTH)
|
||||
{
|
||||
sc = MusicDeviceMIDIEvent(dest->synth, bytes[0], bytes[1], bytes[2], 0);
|
||||
if (sc != noErr)
|
||||
{
|
||||
ERR("MusicDeviceMIDIEvent returns %s\n", wine_dbgstr_fourcc(sc));
|
||||
return MMSYSERR_ERROR;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
midi_send(midi_out_port, dest->dest, bytes, sizeof(bytes));
|
||||
}
|
||||
|
||||
return MMSYSERR_NOERROR;
|
||||
}
|
||||
|
||||
NTSTATUS midi_out_message(void *args)
|
||||
{
|
||||
struct midi_out_message_params *params = args;
|
||||
|
@ -483,6 +529,9 @@ NTSTATUS midi_out_message(void *args)
|
|||
case MODM_CLOSE:
|
||||
*params->err = midi_out_close(params->dev_id, params->notify);
|
||||
break;
|
||||
case MODM_DATA:
|
||||
*params->err = midi_out_data(params->dev_id, params->param_1);
|
||||
break;
|
||||
default:
|
||||
TRACE("Unsupported message\n");
|
||||
*params->err = MMSYSERR_NOTSUPPORTED;
|
||||
|
|
|
@ -163,44 +163,6 @@ static void MIDI_NotifyClient(UINT wDevID, WORD wMsg, DWORD_PTR dwParam1, DWORD_
|
|||
DriverCallback(dwCallBack, uFlags, hDev, wMsg, dwInstance, dwParam1, dwParam2);
|
||||
}
|
||||
|
||||
static DWORD MIDIOut_Data(WORD wDevID, DWORD dwParam)
|
||||
{
|
||||
WORD evt = LOBYTE(LOWORD(dwParam));
|
||||
UInt8 chn = (evt & 0x0F);
|
||||
|
||||
TRACE("wDevID=%d dwParam=%08X\n", wDevID, dwParam);
|
||||
|
||||
if (wDevID >= MIDIOut_NumDevs) {
|
||||
WARN("bad device ID : %d\n", wDevID);
|
||||
return MMSYSERR_BADDEVICEID;
|
||||
}
|
||||
|
||||
if (destinations[wDevID].caps.wTechnology == MOD_SYNTH)
|
||||
{
|
||||
WORD d1 = HIBYTE(LOWORD(dwParam));
|
||||
WORD d2 = LOBYTE(HIWORD(dwParam));
|
||||
OSStatus err = noErr;
|
||||
|
||||
err = MusicDeviceMIDIEvent(destinations[wDevID].synth, (evt & 0xF0) | chn, d1, d2, 0);
|
||||
if (err != noErr)
|
||||
{
|
||||
ERR("MusicDeviceMIDIEvent(%p, %04x, %04x, %04x, %d) return %s\n", destinations[wDevID].synth, (evt & 0xF0) | chn, d1, d2, 0, wine_dbgstr_fourcc(err));
|
||||
return MMSYSERR_ERROR;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
UInt8 buffer[3];
|
||||
buffer[0] = (evt & 0xF0) | chn;
|
||||
buffer[1] = HIBYTE(LOWORD(dwParam));
|
||||
buffer[2] = LOBYTE(HIWORD(dwParam));
|
||||
|
||||
MIDIOut_Send(MIDIOutPort, destinations[wDevID].dest, buffer, 3);
|
||||
}
|
||||
|
||||
return MMSYSERR_NOERROR;
|
||||
}
|
||||
|
||||
static DWORD MIDIOut_LongData(WORD wDevID, LPMIDIHDR lpMidiHdr, DWORD dwSize)
|
||||
{
|
||||
LPBYTE lpData;
|
||||
|
@ -763,8 +725,6 @@ DWORD WINAPI CoreAudio_modMessage(UINT wDevID, UINT wMsg, DWORD_PTR dwUser, DWOR
|
|||
TRACE("%d %08x %08lx %08lx %08lx\n", wDevID, wMsg, dwUser, dwParam1, dwParam2);
|
||||
|
||||
switch (wMsg) {
|
||||
case MODM_DATA:
|
||||
return MIDIOut_Data(wDevID, dwParam1);
|
||||
case MODM_LONGDATA:
|
||||
return MIDIOut_LongData(wDevID, (LPMIDIHDR)dwParam1, dwParam2);
|
||||
case MODM_PREPARE:
|
||||
|
|
Loading…
Reference in New Issue