Commit 85890a06 authored by Huw Davies's avatar Huw Davies Committed by Alexandre Julliard

winealsa: Move MIDM_PREPARE and MIDM_UNPREPARE to the unixlib.

parent be9a875f
......@@ -2446,6 +2446,7 @@ unixlib_entry_t __wine_unix_call_funcs[] =
get_prop_value,
midi_init,
midi_out_message,
midi_in_message,
midi_seq_lock, /* temporary */
midi_seq_open,
......
......@@ -833,6 +833,37 @@ static UINT midi_out_reset(WORD dev_id)
return MMSYSERR_NOERROR;
}
static UINT midi_in_prepare(WORD dev_id, MIDIHDR *hdr, UINT hdr_size)
{
TRACE("(%04X, %p, %d);\n", dev_id, hdr, hdr_size);
if (hdr_size < offsetof(MIDIHDR, dwOffset) || !hdr || !hdr->lpData)
return MMSYSERR_INVALPARAM;
if (hdr->dwFlags & MHDR_PREPARED)
return MMSYSERR_NOERROR;
hdr->lpNext = 0;
hdr->dwFlags |= MHDR_PREPARED;
hdr->dwFlags &= ~(MHDR_DONE | MHDR_INQUEUE);
return MMSYSERR_NOERROR;
}
static UINT midi_in_unprepare(WORD dev_id, MIDIHDR *hdr, UINT hdr_size)
{
TRACE("(%04X, %p, %d);\n", dev_id, hdr, hdr_size);
if (hdr_size < offsetof(MIDIHDR, dwOffset) || !hdr || !hdr->lpData)
return MMSYSERR_INVALPARAM;
if (!(hdr->dwFlags & MHDR_PREPARED))
return MMSYSERR_NOERROR;
if (hdr->dwFlags & MHDR_INQUEUE)
return MIDIERR_STILLPLAYING;
hdr->dwFlags &= ~MHDR_PREPARED;
return MMSYSERR_NOERROR;
}
NTSTATUS midi_out_message(void *args)
{
......@@ -888,3 +919,29 @@ NTSTATUS midi_out_message(void *args)
return STATUS_SUCCESS;
}
NTSTATUS midi_in_message(void *args)
{
struct midi_in_message_params *params = args;
switch (params->msg)
{
case DRVM_EXIT:
case DRVM_ENABLE:
case DRVM_DISABLE:
/* FIXME: Pretend this is supported */
*params->err = MMSYSERR_NOERROR;
break;
case MIDM_PREPARE:
*params->err = midi_in_prepare(params->dev_id, (MIDIHDR *)params->param_1, params->param_2);
break;
case MIDM_UNPREPARE:
*params->err = midi_in_unprepare(params->dev_id, (MIDIHDR *)params->param_1, params->param_2);
break;
default:
TRACE("Unsupported message\n");
*params->err = MMSYSERR_NOTSUPPORTED;
}
return STATUS_SUCCESS;
}
......@@ -511,44 +511,6 @@ static DWORD midAddBuffer(WORD wDevID, LPMIDIHDR lpMidiHdr, DWORD dwSize)
}
/**************************************************************************
* midPrepare [internal]
*/
static DWORD midPrepare(WORD wDevID, LPMIDIHDR lpMidiHdr, DWORD dwSize)
{
TRACE("(%04X, %p, %d);\n", wDevID, lpMidiHdr, dwSize);
if (dwSize < offsetof(MIDIHDR,dwOffset) || lpMidiHdr == 0 || lpMidiHdr->lpData == 0)
return MMSYSERR_INVALPARAM;
if (lpMidiHdr->dwFlags & MHDR_PREPARED)
return MMSYSERR_NOERROR;
lpMidiHdr->lpNext = 0;
lpMidiHdr->dwFlags |= MHDR_PREPARED;
lpMidiHdr->dwFlags &= ~(MHDR_DONE|MHDR_INQUEUE); /* flags cleared since w2k */
return MMSYSERR_NOERROR;
}
/**************************************************************************
* midUnprepare [internal]
*/
static DWORD midUnprepare(WORD wDevID, LPMIDIHDR lpMidiHdr, DWORD dwSize)
{
TRACE("(%04X, %p, %d);\n", wDevID, lpMidiHdr, dwSize);
if (dwSize < offsetof(MIDIHDR,dwOffset) || lpMidiHdr == 0 || lpMidiHdr->lpData == 0)
return MMSYSERR_INVALPARAM;
if (!(lpMidiHdr->dwFlags & MHDR_PREPARED))
return MMSYSERR_NOERROR;
if (lpMidiHdr->dwFlags & MHDR_INQUEUE)
return MIDIERR_STILLPLAYING;
lpMidiHdr->dwFlags &= ~MHDR_PREPARED;
return MMSYSERR_NOERROR;
}
/**************************************************************************
* midReset [internal]
*/
static DWORD midReset(WORD wDevID)
......@@ -633,27 +595,21 @@ static BOOL ALSA_MidiInit(void)
DWORD WINAPI ALSA_midMessage(UINT wDevID, UINT wMsg, DWORD_PTR dwUser,
DWORD_PTR dwParam1, DWORD_PTR dwParam2)
{
struct midi_in_message_params params;
UINT err;
TRACE("(%04X, %04X, %08lX, %08lX, %08lX);\n",
wDevID, wMsg, dwUser, dwParam1, dwParam2);
switch (wMsg) {
case DRVM_INIT:
ALSA_MidiInit();
return 0;
case DRVM_EXIT:
case DRVM_ENABLE:
case DRVM_DISABLE:
/* FIXME: Pretend this is supported */
return 0;
case MIDM_OPEN:
return midOpen(wDevID, (LPMIDIOPENDESC)dwParam1, dwParam2);
case MIDM_CLOSE:
return midClose(wDevID);
case MIDM_ADDBUFFER:
return midAddBuffer(wDevID, (LPMIDIHDR)dwParam1, dwParam2);
case MIDM_PREPARE:
return midPrepare(wDevID, (LPMIDIHDR)dwParam1, dwParam2);
case MIDM_UNPREPARE:
return midUnprepare(wDevID, (LPMIDIHDR)dwParam1, dwParam2);
case MIDM_GETDEVCAPS:
return midGetDevCaps(wDevID, (LPMIDIINCAPSW)dwParam1,dwParam2);
case MIDM_GETNUMDEVS:
......@@ -664,10 +620,18 @@ DWORD WINAPI ALSA_midMessage(UINT wDevID, UINT wMsg, DWORD_PTR dwUser,
return midStart(wDevID);
case MIDM_STOP:
return midStop(wDevID);
default:
TRACE("Unsupported message\n");
}
return MMSYSERR_NOTSUPPORTED;
params.dev_id = wDevID;
params.msg = wMsg;
params.user = dwUser;
params.param_1 = dwParam1;
params.param_2 = dwParam2;
params.err = &err;
ALSA_CALL(midi_in_message, &params);
return err;
}
/**************************************************************************
......
......@@ -254,6 +254,16 @@ struct midi_out_message_params
struct notify_context *notify;
};
struct midi_in_message_params
{
UINT dev_id;
UINT msg;
UINT_PTR user;
UINT_PTR param_1;
UINT_PTR param_2;
UINT *err;
};
struct midi_seq_open_params
{
int close;
......@@ -288,6 +298,7 @@ enum alsa_funcs
alsa_get_prop_value,
alsa_midi_init,
alsa_midi_out_message,
alsa_midi_in_message,
alsa_midi_seq_lock, /* temporary */
alsa_midi_seq_open,
......@@ -295,6 +306,7 @@ enum alsa_funcs
NTSTATUS midi_init(void *args) DECLSPEC_HIDDEN;
NTSTATUS midi_out_message(void *args) DECLSPEC_HIDDEN;
NTSTATUS midi_in_message(void *args) DECLSPEC_HIDDEN;
NTSTATUS midi_seq_lock(void *args) DECLSPEC_HIDDEN;
NTSTATUS midi_seq_open(void *args) DECLSPEC_HIDDEN;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment