[PATCH 07/12] winecoreaudio: Move midi_out_long_data to the unixlib.

Andrew Eikum aeikum at codeweavers.com
Fri Nov 26 09:02:42 CST 2021


Signed-off-by: Andrew Eikum <aeikum at codeweavers.com>

On Thu, Nov 25, 2021 at 11:03:42AM +0000, Huw Davies wrote:
> Signed-off-by: Huw Davies <huw at codeweavers.com>
> ---
>  dlls/winecoreaudio.drv/audiounit.c | 12 -----
>  dlls/winecoreaudio.drv/coremidi.c  | 59 +++++++++++++++++++++
>  dlls/winecoreaudio.drv/coremidi.h  |  7 ---
>  dlls/winecoreaudio.drv/midi.c      | 85 ------------------------------
>  4 files changed, 59 insertions(+), 104 deletions(-)
> 
> diff --git a/dlls/winecoreaudio.drv/audiounit.c b/dlls/winecoreaudio.drv/audiounit.c
> index d3c53926c59..137b1e93bcf 100644
> --- a/dlls/winecoreaudio.drv/audiounit.c
> +++ b/dlls/winecoreaudio.drv/audiounit.c
> @@ -83,15 +83,3 @@ int AudioUnit_GetVolume(AudioUnit au, float *left, float *right)
>      *right = *left;
>      return 1;
>  }
> -
> -void MIDIOut_Send(MIDIPortRef port, MIDIEndpointRef dest, UInt8 *buffer, unsigned length)
> -{
> -    Byte packetBuff[512];
> -    MIDIPacketList *packetList = (MIDIPacketList *)packetBuff;
> -
> -    MIDIPacket *packet = MIDIPacketListInit(packetList);
> -
> -    packet = MIDIPacketListAdd(packetList, sizeof(packetBuff), packet, mach_absolute_time(), length, buffer);
> -    if (packet)
> -        MIDISend(port, dest, packetList);
> -}
> diff --git a/dlls/winecoreaudio.drv/coremidi.c b/dlls/winecoreaudio.drv/coremidi.c
> index 4dc4166dda1..d80b8c1711b 100644
> --- a/dlls/winecoreaudio.drv/coremidi.c
> +++ b/dlls/winecoreaudio.drv/coremidi.c
> @@ -509,6 +509,62 @@ static DWORD midi_out_data(WORD dev_id, DWORD data)
>      return MMSYSERR_NOERROR;
>  }
>  
> +static DWORD midi_out_long_data(WORD dev_id, MIDIHDR *hdr, DWORD hdr_size, struct notify_context *notify)
> +{
> +    struct midi_dest *dest;
> +    OSStatus sc;
> +
> +    TRACE("dev_id = %d midi_hdr = %p hdr_size = %d\n", dev_id, hdr, hdr_size);
> +
> +    if (dev_id >= num_dests)
> +    {
> +        WARN("bad device ID : %d\n", dev_id);
> +        return MMSYSERR_BADDEVICEID;
> +    }
> +    if (!hdr)
> +    {
> +        WARN("Invalid Parameter\n");
> +        return MMSYSERR_INVALPARAM;
> +    }
> +    if (!hdr->lpData || !(hdr->dwFlags & MHDR_PREPARED))
> +        return MIDIERR_UNPREPARED;
> +
> +    if (hdr->dwFlags & MHDR_INQUEUE)
> +        return MIDIERR_STILLPLAYING;
> +
> +    hdr->dwFlags &= ~MHDR_DONE;
> +    hdr->dwFlags |= MHDR_INQUEUE;
> +
> +    if ((UInt8)hdr->lpData[0] != 0xf0)
> +        /* System Exclusive */
> +        ERR("Add missing 0xf0 marker at the beginning of system exclusive byte stream\n");
> +
> +    if ((UInt8)hdr->lpData[hdr->dwBufferLength - 1] != 0xF7)
> +        /* Send end of System Exclusive */
> +        ERR("Add missing 0xf7 marker at the end of system exclusive byte stream\n");
> +
> +    dest = dests + dev_id;
> +
> +    if (dest->caps.wTechnology == MOD_SYNTH) /* FIXME */
> +    {
> +        sc = MusicDeviceSysEx(dest->synth, (const UInt8 *)hdr->lpData, hdr->dwBufferLength);
> +        if (sc != noErr)
> +        {
> +            ERR("MusicDeviceSysEx returns %s\n", wine_dbgstr_fourcc(sc));
> +            return MMSYSERR_ERROR;
> +        }
> +    }
> +    else if (dest->caps.wTechnology == MOD_MIDIPORT)
> +        midi_send(midi_out_port, dest->dest, (UInt8 *)hdr->lpData, hdr->dwBufferLength);
> +
> +    hdr->dwFlags &= ~MHDR_INQUEUE;
> +    hdr->dwFlags |= MHDR_DONE;
> +
> +    set_out_notify(notify, dest, dev_id, MOM_DONE, (DWORD_PTR)hdr, 0);
> +
> +    return MMSYSERR_NOERROR;
> +}
> +
>  NTSTATUS midi_out_message(void *args)
>  {
>      struct midi_out_message_params *params = args;
> @@ -532,6 +588,9 @@ NTSTATUS midi_out_message(void *args)
>      case MODM_DATA:
>          *params->err = midi_out_data(params->dev_id, params->param_1);
>          break;
> +    case MODM_LONGDATA:
> +        *params->err = midi_out_long_data(params->dev_id, (MIDIHDR *)params->param_1, params->param_2, params->notify);
> +        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 ca669db7db1..f764bad45aa 100644
> --- a/dlls/winecoreaudio.drv/coremidi.h
> +++ b/dlls/winecoreaudio.drv/coremidi.h
> @@ -67,13 +67,6 @@ extern int AudioUnit_SetVolume(AudioUnit au, float left, float right);
>  extern int AudioUnit_GetVolume(AudioUnit au, float *left, float *right);
>  #endif
>  
> -/* coremidi.c */
> -extern MIDIClientRef CoreMIDI_CreateClient(CFStringRef name);
> -extern void CoreMIDI_GetObjectName(MIDIObjectRef obj, char *name, int size);
> -extern void MIDIIn_ReadProc(const MIDIPacketList *pktlist, void *refCon, void *connRefCon);
> -
> -extern void MIDIOut_Send(MIDIPortRef port, MIDIEndpointRef dest, UInt8 *buffer, unsigned length);
> -
>  /* midi.c */
>  typedef struct midi_dest
>  {
> diff --git a/dlls/winecoreaudio.drv/midi.c b/dlls/winecoreaudio.drv/midi.c
> index 98b0a17a147..589a08e0907 100644
> --- a/dlls/winecoreaudio.drv/midi.c
> +++ b/dlls/winecoreaudio.drv/midi.c
> @@ -135,14 +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_DONE:
> -    case MOM_POSITIONCB:
> -	dwCallBack = destinations[wDevID].midiDesc.dwCallback;
> -	uFlags = destinations[wDevID].wFlags;
> -	hDev = destinations[wDevID].midiDesc.hMidi;
> -	dwInstance = destinations[wDevID].midiDesc.dwInstance;
> -	break;
> -
>      case MIM_OPEN:
>      case MIM_CLOSE:
>      case MIM_DATA:
> @@ -163,81 +155,6 @@ static void MIDI_NotifyClient(UINT wDevID, WORD wMsg, DWORD_PTR dwParam1, DWORD_
>      DriverCallback(dwCallBack, uFlags, hDev, wMsg, dwInstance, dwParam1, dwParam2);
>  }
>  
> -static DWORD MIDIOut_LongData(WORD wDevID, LPMIDIHDR lpMidiHdr, DWORD dwSize)
> -{
> -    LPBYTE lpData;
> -    OSStatus err = noErr;
> -
> -    TRACE("wDevID=%d lpMidiHdr=%p dwSize=%d\n", wDevID, lpMidiHdr, dwSize);
> -
> -    /* Note: MS doc does not say much about the dwBytesRecorded member of the MIDIHDR structure
> -     * but it seems to be used only for midi input.
> -     * Taking a look at the WAVEHDR structure (which is quite similar) confirms this assumption.
> -     */
> -
> -    if (wDevID >= MIDIOut_NumDevs) {
> -        WARN("bad device ID : %d\n", wDevID);
> -	return MMSYSERR_BADDEVICEID;
> -    }
> -
> -    if (lpMidiHdr == NULL) {
> -	WARN("Invalid Parameter\n");
> -	return MMSYSERR_INVALPARAM;
> -    }
> -
> -    lpData = (LPBYTE) lpMidiHdr->lpData;
> -
> -    if (lpData == NULL)
> -	return MIDIERR_UNPREPARED;
> -    if (!(lpMidiHdr->dwFlags & MHDR_PREPARED))
> -	return MIDIERR_UNPREPARED;
> -    if (lpMidiHdr->dwFlags & MHDR_INQUEUE)
> -	return MIDIERR_STILLPLAYING;
> -    lpMidiHdr->dwFlags &= ~MHDR_DONE;
> -    lpMidiHdr->dwFlags |= MHDR_INQUEUE;
> -
> -    /* FIXME: MS doc is not 100% clear. Will lpData only contain system exclusive
> -     * data, or can it also contain raw MIDI data, to be split up and sent to
> -     * modShortData() ?
> -     * If the latter is true, then the following WARNing will fire up
> -     */
> -    if (lpData[0] != 0xF0 || lpData[lpMidiHdr->dwBufferLength - 1] != 0xF7) {
> -	WARN("The allegedly system exclusive buffer is not correct\n\tPlease report with MIDI file\n");
> -    }
> -
> -    TRACE("dwBufferLength=%u !\n", lpMidiHdr->dwBufferLength);
> -    TRACE("                 %02X %02X %02X ... %02X %02X %02X\n",
> -	  lpData[0], lpData[1], lpData[2], lpData[lpMidiHdr->dwBufferLength-3],
> -	  lpData[lpMidiHdr->dwBufferLength-2], lpData[lpMidiHdr->dwBufferLength-1]);
> -
> -
> -    if (lpData[0] != 0xF0) {
> -        /* System Exclusive */
> -        ERR("Add missing 0xF0 marker at the beginning of system exclusive byte stream\n");
> -    }
> -    if (lpData[lpMidiHdr->dwBufferLength - 1] != 0xF7) {
> -        /* Send end of System Exclusive */
> -        ERR("Add missing 0xF7 marker at the end of system exclusive byte stream\n");
> -    }
> -    if (destinations[wDevID].caps.wTechnology == MOD_SYNTH) /* FIXME */
> -    {
> -        err = MusicDeviceSysEx(destinations[wDevID].synth, (const UInt8 *) lpData, lpMidiHdr->dwBufferLength);
> -        if (err != noErr)
> -        {
> -            ERR("MusicDeviceSysEx(%p, %p, %d) return %s\n", destinations[wDevID].synth, lpData, lpMidiHdr->dwBufferLength, wine_dbgstr_fourcc(err));
> -            return MMSYSERR_ERROR;
> -        }
> -    }
> -    else if (destinations[wDevID].caps.wTechnology == MOD_MIDIPORT) {
> -        MIDIOut_Send(MIDIOutPort, destinations[wDevID].dest, lpData, lpMidiHdr->dwBufferLength);
> -    }
> -
> -    lpMidiHdr->dwFlags &= ~MHDR_INQUEUE;
> -    lpMidiHdr->dwFlags |= MHDR_DONE;
> -    MIDI_NotifyClient(wDevID, MOM_DONE, (DWORD_PTR)lpMidiHdr, 0L);
> -    return MMSYSERR_NOERROR;
> -}
> -
>  /**************************************************************************
>   * 			MIDIOut_Prepare				[internal]
>   */
> @@ -725,8 +642,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_LONGDATA:
> -            return MIDIOut_LongData(wDevID, (LPMIDIHDR)dwParam1, dwParam2);
>          case MODM_PREPARE:
>              return MIDIOut_Prepare(wDevID, (LPMIDIHDR)dwParam1, dwParam2);
>          case MODM_UNPREPARE:
> -- 
> 2.23.0
> 
> 



More information about the wine-devel mailing list