From bf3954531522ecdfd99d1e95f6ea9d71f56ded85 Mon Sep 17 00:00:00 2001 From: Huw Davies Date: Thu, 17 Mar 2022 08:14:08 +0000 Subject: [PATCH] winealsa: Move MODM_RESET to the unixlib. Signed-off-by: Huw Davies Signed-off-by: Andrew Eikum Signed-off-by: Alexandre Julliard --- dlls/winealsa.drv/alsamidi.c | 41 ++++++++++++++++++++++++++++++++++-- dlls/winealsa.drv/midi.c | 36 ------------------------------- dlls/winealsa.drv/unixlib.h | 15 ++----------- 3 files changed, 41 insertions(+), 51 deletions(-) diff --git a/dlls/winealsa.drv/alsamidi.c b/dlls/winealsa.drv/alsamidi.c index f3de2a5ce07..b99c3aedd33 100644 --- a/dlls/winealsa.drv/alsamidi.c +++ b/dlls/winealsa.drv/alsamidi.c @@ -48,6 +48,17 @@ WINE_DEFAULT_DEBUG_CHANNEL(midi); +struct midi_dest +{ + BOOL bEnabled; + MIDIOPENDESC midiDesc; + WORD wFlags; + MIDIOUTCAPSW caps; + snd_seq_t *seq; + snd_seq_addr_t addr; + int port_out; +}; + static pthread_mutex_t seq_mutex = PTHREAD_MUTEX_INITIALIZER; static unsigned int num_dests, num_srcs; @@ -353,9 +364,7 @@ NTSTATUS midi_init(void *args) free( pinfo ); *params->err = NOERROR; - params->num_dests = num_dests; params->num_srcs = num_srcs; - params->dests = dests; params->srcs = srcs; TRACE("End\n"); @@ -800,6 +809,31 @@ 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) +{ + unsigned chn; + + TRACE("(%04X);\n", dev_id); + + if (dev_id >= num_dests) return MMSYSERR_BADDEVICEID; + if (!dests[dev_id].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_CMD_CONTROL | chn); + /* remove sustain on all channels */ + midi_out_data(dev_id, (MIDI_CTL_SUSTAIN << 8) | MIDI_CMD_CONTROL | 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; @@ -844,6 +878,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; diff --git a/dlls/winealsa.drv/midi.c b/dlls/winealsa.drv/midi.c index 0ed2feb41eb..53b683f59c8 100644 --- a/dlls/winealsa.drv/midi.c +++ b/dlls/winealsa.drv/midi.c @@ -48,10 +48,7 @@ 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 total number of MIDI out devices found */ static int MIDM_NumDevs = 0; @@ -605,35 +602,6 @@ static DWORD midStop(WORD wDevID) return MMSYSERR_NOERROR; } -/************************************************************************** - * modReset [internal] - */ -static DWORD modReset(WORD wDevID) -{ - DWORD WINAPI ALSA_modMessage(UINT wDevID, UINT wMsg, DWORD_PTR dwUser, - DWORD_PTR dwParam1, DWORD_PTR dwParam2); - 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 */ - ALSA_modMessage(wDevID, MODM_DATA, 0, 0x7800 | MIDI_CMD_CONTROL | chn, 0); - /* remove sustain on all channels */ - ALSA_modMessage(wDevID, MODM_DATA, 0, (MIDI_CTL_SUSTAIN << 8) | MIDI_CMD_CONTROL | chn, 0); - } - /* FIXME: the LongData buffers must also be returned to the app */ - return MMSYSERR_NOERROR; -} - - /*======================================================================* * MIDI entry points * *======================================================================*/ @@ -653,9 +621,7 @@ static BOOL ALSA_MidiInit(void) if (!err) { - MODM_NumDevs = params.num_dests; MIDM_NumDevs = params.num_srcs; - MidiOutDev = params.dests; MidiInDev = params.srcs; } return TRUE; @@ -721,8 +687,6 @@ DWORD WINAPI ALSA_modMessage(UINT wDevID, UINT wMsg, DWORD_PTR dwUser, case DRVM_INIT: ALSA_MidiInit(); return 0; - case MODM_RESET: - return modReset(wDevID); } params.dev_id = wDevID; diff --git a/dlls/winealsa.drv/unixlib.h b/dlls/winealsa.drv/unixlib.h index e3cd7123101..c1dbd83b84e 100644 --- a/dlls/winealsa.drv/unixlib.h +++ b/dlls/winealsa.drv/unixlib.h @@ -223,22 +223,11 @@ typedef struct midi_src int port_in; } WINE_MIDIIN; -typedef struct midi_dest -{ - BOOL bEnabled; - MIDIOPENDESC midiDesc; - WORD wFlags; - MIDIOUTCAPSW caps; - snd_seq_t *seq; - snd_seq_addr_t addr; - int port_out; -} WINE_MIDIOUT; - struct midi_init_params { UINT *err; - unsigned int num_dests, num_srcs; - void *dests, *srcs; + unsigned int num_srcs; + void *srcs; }; struct notify_context