Ver código fonte

cmDspBuiltIn.c Added useThreadFl to WaveTable DSP Object.

useThreadFl allows the background file loading thread to be enabled and disabled.
master
kpl 11 anos atrás
pai
commit
d7578b9866
1 arquivos alterados com 6 adições e 3 exclusões
  1. 6
    3
      dsp/cmDspBuiltIn.c

+ 6
- 3
dsp/cmDspBuiltIn.c Ver arquivo

2778
   unsigned       onSymId;
2778
   unsigned       onSymId;
2779
   unsigned       offSymId;
2779
   unsigned       offSymId;
2780
   unsigned       doneSymId;
2780
   unsigned       doneSymId;
2781
+  bool           useThreadFl;
2781
  } cmDspWaveTable_t;
2782
  } cmDspWaveTable_t;
2782
 
2783
 
2783
 bool _cmDspWaveTableThreadFunc( void* param);
2784
 bool _cmDspWaveTableThreadFunc( void* param);
2823
   cmDspSetDefaultDouble(ctx, &p->inst, kGainWtId,  0,     1.0 );
2824
   cmDspSetDefaultDouble(ctx, &p->inst, kGainWtId,  0,     1.0 );
2824
   cmDspSetDefaultUInt(  ctx, &p->inst, kFIdxWtId,  0,     0 );
2825
   cmDspSetDefaultUInt(  ctx, &p->inst, kFIdxWtId,  0,     0 );
2825
 
2826
 
2827
+  p->useThreadFl = false;
2828
+
2826
   return &p->inst;
2829
   return &p->inst;
2827
 }
2830
 }
2828
 
2831
 
3069
   if( p->loadFileFl )
3072
   if( p->loadFileFl )
3070
     return cmDspInstErr(ctx,&p->inst,kInvalidStateDspRC,"The audio file '%s' was not loaded because another file is in the process of being loaded.",cmStringNullGuard(fn));  
3073
     return cmDspInstErr(ctx,&p->inst,kInvalidStateDspRC,"The audio file '%s' was not loaded because another file is in the process of being loaded.",cmStringNullGuard(fn));  
3071
 
3074
 
3072
-  if(cmThreadIsValid(p->thH) == false)
3075
+  if(p->useThreadFl && cmThreadIsValid(p->thH) == false)
3073
     cmThreadCreate(&p->thH,_cmDspWaveTableThreadFunc,p,ctx->rpt);
3076
     cmThreadCreate(&p->thH,_cmDspWaveTableThreadFunc,p,ctx->rpt);
3074
 
3077
 
3075
-  if( cmThreadIsValid(p->thH) == false )
3078
+  if(p->useThreadFl && cmThreadIsValid(p->thH) == false )
3076
     return cmDspInstErr(ctx,&p->inst,kInvalidStateDspRC,"The audio file '%s' was not loaded because the audio load thread is invalid.",cmStringNullGuard(fn));
3079
     return cmDspInstErr(ctx,&p->inst,kInvalidStateDspRC,"The audio file '%s' was not loaded because the audio load thread is invalid.",cmStringNullGuard(fn));
3077
 
3080
 
3078
   p->loadFileFl = true;
3081
   p->loadFileFl = true;
3080
   cmDspSetUInt(ctx,&p->inst,kShapeWtId,kSilenceWtId);
3083
   cmDspSetUInt(ctx,&p->inst,kShapeWtId,kSilenceWtId);
3081
   cmDspSetStrcz(ctx,&p->inst,kFnWtId,fn);
3084
   cmDspSetStrcz(ctx,&p->inst,kFnWtId,fn);
3082
 
3085
 
3083
-  if(1)
3086
+  if( p->useThreadFl == false )
3084
   {
3087
   {
3085
     // use non-threaded load
3088
     // use non-threaded load
3086
     if((rc = _cmDspWaveTableInitAudioFile(p->ctx,p)) != kOkDspRC )
3089
     if((rc = _cmDspWaveTableInitAudioFile(p->ctx,p)) != kOkDspRC )

Carregando…
Cancelar
Salvar