Parcourir la source

cmApBuf.h/c: Limit the meter update parameter (meterMs) to the range 10-1000.

master
kevin il y a 11 ans
Parent
révision
2ccd818b55
2 fichiers modifiés avec 10 ajouts et 2 suppressions
  1. 6
    1
      cmApBuf.c
  2. 4
    1
      cmApBuf.h

+ 6
- 1
cmApBuf.c Voir le fichier

@@ -215,7 +215,7 @@ cmAbRC_t cmApBufInitialize( unsigned devCnt, unsigned meterMs )
215 215
 
216 216
   _cmApBuf.devArray        = cmMemAllocZ( cmApDev, devCnt );
217 217
   _cmApBuf.devCnt          = devCnt;
218
-  _cmApBuf.meterMs         = meterMs;
218
+  cmApBufSetMeterMs(meterMs);
219 219
   return kOkAbRC;
220 220
 }
221 221
 
@@ -451,6 +451,11 @@ cmAbRC_t cmApBufUpdate(
451 451
 unsigned cmApBufMeterMs()
452 452
 { return _cmApBuf.meterMs; }
453 453
 
454
+void     cmApBufSetMeterMs( unsigned meterMs )
455
+{
456
+  _cmApBuf.meterMs = cmMin(1000,cmMax(10,meterMs));
457
+}
458
+
454 459
 unsigned cmApBufChannelCount( unsigned devIdx, unsigned flags )
455 460
 {
456 461
   if( devIdx == cmInvalidIdx )

+ 4
- 1
cmApBuf.h Voir le fichier

@@ -46,7 +46,7 @@ extern "C" {
46 46
 
47 47
   /// Allocate and initialize an audio buffer.
48 48
   /// devCnt - count of devices this buffer will handle.
49
-  /// meterMs - length of the meter buffers in milliseconds
49
+  /// meterMs - length of the meter buffers in milliseconds (automatically limit to the range:10 to 1000)
50 50
   cmAbRC_t cmApBufInitialize( unsigned devCnt, unsigned meterMs );
51 51
 
52 52
   /// Deallocate and release any resource held by an audio buffer allocated via cmApBufInitialize().
@@ -106,6 +106,9 @@ extern "C" {
106 106
 
107 107
   /// Return the meter window period as set by cmApBufInitialize()
108 108
   unsigned cmApBufMeterMs();
109
+  
110
+  // Set the meter update period. THis function limits the value to between 10 and 1000.
111
+  void     cmApBufSetMeterMs( unsigned meterMs );
109 112
 
110 113
   /// Returns the channel count set via cmApBufSetup().
111 114
   unsigned cmApBufChannelCount( unsigned devIdx, unsigned flags );

Chargement…
Annuler
Enregistrer