Browse Source

cmDspFx.c : Added missing va_end() to match va_copy().

master
kevin 11 years ago
parent
commit
681865e04b
1 changed files with 47 additions and 10 deletions
  1. 47
    10
      dsp/cmDspFx.c

+ 47
- 10
dsp/cmDspFx.c View File

199
 cmDspInst_t*  _cmDspMtDelayAlloc(cmDspCtx_t* ctx, cmDspClass_t* classPtr, unsigned storeSymId, unsigned instSymId, unsigned id, unsigned va_cnt, va_list vl )
199
 cmDspInst_t*  _cmDspMtDelayAlloc(cmDspCtx_t* ctx, cmDspClass_t* classPtr, unsigned storeSymId, unsigned instSymId, unsigned id, unsigned va_cnt, va_list vl )
200
 {
200
 {
201
   va_list vl1;
201
   va_list vl1;
202
-  va_copy(vl1,vl);
203
 
202
 
204
   cmDspVarArg_t args[] =
203
   cmDspVarArg_t args[] =
205
   {
204
   {
217
     return NULL;
216
     return NULL;
218
   }    
217
   }    
219
 
218
 
219
+  va_copy(vl1,vl);
220
+
220
   unsigned      reqArgCnt    = 3;
221
   unsigned      reqArgCnt    = 3;
221
   unsigned      fixArgCnt    = sizeof(args)/sizeof(args[0]);
222
   unsigned      fixArgCnt    = sizeof(args)/sizeof(args[0]);
222
   unsigned      tapCnt       = (va_cnt - reqArgCnt)/2;
223
   unsigned      tapCnt       = (va_cnt - reqArgCnt)/2;
261
     cmDspSetDefaultDouble(ctx,&p->inst,baseGainMtId+i,  0.0, gainV[i]);
262
     cmDspSetDefaultDouble(ctx,&p->inst,baseGainMtId+i,  0.0, gainV[i]);
262
   }
263
   }
263
   
264
   
264
-
265
+  va_end(vl1);
265
   return &p->inst;
266
   return &p->inst;
266
 }
267
 }
267
 
268
 
985
   va_list             vl1;
986
   va_list             vl1;
986
   unsigned            i;
987
   unsigned            i;
987
 
988
 
988
-  // copy the va_list so that it can be used again in cmDspInstAlloc()
989
-  va_copy(vl1,vl);
990
 
989
 
991
   // verify that at least one var arg exists
990
   // verify that at least one var arg exists
992
   if( va_cnt < 1 )
991
   if( va_cnt < 1 )
994
     cmDspClassErr(ctx,classPtr,kInvalidArgDspRC,"The AutoGain constructor must be given the audio channel count as its first argument.");
993
     cmDspClassErr(ctx,classPtr,kInvalidArgDspRC,"The AutoGain constructor must be given the audio channel count as its first argument.");
995
     return NULL;
994
     return NULL;
996
   }    
995
   }    
996
+  // copy the va_list so that it can be used again in cmDspInstAlloc()
997
+  va_copy(vl1,vl);
997
 
998
 
998
   // get the first var arg which should be a filename
999
   // get the first var arg which should be a filename
999
   unsigned chCnt = va_arg(vl,unsigned);
1000
   unsigned chCnt = va_arg(vl,unsigned);
1001
   if( chCnt == 0 )
1002
   if( chCnt == 0 )
1002
   {
1003
   {
1003
     cmDspClassErr(ctx,classPtr,kInvalidArgDspRC,"The AutoGain constructor requires at least 1 audio channel.");
1004
     cmDspClassErr(ctx,classPtr,kInvalidArgDspRC,"The AutoGain constructor requires at least 1 audio channel.");
1005
+    va_end(vl1);
1004
     return NULL;
1006
     return NULL;
1005
   }
1007
   }
1006
 
1008
 
1038
   cmDspSetDefaultSymbol( ctx, &p->inst, kSelAgId, p->cancelSymId );
1040
   cmDspSetDefaultSymbol( ctx, &p->inst, kSelAgId, p->cancelSymId );
1039
   cmDspSetDefaultInt(    ctx, &p->inst, kIdAgId,  0, cmInvalidId );
1041
   cmDspSetDefaultInt(    ctx, &p->inst, kIdAgId,  0, cmInvalidId );
1040
 
1042
 
1043
+   va_end(vl1);
1044
+ 
1041
   return &p->inst;
1045
   return &p->inst;
1042
 }
1046
 }
1043
 
1047
 
1504
   for(i=0; i<chCnt; ++i)
1508
   for(i=0; i<chCnt; ++i)
1505
     cmDspSetDefaultBool( ctx, &p->inst, stateBaseXfId+i, false, false );
1509
     cmDspSetDefaultBool( ctx, &p->inst, stateBaseXfId+i, false, false );
1506
 
1510
 
1511
+  va_end(vl1);
1512
+
1507
   return &p->inst;
1513
   return &p->inst;
1508
 }
1514
 }
1509
 
1515
 
1900
 
1906
 
1901
   if( cmDspRsrcUIntArray( ctx->dspH, &chCnt, &enaV, rsrc, NULL ) != kOkDspRC )
1907
   if( cmDspRsrcUIntArray( ctx->dspH, &chCnt, &enaV, rsrc, NULL ) != kOkDspRC )
1902
   {
1908
   {
1909
+    va_end(vl1);
1903
     cmDspClassErr(ctx,classPtr,kInvalidArgDspRC,"The chord detector channel index resource '%s' could not be read.",cmStringNullGuard(rsrc));
1910
     cmDspClassErr(ctx,classPtr,kInvalidArgDspRC,"The chord detector channel index resource '%s' could not be read.",cmStringNullGuard(rsrc));
1904
     return NULL;
1911
     return NULL;
1905
   }
1912
   }
1942
   p->chRmsV        = cmMemAllocZ(cmReal_t, chCnt);
1949
   p->chRmsV        = cmMemAllocZ(cmReal_t, chCnt);
1943
   p->chEnaV        = enaV;
1950
   p->chEnaV        = enaV;
1944
 
1951
 
1952
+  va_end(vl1);
1945
 
1953
 
1946
   return &p->inst;
1954
   return &p->inst;
1947
 }
1955
 }
2202
   }
2210
   }
2203
 
2211
 
2204
   va_list vl1;
2212
   va_list vl1;
2205
-  va_copy(vl1,vl);
2206
 
2213
 
2207
   unsigned        CD0chanN = 0;
2214
   unsigned        CD0chanN = 0;
2208
   unsigned        CD1chanN = 0;
2215
   unsigned        CD1chanN = 0;
2223
     return NULL;
2230
     return NULL;
2224
   }
2231
   }
2225
 
2232
 
2233
+  va_copy(vl1,vl);
2226
 
2234
 
2227
   unsigned chCnt         = va_arg(vl,unsigned);
2235
   unsigned chCnt         = va_arg(vl,unsigned);
2228
   unsigned fixArgCnt     = sizeof(args)/sizeof(args[0]);
2236
   unsigned fixArgCnt     = sizeof(args)/sizeof(args[0]);
2297
     cmDspSetDefaultBool(  ctx, &p->inst, gate4BaseNsId+i, false, p->chGroupV[i] == kGroupNonNsId );   
2305
     cmDspSetDefaultBool(  ctx, &p->inst, gate4BaseNsId+i, false, p->chGroupV[i] == kGroupNonNsId );   
2298
   }
2306
   }
2299
 
2307
 
2308
+  va_end(vl1);
2309
+
2300
   return &p->inst;
2310
   return &p->inst;
2301
 }
2311
 }
2302
 
2312
 
2903
   if( inPortCnt == 0 )
2913
   if( inPortCnt == 0 )
2904
   {
2914
   {
2905
     cmDspClassErr(ctx,classPtr,kVarNotValidDspRC,"The 'ScalarOp' constructor input port argument must be non-zero.");
2915
     cmDspClassErr(ctx,classPtr,kVarNotValidDspRC,"The 'ScalarOp' constructor input port argument must be non-zero.");
2906
-    return NULL;
2916
+    goto errLabel;
2907
   }
2917
   }
2908
 
2918
 
2909
   // locate the operation function
2919
   // locate the operation function
2917
   if( fp == NULL )
2927
   if( fp == NULL )
2918
   {
2928
   {
2919
     cmDspClassErr(ctx,classPtr,kVarNotValidDspRC,"The 'ScalarOp' constructor operation string id '%s' did not match a known operation.",cmStringNullGuard(opIdStr));
2929
     cmDspClassErr(ctx,classPtr,kVarNotValidDspRC,"The 'ScalarOp' constructor operation string id '%s' did not match a known operation.",cmStringNullGuard(opIdStr));
2920
-    return NULL;
2930
+    goto errLabel;
2921
   }
2931
   }
2922
 
2932
 
2923
   // setup the fixed args
2933
   // setup the fixed args
