Strange MMSYSTEM error with XP
I'm trying to send a GM reset command to a midi device, which works
well in Win7 but not XP (same code). See details below in the code. I
have no clue what could be wrong. Any ideas? It's independent of the
(not) sent data and it happens on my laptop as well as a friend's
computer. Not on my desktop machine with Win7.
THX,
Hans
void CMainFrame::SendGmReset(HMIDIOUT hMidi)
{
static const BYTE GMreset[] = {0xF0, 0x7E, 0x7F, 0x09, 0x01, 0xF7};
SendSysex(hMidi, GMreset, sizeof(GMreset));
}
void CMainFrame::SendSysex(HMIDIOUT hMidi, const BYTE *pBuf, int
count)
{
MIDIHDR mh = { 0 };
mh.lpData = (LPSTR) pBuf;
mh.dwBufferLength = count;
mh.dwBytesRecorded = count;
MidiErrorMessage (midiOutPrepareHeader(hMidi, &mh, sizeof(mh)));
// The call to midiOutLongMsg(...) returns 7 and causes the
// error message:
// There is not enough memory available for this task.
// Quit one or more applications to increase available
// memory and then try again.
MidiErrorMessage (midiOutLongMsg(hMidi, &mh, sizeof(mh)));
MidiErrorMessage (midiOutUnprepareHeader(hMidi, &mh, sizeof(mh)));
}
void CMainFrame::MidiErrorMessage (MMRESULT nError)
{
if (nError != MMSYSERR_NOERROR)
{
TCHAR errText[512];
CString str(_T("MIDI: "));
midiOutGetErrorText(nError, errText, _countof(errText));
str.Append(errText);
AfxMessageBox(str);
}
}