Commit 27bda12c authored by Huw Davies's avatar Huw Davies Committed by Alexandre Julliard

winecoreaudio: Move midi_in_add_buffer to the unixlib.

parent 9eeee3dd
......@@ -809,6 +809,49 @@ static DWORD midi_in_close(WORD dev_id, struct notify_context *notify)
return MMSYSERR_NOERROR;
}
static DWORD midi_in_add_buffer(WORD dev_id, MIDIHDR *hdr, DWORD hdr_size)
{
MIDIHDR **next;
TRACE("dev_id = %d hdr = %p hdr_size = %d\n", dev_id, hdr, hdr_size);
if (dev_id >= num_srcs)
{
WARN("bad device ID : %d\n", dev_id);
return MMSYSERR_BADDEVICEID;
}
if (!hdr || hdr_size < offsetof(MIDIHDR, dwOffset) || !hdr->dwBufferLength)
{
WARN("Invalid Parameter\n");
return MMSYSERR_INVALPARAM;
}
if (hdr->dwFlags & MHDR_INQUEUE)
{
WARN("Still playing\n");
return MIDIERR_STILLPLAYING;
}
if (!(hdr->dwFlags & MHDR_PREPARED))
{
WARN("Unprepared\n");
return MIDIERR_UNPREPARED;
}
hdr->dwFlags &= ~WHDR_DONE;
hdr->dwFlags |= MHDR_INQUEUE;
hdr->dwBytesRecorded = 0;
hdr->lpNext = NULL;
midi_in_lock((void *)TRUE);
next = &srcs[dev_id].lpQueueHdr;
while (*next) next = &(*next)->lpNext;
*next = hdr;
midi_in_lock((void *)FALSE);
return MMSYSERR_NOERROR;
}
static DWORD midi_in_prepare(WORD dev_id, MIDIHDR *hdr, DWORD hdr_size)
{
TRACE("dev_id = %d hdr = %p hdr_size = %d\n", dev_id, hdr, hdr_size);
......@@ -966,6 +1009,9 @@ NTSTATUS midi_in_message(void *args)
case MIDM_CLOSE:
*params->err = midi_in_close(params->dev_id, params->notify);
break;
case MIDM_ADDBUFFER:
*params->err = midi_in_add_buffer(params->dev_id, (MIDIHDR *)params->param_1, params->param_2);
break;
case MIDM_PREPARE:
*params->err = midi_in_prepare(params->dev_id, (MIDIHDR *)params->param_1, params->param_2);
break;
......
......@@ -142,54 +142,6 @@ static void midi_lock( BOOL lock )
UNIX_CALL(midi_in_lock, (void *)lock);
}
static DWORD MIDIIn_AddBuffer(WORD wDevID, LPMIDIHDR lpMidiHdr, DWORD dwSize)
{
TRACE("wDevID=%d lpMidiHdr=%p dwSize=%d\n", wDevID, lpMidiHdr, dwSize);
if (wDevID >= MIDIIn_NumDevs) {
WARN("bad device ID : %d\n", wDevID);
return MMSYSERR_BADDEVICEID;
}
if (lpMidiHdr == NULL) {
WARN("Invalid Parameter\n");
return MMSYSERR_INVALPARAM;
}
if (dwSize < offsetof(MIDIHDR,dwOffset)) {
WARN("Invalid Parameter\n");
return MMSYSERR_INVALPARAM;
}
if (lpMidiHdr->dwBufferLength == 0) {
WARN("Invalid Parameter\n");
return MMSYSERR_INVALPARAM;
}
if (lpMidiHdr->dwFlags & MHDR_INQUEUE) {
WARN("Still playing\n");
return MIDIERR_STILLPLAYING;
}
if (!(lpMidiHdr->dwFlags & MHDR_PREPARED)) {
WARN("Unprepared\n");
return MIDIERR_UNPREPARED;
}
midi_lock( TRUE );
lpMidiHdr->dwFlags &= ~WHDR_DONE;
lpMidiHdr->dwFlags |= MHDR_INQUEUE;
lpMidiHdr->dwBytesRecorded = 0;
lpMidiHdr->lpNext = 0;
if (sources[wDevID].lpQueueHdr == 0) {
sources[wDevID].lpQueueHdr = lpMidiHdr;
} else {
LPMIDIHDR ptr;
for (ptr = sources[wDevID].lpQueueHdr;
ptr->lpNext != 0;
ptr = ptr->lpNext);
ptr->lpNext = lpMidiHdr;
}
midi_lock( FALSE );
return MMSYSERR_NOERROR;
}
static DWORD MIDIIn_Reset(WORD wDevID)
{
DWORD dwTime = GetTickCount();
......@@ -384,8 +336,6 @@ DWORD WINAPI CoreAudio_midMessage(UINT wDevID, UINT wMsg, DWORD_PTR dwUser, DWOR
TRACE("%d %08x %08lx %08lx %08lx\n", wDevID, wMsg, dwUser, dwParam1, dwParam2);
switch (wMsg) {
case MIDM_ADDBUFFER:
return MIDIIn_AddBuffer(wDevID, (LPMIDIHDR)dwParam1, dwParam2);
case MIDM_RESET:
return MIDIIn_Reset(wDevID);
}
......
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