ADLplug
ADLplug copied to clipboard
Dynamic measurement thread issue
The InitTables
method of Dosbox to initialize global data has a defect when using the emulator on multiple threads.
Description of the problem:
- have 2 threads doing
Init()
each around the same time - T1 has entered
InitTables()
, has set doneTables = true - T2 takes over,
InitTables()
skips because ofdoneTables
flag - T2 generates bad audio because tables are not filled
Also, there must be a synchronization to ensure correct sequencing of read and write. Mutex will be fine.
(EDIT I don't use several threads in the worker for measuring so it's not affected; but needed for libADLMIDI's genadldata and I'll copy the changes here)