[Scummvm-git-logs] scummvm master -> b259071965e3eac43fd0ecb674286a4f2a214fb6
NMIError
noreply at scummvm.org
Sat Apr 15 19:58:49 UTC 2023
This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
b259071965 SCI: Fix Coverity issue
Commit: b259071965e3eac43fd0ecb674286a4f2a214fb6
https://github.com/scummvm/scummvm/commit/b259071965e3eac43fd0ecb674286a4f2a214fb6
Author: Coen Rampen (crampen at gmail.com)
Date: 2023-04-15T21:58:13+02:00
Commit Message:
SCI: Fix Coverity issue
Changed paths:
engines/sci/sound/drivers/casio.cpp
diff --git a/engines/sci/sound/drivers/casio.cpp b/engines/sci/sound/drivers/casio.cpp
index c4fc37dd8c7..bfa47cf1a00 100644
--- a/engines/sci/sound/drivers/casio.cpp
+++ b/engines/sci/sound/drivers/casio.cpp
@@ -273,15 +273,6 @@ void MidiDriver_Casio::programChange(byte outputChannel, byte patchId, int8 sour
if (applyBassSwap && mappedInstrument == (_deviceType == MT_MT540 ? BASS_INSTRUMENT_MT540 : BASS_INSTRUMENT_CT460) && outputChannel != 2) {
_mutex.lock();
- // The original drivers do not stop all notes before swapping channels.
- // This could potentially cause hanging notes, so this is done here to
- // be safe. Instead, the original drivers swap out the registered
- // active notes between the channels. This does not accomplish anything
- // other than putting the driver state out of sync with the device
- // state.
- stopAllNotes(source, outputChannel);
- stopAllNotes(source, 2);
-
int currentDataChannel = -1;
int currentTargetDataChannel = -1;
for (int i = 0; i < MIDI_CHANNEL_COUNT; i++) {
@@ -291,14 +282,27 @@ void MidiDriver_Casio::programChange(byte outputChannel, byte patchId, int8 sour
currentTargetDataChannel = i;
}
}
- _channelMap[currentDataChannel] = 2;
- _channelMap[currentTargetDataChannel] = outputChannel;
- programChange(outputChannel, _instruments[2], source, applyRemapping, false);
+ // These data channels should always be mapped, but check it just in case.
+ if (currentDataChannel >= 0 && currentTargetDataChannel >= 0) {
+ // The original drivers do not stop all notes before swapping channels.
+ // This could potentially cause hanging notes, so this is done here to
+ // be safe. Instead, the original drivers swap out the registered
+ // active notes between the channels. This does not accomplish anything
+ // other than putting the driver state out of sync with the device
+ // state.
+ stopAllNotes(source, outputChannel);
+ stopAllNotes(source, 2);
- _mutex.unlock();
+ _channelMap[currentDataChannel] = 2;
+ _channelMap[currentTargetDataChannel] = outputChannel;
+
+ programChange(outputChannel, _instruments[2], source, applyRemapping, false);
- outputChannel = 2;
+ outputChannel = 2;
+ }
+
+ _mutex.unlock();
}
// Register the new instrument.
More information about the Scummvm-git-logs
mailing list