winealsa: Move MODM_CLOSE 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:
Huw Davies 2022-03-15 16:19:03 +00:00 committed by Alexandre Julliard
parent 7ff6c8738b
commit 30c18bdfd4
2 changed files with 57 additions and 47 deletions

View File

@ -471,6 +471,60 @@ static UINT midi_out_open(WORD dev_id, MIDIOPENDESC *midi_desc, UINT flags, stru
return MMSYSERR_NOERROR;
}
static UINT midi_out_close(WORD dev_id, struct notify_context *notify)
{
struct midi_dest *dest;
TRACE("(%04X);\n", dev_id);
if (dev_id >= num_dests)
{
WARN("bad device ID : %d\n", dev_id);
return MMSYSERR_BADDEVICEID;
}
dest = dests + dev_id;
if (dest->midiDesc.hMidi == 0)
{
WARN("device not opened !\n");
return MMSYSERR_ERROR;
}
/* FIXME: should test that no pending buffer is still in the queue for
* playing */
if (dest->seq == NULL)
{
WARN("can't close !\n");
return MMSYSERR_ERROR;
}
switch (dest->caps.wTechnology)
{
case MOD_FMSYNTH:
case MOD_MIDIPORT:
case MOD_SYNTH:
seq_lock();
TRACE("Deleting port :%d, connected to %d:%d\n", dest->port_out, dest->addr.client, dest->addr.port);
snd_seq_delete_simple_port(dest->seq, dest->port_out);
dest->port_out = -1;
seq_unlock();
seq_close();
dest->seq = NULL;
break;
default:
WARN("Technology not supported (yet) %d !\n", dest->caps.wTechnology);
return MMSYSERR_NOTENABLED;
}
set_out_notify(notify, dest, dev_id, MOM_CLOSE, 0, 0);
dest->midiDesc.hMidi = 0;
return MMSYSERR_NOERROR;
}
NTSTATUS midi_out_message(void *args)
{
struct midi_out_message_params *params = args;
@ -488,6 +542,9 @@ NTSTATUS midi_out_message(void *args)
case MODM_OPEN:
*params->err = midi_out_open(params->dev_id, (MIDIOPENDESC *)params->param_1, params->param_2, params->notify);
break;
case MODM_CLOSE:
*params->err = midi_out_close(params->dev_id, params->notify);
break;
default:
TRACE("Unsupported message\n");
*params->err = MMSYSERR_NOTSUPPORTED;

View File

@ -122,7 +122,6 @@ static void MIDI_NotifyClient(UINT wDevID, WORD wMsg,
wDevID, wMsg, dwParam1, dwParam2);
switch (wMsg) {
case MOM_CLOSE:
case MOM_DONE:
case MOM_POSITIONCB:
if (wDevID > MODM_NumDevs) return;
@ -631,50 +630,6 @@ static DWORD modGetDevCaps(WORD wDevID, LPMIDIOUTCAPSW lpCaps, DWORD dwSize)
return MMSYSERR_NOERROR;
}
/**************************************************************************
* modClose [internal]
*/
static DWORD modClose(WORD wDevID)
{
int ret = MMSYSERR_NOERROR;
TRACE("(%04X);\n", wDevID);
if (MidiOutDev[wDevID].midiDesc.hMidi == 0) {
WARN("device not opened !\n");
return MMSYSERR_ERROR;
}
/* FIXME: should test that no pending buffer is still in the queue for
* playing */
if (MidiOutDev[wDevID].seq == NULL) {
WARN("can't close !\n");
return MMSYSERR_ERROR;
}
switch (MidiOutDev[wDevID].caps.wTechnology) {
case MOD_FMSYNTH:
case MOD_MIDIPORT:
case MOD_SYNTH:
seq_lock();
TRACE("Deleting port :%d, connected to %d:%d\n", MidiOutDev[wDevID].port_out, MidiOutDev[wDevID].addr.client, MidiOutDev[wDevID].addr.port);
snd_seq_delete_simple_port(MidiOutDev[wDevID].seq, MidiOutDev[wDevID].port_out);
MidiOutDev[wDevID].port_out = -1;
seq_unlock();
midiCloseSeq();
MidiOutDev[wDevID].seq = NULL;
break;
default:
WARN("Technology not supported (yet) %d !\n",
MidiOutDev[wDevID].caps.wTechnology);
return MMSYSERR_NOTENABLED;
}
MIDI_NotifyClient(wDevID, MOM_CLOSE, 0L, 0L);
MidiOutDev[wDevID].midiDesc.hMidi = 0;
return ret;
}
/**************************************************************************
* modData [internal]
*/
@ -1051,8 +1006,6 @@ DWORD WINAPI ALSA_modMessage(UINT wDevID, UINT wMsg, DWORD_PTR dwUser,
case DRVM_INIT:
ALSA_MidiInit();
return 0;
case MODM_CLOSE:
return modClose(wDevID);
case MODM_DATA:
return modData(wDevID, dwParam1);
case MODM_LONGDATA: