From 54ad69ebad78f2d9fcc65ab898fb83973b3633ed Mon Sep 17 00:00:00 2001 From: Randy Heit Date: Tue, 6 Nov 2012 05:35:43 +0000 Subject: [PATCH] - Call init_tables() directly from the YM3812 constructor. SVN r3944 (trunk) --- src/oplsynth/fmopl.cpp | 43 ++++++++++-------------------------------- 1 file changed, 10 insertions(+), 33 deletions(-) diff --git a/src/oplsynth/fmopl.cpp b/src/oplsynth/fmopl.cpp index 1bfe1dd5f..e1ade9e43 100644 --- a/src/oplsynth/fmopl.cpp +++ b/src/oplsynth/fmopl.cpp @@ -1077,12 +1077,19 @@ INLINE void OPL_CALC_RH( OPL_CH *CH, unsigned int noise ) /* generic table initialize */ -static int init_tables(void) +static void init_tables(void) { signed int i,x; signed int n; double o,m; + /* We only need to do this once. */ + static bool did_init = false; + + if (did_init) + { + return; + } for (x=0; x>2)]; } - return 1; + did_init = true; } static void OPL_initalize(FM_OPL *OPL) @@ -1512,30 +1519,6 @@ static void OPLWriteReg(FM_OPL *OPL, int r, int v) } } -/* lock/unlock for common table */ -static int OPL_LockTable(void) -{ - num_lock++; - if(num_lock>1) return 0; - - /* first time */ - - /* allocate total level table (128kb space) */ - if( !init_tables() ) - { - num_lock--; - return -1; - } - - return 0; -} - -static void OPL_UnLockTable(void) -{ - if(num_lock) num_lock--; - if(num_lock) return; -} - static void OPLResetChip(FM_OPL *OPL) { int c,s; @@ -1579,7 +1562,7 @@ public: /* Create one of virtual YM3812 */ YM3812(bool stereo) { - if (OPL_LockTable() == -1) return; + init_tables(); /* clear */ memset(&Chip, 0, sizeof(Chip)); @@ -1592,12 +1575,6 @@ public: Reset(); } - /* Destroy one of virtual YM3812 */ - ~YM3812() - { - OPL_UnLockTable(); - } - /* YM3812 I/O interface */ int Write(int a, int v) {