Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Possible bug in audioPlaySoundFrame #329

Closed
Gerwin2k opened this issue Sep 24, 2023 · 3 comments
Closed

Possible bug in audioPlaySoundFrame #329

Gerwin2k opened this issue Sep 24, 2023 · 3 comments

Comments

@Gerwin2k
Copy link

I was building a Win32 version of the latest source. There was a consistent crash whenever the first sound was supposed to be played. (music was fine). I bisected the cause to be introduced in February 2023. Below is the cause commented out, and replaced with the earlier logic, which does seem to work: no crashes, sound is fine. Actually it seems to sound a bit better then the current official x64 binary, where i hear some sound interruptions.

TFE_Jedi\IMuse\imDigitalSound.cpp / function audioPlaySoundFrame

// Read additional samples, but only update the offset by the base number.
// This is required since the results might be interpolated on upsample.
const s32 baseReadSize = min(bufferSize,                     data->chunkSize);
const s32     readSize = min(bufferSize+IM_AUDIO_OVERSAMPLE, data->chunkSize);
s_audioData = ImInternalGetSoundData(sound->soundId) + data->offset;
// GB 2023 - guilty change for audio crashes since February 2023
//audioProcessFrame(s_audioData,     readSize, offset, sound->volume, sound->pan);
audioProcessFrame(s_audioData, baseReadSize, offset, sound->volume, sound->pan);
@classilla
Copy link

This seems to fix #266 for me. Nice find.

@luciusDXL
Copy link
Owner

Thanks for the report. Though it is supposed to read those extra samples in order to properly upscale the audio. So I will have to look into it further.

@luciusDXL
Copy link
Owner

luciusDXL commented Sep 25, 2023

Ok, I found the issue. The oversampling was correct, but the buffer was increased by the oversample amount - but these are supposed to be stereo samples, which means the value should have been increased by x2. So it was reading/writing past the end of the buffer... Thanks for pointing out the issue, it was probably responsible for "random" crashes even on Windows.

This should be fixed in master now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants