midimap: Implement callback/notification.

This commit is contained in:
Jörg Höhle 2010-02-10 19:42:15 +01:00 committed by Alexandre Julliard
parent 788d8720e7
commit a8b8078704
2 changed files with 19 additions and 11 deletions

View File

@ -92,6 +92,8 @@ typedef struct tagMIDIMAPDATA
{
struct tagMIDIMAPDATA* self;
MIDIOUTPORT* ChannelMap[16];
MIDIOPENDESC midiDesc;
WORD wCbFlags;
} MIDIMAPDATA;
static MIDIOUTPORT* midiOutPorts;
@ -258,6 +260,13 @@ static BOOL MIDIMAP_LoadSettings(MIDIMAPDATA* mom)
return ret;
}
static void MIDIMAP_NotifyClient(MIDIMAPDATA* mom, WORD wMsg,
DWORD_PTR dwParam1, DWORD_PTR dwParam2)
{
DriverCallback(mom->midiDesc.dwCallback, mom->wCbFlags, (HDRVR)mom->midiDesc.hMidi,
wMsg, mom->midiDesc.dwInstance, dwParam1, dwParam2);
}
static DWORD modOpen(DWORD_PTR *lpdwUser, LPMIDIOPENDESC lpDesc, DWORD dwFlags)
{
MIDIMAPDATA* mom = HeapAlloc(GetProcessHeap(), 0, sizeof(MIDIMAPDATA));
@ -265,11 +274,9 @@ static DWORD modOpen(DWORD_PTR *lpdwUser, LPMIDIOPENDESC lpDesc, DWORD dwFlags)
TRACE("(%p %p %08x)\n", lpdwUser, lpDesc, dwFlags);
if (!mom) return MMSYSERR_NOMEM;
if (HIWORD(dwFlags & CALLBACK_TYPEMASK)) {
FIXME("NIY callback flags %08x\n", dwFlags);
if (!lpDesc) {
HeapFree(GetProcessHeap(), 0, mom);
return MMSYSERR_INVALFLAG;
return MMSYSERR_INVALPARAM;
}
if (MIDIMAP_LoadSettings(mom))
@ -277,6 +284,10 @@ static DWORD modOpen(DWORD_PTR *lpdwUser, LPMIDIOPENDESC lpDesc, DWORD dwFlags)
*lpdwUser = (DWORD_PTR)mom;
mom->self = mom;
mom->wCbFlags = HIWORD(dwFlags & CALLBACK_TYPEMASK);
mom->midiDesc = *lpDesc;
MIDIMAP_NotifyClient(mom, MOM_OPEN, 0L, 0L);
return MMSYSERR_NOERROR;
}
HeapFree(GetProcessHeap(), 0, mom);
@ -305,8 +316,10 @@ static DWORD modClose(MIDIMAPDATA* mom)
ret = t;
}
}
if (ret == MMSYSERR_NOERROR)
if (ret == MMSYSERR_NOERROR) {
MIDIMAP_NotifyClient(mom, MOM_CLOSE, 0L, 0L);
HeapFree(GetProcessHeap(), 0, mom);
}
return ret;
}
@ -342,6 +355,7 @@ static DWORD modLongData(MIDIMAPDATA* mom, LPMIDIHDR lpMidiHdr, DWORD_PTR dwPara
}
lpMidiHdr->dwFlags &= ~MHDR_INQUEUE;
lpMidiHdr->dwFlags |= MHDR_DONE;
MIDIMAP_NotifyClient(mom, MOM_DONE, (DWORD_PTR)lpMidiHdr, 0L);
return ret;
}

View File

@ -203,9 +203,6 @@ static void test_midiOut_device(UINT udev, HWND hwnd)
rc = midiOutOpen(&hm, udev, (DWORD_PTR)hwnd, (DWORD_PTR)MYCBINST, CALLBACK_WINDOW);
else
rc = midiOutOpen(&hm, udev, (DWORD_PTR)callback_func, (DWORD_PTR)MYCBINST, CALLBACK_FUNCTION);
if (MIDIMAPPER==udev) todo_wine
ok(!rc, "midiOutOpen(dev=%d) rc=%s\n", udev, mmsys_error(rc));
else
ok(!rc, "midiOutOpen(dev=%d) rc=%s\n", udev, mmsys_error(rc));
if (rc) return;
@ -316,9 +313,6 @@ static void test_midiStream(UINT udev, HWND hwnd)
rc = midiStreamOpen(&hm, &udev, 1, (DWORD_PTR)hwnd, (DWORD_PTR)MYCBINST, CALLBACK_WINDOW);
else
rc = midiStreamOpen(&hm, &udev, 1, (DWORD_PTR)callback_func, (DWORD_PTR)MYCBINST, CALLBACK_FUNCTION);
if (MIDIMAPPER==udev) todo_wine
ok(!rc, "midiStreamOpen(dev=%d) rc=%s\n", udev, mmsys_error(rc));
else
ok(!rc, "midiStreamOpen(dev=%d) rc=%s\n", udev, mmsys_error(rc));
if (rc) return;