[PATCH 12/12] winecoreaudio: Move midi_out_reset to the unixlib.
Andrew Eikum
aeikum at codeweavers.com
Fri Nov 26 09:03:35 CST 2021
Signed-off-by: Andrew Eikum <aeikum at codeweavers.com>
On Thu, Nov 25, 2021 at 11:03:47AM +0000, Huw Davies wrote:
> Signed-off-by: Huw Davies <huw at codeweavers.com>
> ---
> dlls/winecoreaudio.drv/coremidi.c | 46 +++++++++++++++++++++++++++++--
> dlls/winecoreaudio.drv/coremidi.h | 13 ---------
> dlls/winecoreaudio.drv/midi.c | 37 -------------------------
> dlls/winecoreaudio.drv/unixlib.h | 6 ++--
> 4 files changed, 46 insertions(+), 56 deletions(-)
>
> diff --git a/dlls/winecoreaudio.drv/coremidi.c b/dlls/winecoreaudio.drv/coremidi.c
> index 1ced023d4a6..1ca9ad6eb8e 100644
> --- a/dlls/winecoreaudio.drv/coremidi.c
> +++ b/dlls/winecoreaudio.drv/coremidi.c
> @@ -92,6 +92,19 @@
>
> WINE_DEFAULT_DEBUG_CHANNEL(midi);
>
> +struct midi_dest
> +{
> + /* graph and synth are only used for MIDI Synth */
> + AUGraph graph;
> + AudioUnit synth;
> +
> + MIDIEndpointRef dest;
> +
> + MIDIOUTCAPSW caps;
> + MIDIOPENDESC midiDesc;
> + WORD wFlags;
> +};
> +
> static MIDIClientRef midi_client;
> static MIDIPortRef midi_out_port, midi_in_port;
> static UINT num_dests, num_srcs;
> @@ -234,11 +247,8 @@ NTSTATUS midi_init(void *args)
> dests[i].caps.wNotes = 0;
> }
>
> - params->num_dests = num_dests;
> params->num_srcs = num_srcs;
> - params->dests = dests;
> params->srcs = srcs;
> - params->midi_out_port = (void *)midi_out_port;
> params->midi_in_port = (void *)midi_in_port;
>
> *params->err = DRV_SUCCESS;
> @@ -674,6 +684,33 @@ static DWORD midi_out_set_volume(WORD dev_id, DWORD volume)
> return MMSYSERR_NOTSUPPORTED;
> }
>
> +static DWORD midi_out_reset(WORD dev_id)
> +{
> + unsigned chn;
> +
> + TRACE("%d\n", dev_id);
> +
> + if (dev_id >= num_dests)
> + {
> + WARN("bad device ID : %d\n", dev_id);
> + return MMSYSERR_BADDEVICEID;
> + }
> + if (dests[dev_id].caps.wTechnology == MOD_SYNTH)
> + {
> + for (chn = 0; chn < 16; chn++)
> + {
> + /* turn off every note */
> + MusicDeviceMIDIEvent(dests[dev_id].synth, 0xB0 | chn, 0x7B, 0, 0);
> + /* remove sustain on channel */
> + MusicDeviceMIDIEvent(dests[dev_id].synth, 0xB0 | chn, 0x40, 0, 0);
> + }
> + }
> + else FIXME("MOD_MIDIPORT\n");
> +
> + /* 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;
> @@ -718,6 +755,9 @@ NTSTATUS midi_out_message(void *args)
> case MODM_SETVOLUME:
> *params->err = midi_out_set_volume(params->dev_id, params->param_1);
> 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/winecoreaudio.drv/coremidi.h b/dlls/winecoreaudio.drv/coremidi.h
> index bf6a478c859..e6d5c8c18c8 100644
> --- a/dlls/winecoreaudio.drv/coremidi.h
> +++ b/dlls/winecoreaudio.drv/coremidi.h
> @@ -64,19 +64,6 @@ extern OSStatus MusicDeviceSysEx(AudioUnit au, const UInt8 *inData, UInt32 inLen
> #endif
>
> /* midi.c */
> -typedef struct midi_dest
> -{
> - /* graph and synth are only used for MIDI Synth */
> - AUGraph graph;
> - AudioUnit synth;
> -
> - MIDIEndpointRef dest;
> -
> - MIDIOUTCAPSW caps;
> - MIDIOPENDESC midiDesc;
> - WORD wFlags;
> -} MIDIDestination;
> -
> typedef struct midi_src
> {
> MIDIEndpointRef source;
> diff --git a/dlls/winecoreaudio.drv/midi.c b/dlls/winecoreaudio.drv/midi.c
> index 3033503f8f2..f58dcc2e7a0 100644
> --- a/dlls/winecoreaudio.drv/midi.c
> +++ b/dlls/winecoreaudio.drv/midi.c
> @@ -50,7 +50,6 @@ WINE_DEFAULT_DEBUG_CHANNEL(midi);
> #define WINE_DEFINITIONS
> #include "coremidi.h"
>
> -static DWORD MIDIOut_NumDevs = 0;
> static DWORD MIDIIn_NumDevs = 0;
>
> static CRITICAL_SECTION midiInLock; /* Critical section for MIDI In */
> @@ -59,9 +58,7 @@ static CFStringRef MIDIInThreadPortName;
> static DWORD WINAPI MIDIIn_MessageThread(LPVOID p);
>
> static MIDIPortRef MIDIInPort = NULL;
> -static MIDIPortRef MIDIOutPort = NULL;
>
> -MIDIDestination *destinations;
> MIDISource *sources;
>
> static void notify_client(struct notify_context *notify)
> @@ -86,11 +83,8 @@ static LONG CoreAudio_MIDIInit(void)
> return err;
> }
>
> - MIDIOut_NumDevs = params.num_dests;
> MIDIIn_NumDevs = params.num_srcs;
> - destinations = params.dests;
> sources = params.srcs;
> - MIDIOutPort = params.midi_out_port;
> MIDIInPort = params.midi_in_port;
>
> if (MIDIIn_NumDevs > 0)
> @@ -110,7 +104,6 @@ static LONG CoreAudio_MIDIRelease(void)
>
> UNIX_CALL(midi_release, NULL);
> sources = NULL;
> - destinations = NULL;
>
> if (MIDIIn_NumDevs > 0)
> {
> @@ -155,31 +148,6 @@ static void MIDI_NotifyClient(UINT wDevID, WORD wMsg, DWORD_PTR dwParam1, DWORD_
> DriverCallback(dwCallBack, uFlags, hDev, wMsg, dwInstance, dwParam1, dwParam2);
> }
>
> -static DWORD MIDIOut_Reset(WORD wDevID)
> -{
> - unsigned chn;
> -
> - TRACE("%d\n", wDevID);
> -
> - if (wDevID >= MIDIOut_NumDevs) {
> - WARN("bad device ID : %d\n", wDevID);
> - return MMSYSERR_BADDEVICEID;
> - }
> - if (destinations[wDevID].caps.wTechnology == MOD_SYNTH)
> - {
> - for (chn = 0; chn < 16; chn++) {
> - /* turn off every note */
> - MusicDeviceMIDIEvent(destinations[wDevID].synth, 0xB0 | chn, 0x7B, 0, 0);
> - /* remove sustain on channel */
> - MusicDeviceMIDIEvent(destinations[wDevID].synth, 0xB0 | chn, 0x40, 0, 0);
> - }
> - }
> - else FIXME("MOD_MIDIPORT\n");
> -
> - /* FIXME: the LongData buffers must also be returned to the app */
> - return MMSYSERR_NOERROR;
> -}
> -
> static DWORD MIDIIn_Open(WORD wDevID, LPMIDIOPENDESC lpDesc, DWORD dwFlags)
> {
> TRACE("wDevID=%d lpDesc=%p dwFlags=%08x\n", wDevID, lpDesc, dwFlags);
> @@ -532,11 +500,6 @@ DWORD WINAPI CoreAudio_modMessage(UINT wDevID, UINT wMsg, DWORD_PTR dwUser, DWOR
>
> TRACE("%d %08x %08lx %08lx %08lx\n", wDevID, wMsg, dwUser, dwParam1, dwParam2);
>
> - switch (wMsg) {
> - case MODM_RESET:
> - return MIDIOut_Reset(wDevID);
> - }
> -
> params.dev_id = wDevID;
> params.msg = wMsg;
> params.user = dwUser;
> diff --git a/dlls/winecoreaudio.drv/unixlib.h b/dlls/winecoreaudio.drv/unixlib.h
> index 6afb9eb287d..bdf38b24c88 100644
> --- a/dlls/winecoreaudio.drv/unixlib.h
> +++ b/dlls/winecoreaudio.drv/unixlib.h
> @@ -186,9 +186,9 @@ struct set_volumes_params
> struct midi_init_params
> {
> DWORD *err;
> - UINT num_dests, num_srcs;
> - void *dests, *srcs;
> - void *midi_out_port, *midi_in_port;
> + UINT num_srcs;
> + void *srcs;
> + void *midi_in_port;
> };
>
> struct notify_context
> --
> 2.23.0
>
>
More information about the wine-devel
mailing list