2937
   cmDspArgSetupNull( a+argCnt); // set terminating arg. flag
2947
   cmDspArgSetupNull( a+argCnt); // set terminating arg. flag
2938
 
2948
 
2939
   if((p = cmDspInstAlloc(cmDspScalarOp_t,ctx,classPtr,a,instSymId,id,storeSymId,2,vl1)) == NULL )
2949
   if((p = cmDspInstAlloc(cmDspScalarOp_t,ctx,classPtr,a,instSymId,id,storeSymId,2,vl1)) == NULL )
2940
-    return NULL;
2950
+    goto errLabel;
2941
 
2951
 
2942
   for(i=0; i<inPortCnt; ++i)
2952
   for(i=0; i<inPortCnt; ++i)
2943
     cmDspSetDefaultDouble(ctx,&p->inst,kBaseOpdSoId+i,0.0,dfltVal[i]);
2953
     cmDspSetDefaultDouble(ctx,&p->inst,kBaseOpdSoId+i,0.0,dfltVal[i]);
2945
   p->inPortCnt = inPortCnt;
2955
   p->inPortCnt = inPortCnt;
2946
   p->func      = fp;
2956
   p->func      = fp;
2947
   
2957
   
2958
+  va_end(vl1);
2948
 
2959
 
2949
   return &p->inst;
2960
   return &p->inst;
2961
+
2962
+ errLabel:
2963
+  va_end(vl1);
2964
+
2965
+  return NULL;
2950
 }
2966
 }
2951
 
2967
 
2952
 
2968
 
3053
   cmDspArgSetupNull( a+argCnt); // set terminating arg. flag
3069
   cmDspArgSetupNull( a+argCnt); // set terminating arg. flag
3054
 
3070
 
3055
   if((p = cmDspInstAlloc(cmDspGroupSel_t,ctx,classPtr,a,instSymId,id,storeSymId,va_cnt,vl1)) == NULL )
3071
   if((p = cmDspInstAlloc(cmDspGroupSel_t,ctx,classPtr,a,instSymId,id,storeSymId,va_cnt,vl1)) == NULL )
3072
+  {
3073
+    va_end(vl1);
3056
     return NULL;
3074
     return NULL;
3057
-    
3075
+  }
3076
+ 
3058
   p->chCnt       = chCnt;
3077
   p->chCnt       = chCnt;
3059
   p->groupCnt    = groupCnt;
3078
   p->groupCnt    = groupCnt;
3060
   p->gsp         = cmGroupSelAlloc(ctx->cmProcCtx, NULL, 0, 0, 0 );
3079
   p->gsp         = cmGroupSelAlloc(ctx->cmProcCtx, NULL, 0, 0, 0 );
3069
   for(i=0; i<outCnt; ++i)
3088
   for(i=0; i<outCnt; ++i)
3070
     cmDspSetDefaultBool( ctx, &p->inst, baseOutGsId, false, false );
3089
     cmDspSetDefaultBool( ctx, &p->inst, baseOutGsId, false, false );
3071
 
3090
 
3091
+  va_end(vl1);
3092
+
3072
   return &p->inst;
3093
   return &p->inst;
3073
 }
3094
 }
3074
 
3095
 
3216
   for(i=0; i<outChCnt; ++i)
3237
   for(i=0; i<outChCnt; ++i)
3217
     cmDspSetDefaultDouble( ctx, &p->inst, baseGainNmId + i, 0.0, 0.0 );
3238
     cmDspSetDefaultDouble( ctx, &p->inst, baseGainNmId + i, 0.0, 0.0 );
3218
 
3239
 
3240
+  va_end(vl1);
3241
+
3219
   return &p->inst;
3242
   return &p->inst;
3220
 }
3243
 }
3221
 
3244
 
3362
 
3385
 
3363
   p->inChCnt = inChCnt;
3386
   p->inChCnt = inChCnt;
3364
 
3387
 
3388
+  va_end(vl1);
3389
+
3365
   return &p->inst;
3390
   return &p->inst;
3366
 }
3391
 }
3367
 
3392
 
4656
 
4681
 
4657
   if( oChCnt > iChCnt )
4682
   if( oChCnt > iChCnt )
4658
   {
4683
   {
4684
+    va_end(vl1);
4659
     cmDspClassErr(ctx,classPtr,kVarArgParseFailDspRC,"The 'NofM' output count must be less than or equal to the input count.");
4685
     cmDspClassErr(ctx,classPtr,kVarArgParseFailDspRC,"The 'NofM' output count must be less than or equal to the input count.");
4660
     return NULL;
4686
     return NULL;
4661
   }
4687
   }
