Browse Source

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

master
kevin 11 years ago
parent
commit
2ccd818b55
2 changed files with 10 additions and 2 deletions
  1. 6
    1
      cmApBuf.c
  2. 4
    1
      cmApBuf.h

+ 6
- 1
cmApBuf.c View File

@@ -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 View File

@@ -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 );

Loading…
Cancel
Save