mirror of
https://github.com/JetBrains/JetBrainsRuntime.git
synced 2025-12-23 01:39:44 +01:00
8200648: Make midi code more sound
Reviewed-by: serb, mschoene, rhalade
This commit is contained in:
@@ -252,7 +252,7 @@ INT32 MIDI_IN_GetNumDevices() {
|
||||
}
|
||||
|
||||
INT32 getMidiInCaps(INT32 deviceID, MIDIINCAPSW* caps, INT32* err) {
|
||||
(*err) = midiInGetDevCapsW(deviceID, caps, sizeof(MIDIINCAPS));
|
||||
(*err) = midiInGetDevCapsW(deviceID, caps, sizeof(MIDIINCAPSW));
|
||||
return ((*err) == MMSYSERR_NOERROR);
|
||||
}
|
||||
|
||||
@@ -260,6 +260,7 @@ INT32 MIDI_IN_GetDeviceName(INT32 deviceID, char *name, UINT32 nameLength) {
|
||||
MIDIINCAPSW midiInCaps;
|
||||
INT32 err;
|
||||
|
||||
memset(&midiInCaps, 0, sizeof(midiInCaps));
|
||||
if (getMidiInCaps(deviceID, &midiInCaps, &err)) {
|
||||
UnicodeToUTF8AndCopy(name, midiInCaps.szPname, nameLength);
|
||||
return MIDI_SUCCESS;
|
||||
@@ -284,6 +285,7 @@ INT32 MIDI_IN_GetDeviceVersion(INT32 deviceID, char *name, UINT32 nameLength) {
|
||||
MIDIINCAPSW midiInCaps;
|
||||
INT32 err = MIDI_NOT_SUPPORTED;
|
||||
|
||||
memset(&midiInCaps, 0, sizeof(midiInCaps));
|
||||
if (getMidiInCaps(deviceID, &midiInCaps, &err) && (nameLength>7)) {
|
||||
sprintf(name, "%d.%d", (midiInCaps.vDriverVersion & 0xFF00) >> 8, midiInCaps.vDriverVersion & 0xFF);
|
||||
return MIDI_SUCCESS;
|
||||
|
||||
@@ -70,12 +70,13 @@ INT32 MIDI_OUT_GetNumDevices() {
|
||||
|
||||
|
||||
INT32 getMidiOutCaps(INT32 deviceID, MIDIOUTCAPSW* caps, INT32* err) {
|
||||
UINT_PTR id;
|
||||
if (deviceID == 0) {
|
||||
deviceID = MIDI_MAPPER;
|
||||
id = MIDI_MAPPER;
|
||||
} else {
|
||||
deviceID--;
|
||||
id = (UINT_PTR)(deviceID-1);
|
||||
}
|
||||
(*err) = (INT32) midiOutGetDevCapsW(deviceID, caps, sizeof(MIDIOUTCAPS));
|
||||
(*err) = (INT32) midiOutGetDevCapsW(id, caps, sizeof(MIDIOUTCAPSW));
|
||||
return ((*err) == MMSYSERR_NOERROR);
|
||||
}
|
||||
|
||||
@@ -84,6 +85,7 @@ INT32 MIDI_OUT_GetDeviceName(INT32 deviceID, char *name, UINT32 nameLength) {
|
||||
MIDIOUTCAPSW midiOutCaps;
|
||||
INT32 err;
|
||||
|
||||
memset(&midiOutCaps, 0, sizeof(midiOutCaps));
|
||||
if (getMidiOutCaps(deviceID, &midiOutCaps, &err)) {
|
||||
UnicodeToUTF8AndCopy(name, midiOutCaps.szPname, nameLength);
|
||||
return MIDI_SUCCESS;
|
||||
@@ -103,6 +105,7 @@ INT32 MIDI_OUT_GetDeviceDescription(INT32 deviceID, char *name, UINT32 nameLengt
|
||||
char *desc;
|
||||
INT32 err;
|
||||
|
||||
memset(&midiOutCaps, 0, sizeof(midiOutCaps));
|
||||
if (getMidiOutCaps(deviceID, &midiOutCaps, &err)) {
|
||||
int tech = (int)midiOutCaps.wTechnology;
|
||||
switch(tech) {
|
||||
@@ -139,6 +142,7 @@ INT32 MIDI_OUT_GetDeviceVersion(INT32 deviceID, char *name, UINT32 nameLength) {
|
||||
MIDIOUTCAPSW midiOutCaps;
|
||||
INT32 err;
|
||||
|
||||
memset(&midiOutCaps, 0, sizeof(midiOutCaps));
|
||||
if (getMidiOutCaps(deviceID, &midiOutCaps, &err) && nameLength>7) {
|
||||
sprintf(name, "%d.%d", (midiOutCaps.vDriverVersion & 0xFF00) >> 8, midiOutCaps.vDriverVersion & 0xFF);
|
||||
return MIDI_SUCCESS;
|
||||
|
||||
@@ -357,7 +357,7 @@ int lineHasControls(HMIXER handle, MIXERLINE* line, MIXERLINECONTROLS* controls)
|
||||
|
||||
INT32 PORT_GetPortMixerDescription(INT32 mixerIndex, PortMixerDescription* description) {
|
||||
MIXERCAPSW mixerCaps;
|
||||
if (mixerGetDevCapsW(mixerIndex, &mixerCaps, sizeof(MIXERCAPS)) == MMSYSERR_NOERROR) {
|
||||
if (mixerGetDevCapsW(mixerIndex, &mixerCaps, sizeof(MIXERCAPSW)) == MMSYSERR_NOERROR) {
|
||||
UnicodeToUTF8AndCopy(description->name, mixerCaps.szPname, PORT_STRING_LENGTH);
|
||||
sprintf(description->version, "%d.%d", (mixerCaps.vDriverVersion & 0xFF00) >> 8, mixerCaps.vDriverVersion & 0xFF);
|
||||
strncpy(description->description, "Port Mixer", PORT_STRING_LENGTH-1);
|
||||
@@ -368,9 +368,9 @@ INT32 PORT_GetPortMixerDescription(INT32 mixerIndex, PortMixerDescription* descr
|
||||
|
||||
int getDestinationCount(HMIXER handle) {
|
||||
int ret = 0;
|
||||
MIXERCAPS mixerCaps;
|
||||
MIXERCAPSW mixerCaps;
|
||||
|
||||
if (mixerGetDevCaps((UINT_PTR) handle, &mixerCaps, sizeof(MIXERCAPS)) == MMSYSERR_NOERROR) {
|
||||
if (mixerGetDevCapsW((UINT_PTR) handle, &mixerCaps, sizeof(MIXERCAPSW)) == MMSYSERR_NOERROR) {
|
||||
ret = mixerCaps.cDestinations;
|
||||
}
|
||||
return ret;
|
||||
|
||||
Reference in New Issue
Block a user