ITotalJustice / notorious_beeg

gba emulator written in c++23
https://notorious-beeg.netlify.app/
GNU General Public License v3.0
41 stars 4 forks source link

Sdl2 frontend hangs when loading a state that had audio disabled #85

Closed ITotalJustice closed 2 years ago

ITotalJustice commented 2 years ago

This is due to https://github.com/ITotalJustice/notorious_beeg/blob/master/src/core/scheduler.cpp#L156

Which only adds the event if it was previously enabled.

When audio is disabled, the sample event is removed, so it would not be re-enabled on state load, even if audio is now enabled.

This causes the sdl2 audio thread to loop until it has enough samples generated, but that will never be true.

To fix this, on state load, simply check the current state of audio and see if it is enabled or not, and add / remove the event accordingly.