Closed hypeastrum closed 5 years ago
Hi Andrey,
thanks for pointing this out. I have updated the destructor to not invoke any actions in the global namespace. Especially as disposal of the audio engine will have triggered this exact action indirectly by halting the rendering thread.
It highlights an interesting issue though: the controller being a class instance that sets flag in the static audio engine namespace. Whereas it would be interesting to run multiple sequencers at the same time, the purpose of the sequencer controller is to act as a single transport control (e.g. singleton only). The only real reason that this is a class rather than a namespace with static functions, is to allow easier exposure of its methods through JNI to Java (this is sadly not possible unless making these pure C...). The MWEngine.java class maintains a unique SequencerController through the MWEngine singleton instance not making this a problem in Java (after the fix mentioned above), leaves a bit of a curious design decision for those using C++ solely though...
https://github.com/igorski/MWEngine/blob/342f8f4a529e24b03b1466d5a6256897c1fd7567/src/main/cpp/sequencercontroller.cpp#L46
If stop the engine and dispose it in java (for example on activity stop), destructor of SequencerController will be called later with GC. So if we stop the activity and the open it again, next scenario became possible: