You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A fix for crash caused when loading save games on Windows under Doom 3. Found in snd_emitter.cpp. The issue is also in the fhDoom source. Just wanted to share, feel free to close the issue.
/*
===================
idSoundChannel::GatherChannelSamples
Will always return 44kHz samples for the given range, even if it deeply looped or
out of the range of the unlooped samples. Handles looping between multiple different
samples and leadins
===================
*/
void idSoundChannel::GatherChannelSamples(int sampleOffset44k, int sampleCount44k, float *dest) const {
float *dest_p = dest;
int len;
// Check for null decoder
if (!decoder) {
// Fill destination with zeroes if decoder is null
memset(dest_p, 0, sampleCount44k * sizeof(dest_p[0]));
return;
}
// Negative offset times will zero-fill
if (sampleOffset44k < 0) {
len = -sampleOffset44k;
if (len > sampleCount44k) {
len = sampleCount44k;
}
memset(dest_p, 0, len * sizeof(dest_p[0]));
dest_p += len;
sampleCount44k -= len;
sampleOffset44k += len;
}
// Handle lead-in sample
idSoundSample *leadin = leadinSample;
if (!leadin || sampleOffset44k < 0 || sampleCount44k <= 0) {
memset(dest_p, 0, sampleCount44k * sizeof(dest_p[0]));
return;
}
if (sampleOffset44k < leadin->LengthIn44kHzSamples()) {
len = leadin->LengthIn44kHzSamples() - sampleOffset44k;
if (len > sampleCount44k) {
len = sampleCount44k;
}
// Decode the sample if decoder is valid
decoder->Decode(leadin, sampleOffset44k, len, dest_p);
dest_p += len;
sampleCount44k -= len;
sampleOffset44k += len;
}
// Zero-fill if not looping
if (!soundShader || !(parms.soundShaderFlags & SSF_LOOPING)) {
memset(dest_p, 0, sampleCount44k * sizeof(dest_p[0]));
return;
}
// Looping sample handling
idSoundSample *loop = soundShader->entries[0];
if (!loop) {
memset(dest_p, 0, sampleCount44k * sizeof(dest_p[0]));
return;
}
sampleOffset44k -= leadin->LengthIn44kHzSamples();
while (sampleCount44k > 0) {
int totalLen = loop->LengthIn44kHzSamples();
sampleOffset44k %= totalLen;
len = totalLen - sampleOffset44k;
if (len > sampleCount44k) {
len = sampleCount44k;
}
// Decode the loop sample
decoder->Decode(loop, sampleOffset44k, len, dest_p);
dest_p += len;
sampleCount44k -= len;
sampleOffset44k += len;
}
}
The text was updated successfully, but these errors were encountered:
IcyChills
changed the title
Small fix to for game load crashes on Windows
Small fix for game load crashes on Windows
Oct 28, 2024
A fix for crash caused when loading save games on Windows under Doom 3. Found in snd_emitter.cpp. The issue is also in the fhDoom source. Just wanted to share, feel free to close the issue.
The text was updated successfully, but these errors were encountered: