Commit 6784845f authored by Huw Davies's avatar Huw Davies Committed by Alexandre Julliard

wineoss: Move MODM_RESET to the unixlib.

parent 03d2bddc
......@@ -64,13 +64,6 @@
WINE_DEFAULT_DEBUG_CHANNEL(midi);
static WINE_MIDIIN *MidiInDev;
static WINE_MIDIOUT *MidiOutDev;
/* this is the total number of MIDI out devices found (synth and port) */
static int MODM_NumDevs = 0;
/* this is the number of FM synthesizers (index from 0 to NUMFMSYNTHDEVS - 1) */
static int MODM_NumFMSynthDevs = 0;
/* the Midi ports have index from NUMFMSYNTHDEVS to NumDevs - 1 */
/* this is the total number of MIDI out devices found */
static int MIDM_NumDevs = 0;
......@@ -119,9 +112,6 @@ static LRESULT OSS_MidiInit(void)
if (!err)
{
MidiInDev = params.srcs;
MidiOutDev = params.dests;
MODM_NumDevs = params.num_dests;
MODM_NumFMSynthDevs = params.num_synths;
MIDM_NumDevs = params.num_srcs;
}
return err;
......@@ -140,10 +130,6 @@ static LRESULT OSS_MidiExit(void)
return 1;
MidiInDev = NULL;
MidiOutDev = NULL;
MODM_NumDevs = 0;
MODM_NumFMSynthDevs = 0;
MIDM_NumDevs = 0;
return 0;
......@@ -646,37 +632,6 @@ static DWORD midStop(WORD wDevID)
return MMSYSERR_NOERROR;
}
/*-----------------------------------------------------------------------*/
DWORD WINAPI OSS_modMessage(UINT wDevID, UINT wMsg, DWORD_PTR dwUser,
DWORD_PTR dwParam1, DWORD_PTR dwParam2);
/**************************************************************************
* modReset [internal]
*/
static DWORD modReset(WORD wDevID)
{
unsigned chn;
TRACE("(%04X);\n", wDevID);
if (wDevID >= MODM_NumDevs) return MMSYSERR_BADDEVICEID;
if (!MidiOutDev[wDevID].bEnabled) return MIDIERR_NODEVICE;
/* stop all notes */
/* FIXME: check if 0x78B0 is channel dependent or not. I coded it so that
* it's channel dependent...
*/
for (chn = 0; chn < 16; chn++) {
/* turn off every note */
OSS_modMessage(wDevID, MODM_DATA, 0, 0x7800 | MIDI_CTL_CHANGE | chn, 0);
/* remove sustain on all channels */
OSS_modMessage(wDevID, MODM_DATA, 0, (CTL_SUSTAIN << 8) | MIDI_CTL_CHANGE | chn, 0);
}
/* FIXME: the LongData buffers must also be returned to the app */
return MMSYSERR_NOERROR;
}
/*======================================================================*
* MIDI entry points *
*======================================================================*/
......@@ -742,8 +697,6 @@ DWORD WINAPI OSS_modMessage(UINT wDevID, UINT wMsg, DWORD_PTR dwUser,
return OSS_MidiInit();
case DRVM_EXIT:
return OSS_MidiExit();
case MODM_RESET:
return modReset(wDevID);
}
params.dev_id = wDevID;
......
......@@ -48,6 +48,17 @@
#include "unixlib.h"
struct midi_dest
{
BOOL bEnabled;
MIDIOPENDESC midiDesc;
WORD wFlags;
MIDIHDR *lpQueueHdr;
void *lpExtra; /* according to port type (MIDI, FM...), extra data when needed */
MIDIOUTCAPSW caps;
int fd;
};
static unsigned int num_dests, num_srcs, num_synths, seq_refs;
static struct midi_dest dests[MAX_MIDIOUTDRV];
static struct midi_src srcs[MAX_MIDIINDRV];
......@@ -381,10 +392,7 @@ wrapup:
*params->err = 0;
params->num_srcs = num_srcs;
params->num_dests = num_dests;
params->num_synths = num_synths;
params->srcs = srcs;
params->dests = dests;
return STATUS_SUCCESS;
}
......@@ -1065,6 +1073,32 @@ static UINT midi_out_get_volume(WORD dev_id, UINT *volume)
return (dests[dev_id].caps.dwSupport & MIDICAPS_VOLUME) ? 0 : MMSYSERR_NOTSUPPORTED;
}
static UINT midi_out_reset(WORD dev_id)
{
struct midi_dest *dest;
unsigned chn;
TRACE("(%04X);\n", dev_id);
if (dev_id >= num_dests) return MMSYSERR_BADDEVICEID;
dest = dests + dev_id;
if (!dest->bEnabled) return MIDIERR_NODEVICE;
/* stop all notes */
/* FIXME: check if 0x78B0 is channel dependent or not. I coded it so that
* it's channel dependent...
*/
for (chn = 0; chn < 16; chn++)
{
/* turn off every note */
midi_out_data(dev_id, 0x7800 | MIDI_CTL_CHANGE | chn);
/* remove sustain on all channels */
midi_out_data(dev_id, (CTL_SUSTAIN << 8) | MIDI_CTL_CHANGE | chn);
}
/* FIXME: the LongData buffers must also be returned to the app */
return MMSYSERR_NOERROR;
}
NTSTATUS midi_out_message(void *args)
{
struct midi_out_message_params *params = args;
......@@ -1108,6 +1142,9 @@ NTSTATUS midi_out_message(void *args)
case MODM_SETVOLUME:
*params->err = 0;
break;
case MODM_RESET:
*params->err = midi_out_reset(params->dev_id);
break;
default:
TRACE("Unsupported message\n");
*params->err = MMSYSERR_NOTSUPPORTED;
......
......@@ -225,24 +225,10 @@ typedef struct midi_src
int fd;
} WINE_MIDIIN;
typedef struct midi_dest
{
BOOL bEnabled;
MIDIOPENDESC midiDesc;
WORD wFlags;
MIDIHDR *lpQueueHdr;
void *lpExtra; /* according to port type (MIDI, FM...), extra data when needed */
MIDIOUTCAPSW caps;
int fd;
} WINE_MIDIOUT;
struct midi_init_params
{
UINT *err;
unsigned int num_dests;
unsigned int num_srcs;
unsigned int num_synths;
struct midi_dest *dests;
struct midi_src *srcs;
};
......
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