File tree Expand file tree Collapse file tree 1 file changed +10
-3
lines changed
Expand file tree Collapse file tree 1 file changed +10
-3
lines changed Original file line number Diff line number Diff line change @@ -42,8 +42,8 @@ onmessage = function(e) {
4242} ;
4343
4444let workerId = "webrtc-vad-worker-" + Math . round ( Math . random ( ) * 1000000 ) + "-" + Date . now ( ) ;
45- // let doDebug = false;
46- // let wasConstructorCalled = false;
45+ let doDebug = false ;
46+ let wasConstructorCalled = false ;
4747//let isReadyForProcessing = false; //TODO: implement
4848
4949let inputSampleRate ;
@@ -140,6 +140,13 @@ function ready(){
140140}
141141
142142function constructWorker ( options ) {
143+ if ( wasConstructorCalled ) {
144+ console . error ( "VadModuleError - Constructor was called twice! 2nd call was ignored but this should be fixed!" , "-" , workerId ) ; //DEBUG
145+ return ;
146+ } else {
147+ wasConstructorCalled = true ;
148+ }
149+ doDebug = options . setup . doDebug || false ;
143150 inputSampleRate = options . setup . inputSampleRate || options . setup . ctxInfo . targetSampleRate || options . setup . ctxInfo . sampleRate ;
144151 channelCount = 1 ; //options.setup.channelCount || 1; //TODO: only MONO atm
145152 inputSampleSize = options . setup . inputSampleSize || 512 ;
@@ -184,7 +191,7 @@ function constructWorker(options) {
184191 init ( ) ;
185192
186193 function onVadLog ( msg ) {
187- console . error ( "VadModuleLog -" , msg ) ; //DEBUG (use postMessage?)
194+ if ( doDebug ) console . error ( "VadModuleLog -" , msg ) ; //DEBUG (use postMessage?)
188195 }
189196 function onVadError ( msg ) {
190197 console . error ( "VadModuleError -" , msg ) ;
You can’t perform that action at this time.
0 commit comments