4721
 
4747
 
4722
   cmDspSetDefaultDouble( ctx, &p->inst, kXfadeMsNoId, 0.0, 15.0 );
4748
   cmDspSetDefaultDouble( ctx, &p->inst, kXfadeMsNoId, 0.0, 15.0 );
4723
 
4749
 
4750
+  va_end(vl1);
4751
+
4724
   return &p->inst;
4752
   return &p->inst;
4725
 }
4753
 }
4726
 
4754
 
5071
   cmDspSetDefaultBool(   ctx, &p->inst, kOutBool1oId, false, false );
5099
   cmDspSetDefaultBool(   ctx, &p->inst, kOutBool1oId, false, false );
5072
   cmDspSetDefaultSymbol( ctx, &p->inst, kOutSym1oId, cmInvalidId );
5100
   cmDspSetDefaultSymbol( ctx, &p->inst, kOutSym1oId, cmInvalidId );
5073
 
5101
 
5102
+  va_end(vl1);
5103
+
5074
   return &p->inst;
5104
   return &p->inst;
5075
 }
5105
 }
5076
 
5106
 
5221
   for(i=0; i<chCnt; ++i)
5251
   for(i=0; i<chCnt; ++i)
5222
     cmDspSetDefaultBool(   ctx, &p->inst, kBaseOut1uId + i, false, false );
5252
     cmDspSetDefaultBool(   ctx, &p->inst, kBaseOut1uId + i, false, false );
5223
 
5253
 
5254
+  va_end(vl1);
5255
+
5224
   return &p->inst;
5256
   return &p->inst;
5225
 }
5257
 }
5226
 
5258
 
5407
 
5439
 
5408
   if( va_cnt < 1 )
5440
   if( va_cnt < 1 )
5409
   {
5441
   {
5442
+    va_end(vl1);
5410
     cmDspClassErr(ctx,classPtr,kVarArgParseFailDspRC,"The 'PortToSym' constructor argument list must contain at least one symbol label.");
5443
     cmDspClassErr(ctx,classPtr,kVarArgParseFailDspRC,"The 'PortToSym' constructor argument list must contain at least one symbol label.");
5411
     return NULL;
5444
     return NULL;
5412
   }
5445
   }
5448
 
5481
 
5449
   cmDspSetDefaultSymbol(ctx,&p->inst,kOutPtsId,cmInvalidId);
5482
   cmDspSetDefaultSymbol(ctx,&p->inst,kOutPtsId,cmInvalidId);
5450
 
5483
 
5484
+  va_end(vl1);
5451
 
5485
 
5452
   return &p->inst;
5486
   return &p->inst;
5453
 }
5487
 }
5580
     cmDspSetDefaultSymbol( ctx, &p->inst, baseOutSymRtId+i, cmInvalidId );
5614
     cmDspSetDefaultSymbol( ctx, &p->inst, baseOutSymRtId+i, cmInvalidId );
5581
   }
5615
   }
5582
 
5616
 
5617
+  va_end(vl1);
5618
+
5583
   return &p->inst;
5619
   return &p->inst;
5584
 }
5620
 }
5585
 
5621
 
5741
 
5777
 
5742
   if( chCnt <= 0 )
5778
   if( chCnt <= 0 )
5743
   {
5779
   {
5780
+    va_end(vl1);
5744
     cmDspClassErr(ctx,classPtr,kInvalidArgDspRC,"The 'AvailCh' constructor must be given a positive channel count.");
5781
     cmDspClassErr(ctx,classPtr,kInvalidArgDspRC,"The 'AvailCh' constructor must be given a positive channel count.");
5745
     return NULL;
5782
     return NULL;
5746
   }
5783
   }
5771
   cmDspSetDefaultUInt( ctx, &p->inst, kModeAvId,  0, kExclusiveModeAvId );
5808
   cmDspSetDefaultUInt( ctx, &p->inst, kModeAvId,  0, kExclusiveModeAvId );
5772
   cmDspSetDefaultUInt( ctx, &p->inst, kChIdxAvId, 0, cmInvalidIdx );
5809
   cmDspSetDefaultUInt( ctx, &p->inst, kChIdxAvId, 0, cmInvalidIdx );
5773
   
5810
   
5774
-  
5811
+  va_end(vl1);
5775
 
5812
 
5776
   return &p->inst;
5813
   return &p->inst;
5777
 }
5814
 }

Loading…
Cancel
Save