Most of the synchronization was too deep in the implementation so that it did not guard everything it needed.
Now each song has precisely one mutex which must be locked for all access to its internals - this is done in the public ZMusic interface
Currently all it contains are the MIDI sources and the MIDI devices, the rest needs to be reworked first.
# Conflicts:
# libraries/zmusic/i_module.cpp
# libraries/zmusic/i_module.h
# src/CMakeLists.txt
# src/i_module.cpp
# src/i_module.h
# src/sound/music/midi_cvars.cpp
# src/utility/i_module.cpp
# src/utility/i_module.h
# Conflicts:
# src/CMakeLists.txt
# src/sound/musicformats/music_opl.cpp
libraries/oplsynth/oplio.cpp:59:32: error: ‘memset’ was not declared in this scope
src/sound/mididevices/midi_cvars.cpp:43:31: error: expected initializer before ‘GetSystemDirectoryA’