winealsa: Move MIDM_ADDBUFFER 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
5f5aa24847
commit
a9fab273a1
|
@ -852,6 +852,38 @@ static UINT midi_out_reset(WORD dev_id)
|
|||
return MMSYSERR_NOERROR;
|
||||
}
|
||||
|
||||
static UINT midi_in_add_buffer(WORD dev_id, MIDIHDR *hdr, UINT hdr_size)
|
||||
{
|
||||
struct midi_src *src;
|
||||
MIDIHDR **next;
|
||||
|
||||
TRACE("(%04X, %p, %d);\n", dev_id, hdr, hdr_size);
|
||||
|
||||
if (dev_id >= num_srcs) return MMSYSERR_BADDEVICEID;
|
||||
src = srcs + dev_id;
|
||||
if (src->state == -1) return MIDIERR_NODEVICE;
|
||||
|
||||
if (!hdr || hdr_size < offsetof(MIDIHDR, dwOffset) || !hdr->dwBufferLength)
|
||||
return MMSYSERR_INVALPARAM;
|
||||
if (hdr->dwFlags & MHDR_INQUEUE) return MIDIERR_STILLPLAYING;
|
||||
if (!(hdr->dwFlags & MHDR_PREPARED)) return MIDIERR_UNPREPARED;
|
||||
|
||||
in_buffer_lock();
|
||||
|
||||
hdr->dwFlags &= ~WHDR_DONE;
|
||||
hdr->dwFlags |= MHDR_INQUEUE;
|
||||
hdr->dwBytesRecorded = 0;
|
||||
hdr->lpNext = NULL;
|
||||
|
||||
next = &src->lpQueueHdr;
|
||||
while (*next) next = &(*next)->lpNext;
|
||||
*next = hdr;
|
||||
|
||||
in_buffer_unlock();
|
||||
|
||||
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);
|
||||
|
@ -963,6 +995,9 @@ NTSTATUS midi_in_message(void *args)
|
|||
/* FIXME: Pretend this is supported */
|
||||
*params->err = MMSYSERR_NOERROR;
|
||||
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;
|
||||
|
|
|
@ -459,42 +459,6 @@ static DWORD midClose(WORD wDevID)
|
|||
return ret;
|
||||
}
|
||||
|
||||
|
||||
/**************************************************************************
|
||||
* midAddBuffer [internal]
|
||||
*/
|
||||
static DWORD midAddBuffer(WORD wDevID, LPMIDIHDR lpMidiHdr, DWORD dwSize)
|
||||
{
|
||||
TRACE("(%04X, %p, %d);\n", wDevID, lpMidiHdr, dwSize);
|
||||
|
||||
if (wDevID >= MIDM_NumDevs) return MMSYSERR_BADDEVICEID;
|
||||
if (MidiInDev[wDevID].state == -1) return MIDIERR_NODEVICE;
|
||||
|
||||
if (lpMidiHdr == NULL) return MMSYSERR_INVALPARAM;
|
||||
if (dwSize < offsetof(MIDIHDR,dwOffset)) return MMSYSERR_INVALPARAM;
|
||||
if (lpMidiHdr->dwBufferLength == 0) return MMSYSERR_INVALPARAM;
|
||||
if (lpMidiHdr->dwFlags & MHDR_INQUEUE) return MIDIERR_STILLPLAYING;
|
||||
if (!(lpMidiHdr->dwFlags & MHDR_PREPARED)) return MIDIERR_UNPREPARED;
|
||||
|
||||
in_buffer_lock();
|
||||
lpMidiHdr->dwFlags &= ~WHDR_DONE;
|
||||
lpMidiHdr->dwFlags |= MHDR_INQUEUE;
|
||||
lpMidiHdr->dwBytesRecorded = 0;
|
||||
lpMidiHdr->lpNext = 0;
|
||||
if (MidiInDev[wDevID].lpQueueHdr == 0) {
|
||||
MidiInDev[wDevID].lpQueueHdr = lpMidiHdr;
|
||||
} else {
|
||||
LPMIDIHDR ptr;
|
||||
|
||||
for (ptr = MidiInDev[wDevID].lpQueueHdr; ptr->lpNext != 0;
|
||||
ptr = ptr->lpNext);
|
||||
ptr->lpNext = lpMidiHdr;
|
||||
}
|
||||
in_buffer_unlock();
|
||||
|
||||
return MMSYSERR_NOERROR;
|
||||
}
|
||||
|
||||
/**************************************************************************
|
||||
* midReset [internal]
|
||||
*/
|
||||
|
@ -593,8 +557,6 @@ DWORD WINAPI ALSA_midMessage(UINT wDevID, UINT wMsg, DWORD_PTR dwUser,
|
|||
return midOpen(wDevID, (LPMIDIOPENDESC)dwParam1, dwParam2);
|
||||
case MIDM_CLOSE:
|
||||
return midClose(wDevID);
|
||||
case MIDM_ADDBUFFER:
|
||||
return midAddBuffer(wDevID, (LPMIDIHDR)dwParam1, dwParam2);
|
||||
case MIDM_RESET:
|
||||
return midReset(wDevID);
|
||||
case MIDM_START:
|
||||
|
|
Loading…
Reference in New Issue