diff options
author | JP Cimalando <jpcima@users.noreply.github.com> | 2019-07-01 17:55:12 +0200 |
---|---|---|
committer | JP Cimalando <jpcima@users.noreply.github.com> | 2019-07-01 17:55:12 +0200 |
commit | 35c7fd9d8320a9d97723591eb6ee48974f6be528 (patch) | |
tree | c539b7f29fcbb3e4a4f774ce848b947a8a3bf412 | |
parent | b56ef6bb0e42f9417b65242142cfa02a38e781e6 (diff) | |
download | libADLMIDI-35c7fd9d8320a9d97723591eb6ee48974f6be528.tar.gz libADLMIDI-35c7fd9d8320a9d97723591eb6ee48974f6be528.tar.bz2 libADLMIDI-35c7fd9d8320a9d97723591eb6ee48974f6be528.zip |
dosbox: thread-safe global initialization
-rw-r--r-- | src/chips/dosbox/dbopl.cpp | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/chips/dosbox/dbopl.cpp b/src/chips/dosbox/dbopl.cpp index d1ab82f..5b4bf53 100644 --- a/src/chips/dosbox/dbopl.cpp +++ b/src/chips/dosbox/dbopl.cpp @@ -1507,11 +1507,15 @@ void Chip::Setup( Bit32u rate ) { } } -static bool doneTables = false; +static volatile bool doneTables = false; +static Mutex mutexTables; + void InitTables( void ) { if ( doneTables ) return; - doneTables = true; + MutexHolder lock( mutexTables ); + if ( doneTables ) + return; #if ( DBOPL_WAVE == WAVE_HANDLER ) || ( DBOPL_WAVE == WAVE_TABLELOG ) //Exponential volume table, same as the real adlib for ( int i = 0; i < 256; i++ ) { @@ -1661,6 +1665,7 @@ void InitTables( void ) { } } #endif + doneTables = true; } Bit32u Handler::WriteAddr( Bit32u port, Bit8u val ) { |