[PATCH 05/12] winecoreaudio: Move midi_out_close to the unixlib.
Andrew Eikum
aeikum at codeweavers.com
Fri Nov 26 09:02:18 CST 2021
Signed-off-by: Andrew Eikum <aeikum at codeweavers.com>
On Thu, Nov 25, 2021 at 11:03:40AM +0000, Huw Davies wrote:
> Signed-off-by: Huw Davies <huw at codeweavers.com>
> ---
> dlls/winecoreaudio.drv/audiounit.c | 23 --------------
> dlls/winecoreaudio.drv/coremidi.c | 50 ++++++++++++++++++++++++++++++
> dlls/winecoreaudio.drv/midi.c | 28 -----------------
> 3 files changed, 50 insertions(+), 51 deletions(-)
>
> diff --git a/dlls/winecoreaudio.drv/audiounit.c b/dlls/winecoreaudio.drv/audiounit.c
> index d155bda7be3..d3c53926c59 100644
> --- a/dlls/winecoreaudio.drv/audiounit.c
> +++ b/dlls/winecoreaudio.drv/audiounit.c
> @@ -49,7 +49,6 @@
> #include "wine/debug.h"
>
> WINE_DEFAULT_DEBUG_CHANNEL(wave);
> -WINE_DECLARE_DEBUG_CHANNEL(midi);
>
> int AudioUnit_SetVolume(AudioUnit au, float left, float right)
> {
> @@ -85,28 +84,6 @@ int AudioUnit_GetVolume(AudioUnit au, float *left, float *right)
> return 1;
> }
>
> -
> -int SynthUnit_Close(AUGraph graph)
> -{
> - OSStatus err = noErr;
> -
> - err = AUGraphStop(graph);
> - if (err != noErr)
> - {
> - ERR_(midi)("AUGraphStop(%p) return %s\n", graph, wine_dbgstr_fourcc(err));
> - return 0;
> - }
> -
> - err = DisposeAUGraph(graph);
> - if (err != noErr)
> - {
> - ERR_(midi)("DisposeAUGraph(%p) return %s\n", graph, wine_dbgstr_fourcc(err));
> - return 0;
> - }
> -
> - return 1;
> -}
> -
> void MIDIOut_Send(MIDIPortRef port, MIDIEndpointRef dest, UInt8 *buffer, unsigned length)
> {
> Byte packetBuff[512];
> diff --git a/dlls/winecoreaudio.drv/coremidi.c b/dlls/winecoreaudio.drv/coremidi.c
> index a7b84f0a41e..6fddbd7d88a 100644
> --- a/dlls/winecoreaudio.drv/coremidi.c
> +++ b/dlls/winecoreaudio.drv/coremidi.c
> @@ -356,6 +356,27 @@ static BOOL synth_unit_init(AudioUnit synth, AUGraph graph)
> return TRUE;
> }
>
> +static BOOL synth_unit_close(AUGraph graph)
> +{
> + OSStatus sc;
> +
> + sc = AUGraphStop(graph);
> + if (sc != noErr)
> + {
> + ERR("AUGraphStop(%p) returns %s\n", graph, wine_dbgstr_fourcc(sc));
> + return FALSE;
> + }
> +
> + sc = DisposeAUGraph(graph);
> + if (sc != noErr)
> + {
> + ERR("DisposeAUGraph(%p) returns %s\n", graph, wine_dbgstr_fourcc(sc));
> + return FALSE;
> + }
> +
> + return TRUE;
> +}
> +
> static void set_out_notify(struct notify_context *notify, struct midi_dest *dest, WORD dev_id, WORD msg,
> DWORD_PTR param_1, DWORD_PTR param_2)
> {
> @@ -416,6 +437,32 @@ static DWORD midi_out_open(WORD dev_id, MIDIOPENDESC *midi_desc, DWORD flags, st
> return MMSYSERR_NOERROR;
> }
>
> +static DWORD midi_out_close(WORD dev_id, struct notify_context *notify)
> +{
> + struct midi_dest *dest;
> +
> + TRACE("dev_id = %d\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->caps.wTechnology == MOD_SYNTH)
> + synth_unit_close(dest->graph);
> + dest->graph = 0;
> + dest->synth = 0;
> +
> + 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;
> @@ -433,6 +480,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;
> diff --git a/dlls/winecoreaudio.drv/midi.c b/dlls/winecoreaudio.drv/midi.c
> index 575a8bf6813..e2418645968 100644
> --- a/dlls/winecoreaudio.drv/midi.c
> +++ b/dlls/winecoreaudio.drv/midi.c
> @@ -64,8 +64,6 @@ static MIDIPortRef MIDIOutPort = NULL;
> MIDIDestination *destinations;
> MIDISource *sources;
>
> -extern int SynthUnit_Close(AUGraph graph);
> -
> static void notify_client(struct notify_context *notify)
> {
> TRACE("dev_id=%d msg=%d param1=%04lX param2=%04lX\n", notify->dev_id, notify->msg, notify->param_1, notify->param_2);
> @@ -137,7 +135,6 @@ static void MIDI_NotifyClient(UINT wDevID, WORD wMsg, DWORD_PTR dwParam1, DWORD_
> TRACE("wDevID=%d wMsg=%d dwParm1=%04lX dwParam2=%04lX\n", wDevID, wMsg, dwParam1, dwParam2);
>
> switch (wMsg) {
> - case MOM_CLOSE:
> case MOM_DONE:
> case MOM_POSITIONCB:
> dwCallBack = destinations[wDevID].midiDesc.dwCallback;
> @@ -166,29 +163,6 @@ static void MIDI_NotifyClient(UINT wDevID, WORD wMsg, DWORD_PTR dwParam1, DWORD_
> DriverCallback(dwCallBack, uFlags, hDev, wMsg, dwInstance, dwParam1, dwParam2);
> }
>
> -static DWORD MIDIOut_Close(WORD wDevID)
> -{
> - DWORD ret = MMSYSERR_NOERROR;
> -
> - TRACE("wDevID=%d\n", wDevID);
> -
> - if (wDevID >= MIDIOut_NumDevs) {
> - WARN("bad device ID : %d\n", wDevID);
> - return MMSYSERR_BADDEVICEID;
> - }
> -
> - if (destinations[wDevID].caps.wTechnology == MOD_SYNTH)
> - SynthUnit_Close(destinations[wDevID].graph);
> -
> - destinations[wDevID].graph = 0;
> - destinations[wDevID].synth = 0;
> -
> - MIDI_NotifyClient(wDevID, MOM_CLOSE, 0L, 0L);
> - destinations[wDevID].midiDesc.hMidi = 0;
> -
> - return ret;
> -}
> -
> static DWORD MIDIOut_Data(WORD wDevID, DWORD dwParam)
> {
> WORD evt = LOBYTE(LOWORD(dwParam));
> @@ -789,8 +763,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_CLOSE:
> - return MIDIOut_Close(wDevID);
> case MODM_DATA:
> return MIDIOut_Data(wDevID, dwParam1);
> case MODM_LONGDATA:
> --
> 2.23.0
>
>
More information about the wine-devel
mailing list