Fix WAV export crash caused by uninitialized variables #367
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This pull request aims to fix random crashes the first time you export a WAV file from FamiTracker.
bool CSoundGen::m_bStoppingRenderfailed to be initialized. If it happened to be nonzero,(audio) CSoundGen::OnIdle()would count downm_iDelayedEndto 0 and then callStopRendering()on every frame, which would fail becauseIsRendering()is false. (This error was silent on release builds before #353, but now dumps a log and blocks the audio thread with a dialog.)The crash happens when the user initiates a render on the GUI thread (setting
m_pWaveFileandm_bRequestRenderStart). While the audio thread is looping,OnIdle() → StopRendering()could succeed and erasem_pWaveFilebefore(audio) CSoundGen::DispatchGuiMessage()processesWM_USER_START_RENDERfrom the GUI. Attempting to render withoutm_pWaveFilewould crash.Fix this by initializing
CSoundGen::m_bStoppingRender, as well as other flags that the code doesn't access immediately but I don't want to leave uninitialized. I didn't initialize everything because I don't understand the existing code.Crash log:
This pull request improves upon and supercedes #272.
Also update the logging infrastructure to "Don't hold mutex during WAV export error dialog".
Changes in this PR: