MrSapps/alive

Crash if closed while audio thread is busy

Closed this issue · 1 comments

Main thread:

Alive.exe!std::recursive_mutex::~recursive_mutex()  C++
Alive.exe!AliveAudio::~AliveAudio() C++
Alive.exe!Sound::~Sound() Line 50   C++
Alive.exe!Sound::`scalar deleting destructor'(unsigned int) C++
Alive.exe!std::default_delete<Sound>::operator()(Sound * _Ptr) Line 1200    C++
Alive.exe!std::unique_ptr<Sound,std::default_delete<Sound> >::reset(Sound * _Ptr) Line 1484 C++
Alive.exe!Engine::~Engine() Line 101    C++
Alive.exe!SDL_main(int __formal, char * * __formal) Line 30 C++
Alive.exe!main(int argc, char * * argv) Line 140    C

Audio call back thread:

Alive.exe!stk::OnePole::tick(double input) Line 83  C++
Alive.exe!stk::FreeVerb::tick(double inputL, double inputR, unsigned int channel) Line 200  C++
Alive.exe!AliveAudio::AliveRenderAudio(float * AudioStream, int StreamLength) Line 171  C++
Alive.exe!AliveAudio::Play(unsigned char * stream, unsigned int len) Line 201   C++
Alive.exe!SdlAudioWrapper::AudioCallback(unsigned char * stream, int len) Line 141  C++
Alive.exe!SdlAudioWrapper::StaticAudioCallback(void * udata, unsigned char * stream, int len) Line 133  C++
SDL2.dll!6c743e0d() Unknown

The audio thread has taken the lock which the main thread has gone and destroyed. We need a clean way to shutdown - such as shutdown SDL audio call back, then take the lock to ensure the call back has exited, then destruct fully.

Seems to be fixed now.