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

+ 4
- 1
cmApBuf.h View File

46
 
46
 
47
   /// Allocate and initialize an audio buffer.
47
   /// Allocate and initialize an audio buffer.
48
   /// devCnt - count of devices this buffer will handle.
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
   cmAbRC_t cmApBufInitialize( unsigned devCnt, unsigned meterMs );
50
   cmAbRC_t cmApBufInitialize( unsigned devCnt, unsigned meterMs );
51
 
51
 
52
   /// Deallocate and release any resource held by an audio buffer allocated via cmApBufInitialize().
52
   /// Deallocate and release any resource held by an audio buffer allocated via cmApBufInitialize().
106
 
106
 
107
   /// Return the meter window period as set by cmApBufInitialize()
107
   /// Return the meter window period as set by cmApBufInitialize()
108
   unsigned cmApBufMeterMs();
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
   /// Returns the channel count set via cmApBufSetup().
113
   /// Returns the channel count set via cmApBufSetup().
111
   unsigned cmApBufChannelCount( unsigned devIdx, unsigned flags );
114
   unsigned cmApBufChannelCount( unsigned devIdx, unsigned flags );

Loading…
Cancel
Save