Skip to content
Snippets Groups Projects
Commit afdc1ec5 authored by sletz's avatar sletz
Browse files

fix winmmedriver to skip midi devices that dont open.

(cherry picked from commit c024b08a476526d082125e6ed47e5fe53a7706e1)


git-svn-id: http://subversion.jackaudio.org/jack/jack2/trunk/jackmp@3568 0c269be4-1314-0410-8aa9-9f06e86f4224
parent 81446bd9
No related branches found
No related tags found
No related merge requests found
......@@ -116,84 +116,84 @@ int JackWinMMEDriver::Open(bool capturing,
assert(fMidiDestination);
// Real input
int devindex = 0;
for (int i = 0; i < fRealCaptureChannels; i++) {
HMIDIIN handle;
fMidiDestination[i].fIndex = i;
MMRESULT ret = midiInOpen(&handle, fMidiDestination[i].fIndex, (DWORD)MidiInProc, (DWORD)fRingBuffer[i], CALLBACK_FUNCTION);
fMidiDestination[devindex].fIndex = i;
MMRESULT ret = midiInOpen(&handle, fMidiDestination[devindex].fIndex, (DWORD)MidiInProc, (DWORD)fRingBuffer[devindex], CALLBACK_FUNCTION);
if (ret == MMSYSERR_NOERROR) {
fMidiDestination[i].fHandle = handle;
if (!InitHeaders(&fMidiDestination[i])) {
fMidiDestination[devindex].fHandle = handle;
if (!InitHeaders(&fMidiDestination[devindex])) {
jack_error("memory allocation failed");
midiInClose(handle);
goto error;
//continue;
continue;
}
ret = midiInPrepareHeader(handle, fMidiDestination[i].fHeader, sizeof(MIDIHDR));
ret = midiInPrepareHeader(handle, fMidiDestination[devindex].fHeader, sizeof(MIDIHDR));
if (ret == MMSYSERR_NOERROR) {
fMidiDestination[i].fHeader->dwUser = 1;
ret = midiInAddBuffer(handle, fMidiDestination[i].fHeader, sizeof(MIDIHDR));
fMidiDestination[devindex].fHeader->dwUser = 1;
ret = midiInAddBuffer(handle, fMidiDestination[devindex].fHeader, sizeof(MIDIHDR));
if (ret == MMSYSERR_NOERROR) {
ret = midiInStart(handle);
if (ret != MMSYSERR_NOERROR) {
jack_error("midiInStart error");
CloseInput(&fMidiDestination[i]);
goto error;
CloseInput(&fMidiDestination[devindex]);
continue;
}
} else {
jack_error ("midiInAddBuffer error");
CloseInput(&fMidiDestination[i]);
goto error;
CloseInput(&fMidiDestination[devindex]);
continue;
}
} else {
jack_error("midiInPrepareHeader error");
midiInClose(handle);
goto error;
continue;
}
} else {
jack_error ("midiInOpen error");
goto error;
continue;
}
devindex += 1;
}
fRealCaptureChannels = devindex;
fCaptureChannels = devindex;
fMidiSource = new MidiSlot[fRealPlaybackChannels];
assert(fMidiSource);
// Real output
devindex = 0;
for (int i = 0; i < fRealPlaybackChannels; i++) {
MMRESULT res;
HMIDIOUT handle;
fMidiSource[i].fIndex = i;
UINT ret = midiOutOpen(&handle, fMidiSource[i].fIndex, 0L, 0L, CALLBACK_NULL);
fMidiSource[devindex].fIndex = i;
UINT ret = midiOutOpen(&handle, fMidiSource[devindex].fIndex, 0L, 0L, CALLBACK_NULL);
if (ret == MMSYSERR_NOERROR) {
fMidiSource[i].fHandle = handle;
if (!InitHeaders(&fMidiSource[i])) {
fMidiSource[devindex].fHandle = handle;
if (!InitHeaders(&fMidiSource[devindex])) {
jack_error("memory allocation failed");
midiOutClose(handle);
//continue;
goto error;
continue;
}
res = midiOutPrepareHeader(handle, fMidiSource[i].fHeader, sizeof(MIDIHDR));
res = midiOutPrepareHeader(handle, fMidiSource[devindex].fHeader, sizeof(MIDIHDR));
if (res != MMSYSERR_NOERROR) {
jack_error("midiOutPrepareHeader error %d %d %d", i, handle, res);
//continue;
goto error;
continue;
} else {
fMidiSource[i].fHeader->dwUser = 1;
fMidiSource[devindex].fHeader->dwUser = 1;
}
} else {
jack_error("midiOutOpen error");
goto error;
continue;
}
devindex += 1;
}
fRealPlaybackChannels = devindex;
fPlaybackChannels = devindex;
return 0;
error:
Close();
return -1;
}
void JackWinMMEDriver::CloseInput(MidiSlot* slot)
......@@ -297,7 +297,7 @@ int JackWinMMEDriver::Attach()
for (i = 0; i < fCaptureChannels; i++) {
MIDIINCAPS caps;
res = midiInGetDevCaps(i, &caps, sizeof(caps));
res = midiInGetDevCaps(fMidiSource[i].fIndex, &caps, sizeof(caps));
if (res == MMSYSERR_NOERROR) {
snprintf(alias, sizeof(alias) - 1, "%s:%s:out%d", fAliasName, caps.szPname, i + 1);
} else {
......@@ -319,7 +319,7 @@ int JackWinMMEDriver::Attach()
for (i = 0; i < fPlaybackChannels; i++) {
MIDIOUTCAPS caps;
res = midiOutGetDevCaps(i, &caps, sizeof(caps));
res = midiOutGetDevCaps(fMidiDestination[i].fIndex, &caps, sizeof(caps));
if (res == MMSYSERR_NOERROR) {
snprintf(alias, sizeof(alias) - 1, "%s:%s:out%d", fAliasName, caps.szPname, i + 1);
} else {
......@@ -415,7 +415,7 @@ extern "C"
SERVER_EXPORT jack_driver_desc_t * driver_get_descriptor()
{
jack_driver_desc_t * desc;
unsigned int i;
//unsigned int i;
desc = (jack_driver_desc_t*)calloc (1, sizeof (jack_driver_desc_t));
strcpy(desc->name, "winmme"); // size MUST be less then JACK_DRIVER_NAME_MAX + 1
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment