From 2ccd818b55c6623a06b217f55eb23dd8ce4c53c4 Mon Sep 17 00:00:00 2001 From: kevin Date: Sun, 31 Mar 2013 22:13:07 -0700 Subject: [PATCH] cmApBuf.h/c: Limit the meter update parameter (meterMs) to the range 10-1000. --- cmApBuf.c | 7 ++++++- cmApBuf.h | 5 ++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/cmApBuf.c b/cmApBuf.c index cd4c449..ef3abf2 100644 --- a/cmApBuf.c +++ b/cmApBuf.c @@ -215,7 +215,7 @@ cmAbRC_t cmApBufInitialize( unsigned devCnt, unsigned meterMs ) _cmApBuf.devArray = cmMemAllocZ( cmApDev, devCnt ); _cmApBuf.devCnt = devCnt; - _cmApBuf.meterMs = meterMs; + cmApBufSetMeterMs(meterMs); return kOkAbRC; } @@ -451,6 +451,11 @@ cmAbRC_t cmApBufUpdate( unsigned cmApBufMeterMs() { return _cmApBuf.meterMs; } +void cmApBufSetMeterMs( unsigned meterMs ) +{ + _cmApBuf.meterMs = cmMin(1000,cmMax(10,meterMs)); +} + unsigned cmApBufChannelCount( unsigned devIdx, unsigned flags ) { if( devIdx == cmInvalidIdx ) diff --git a/cmApBuf.h b/cmApBuf.h index b2e06ca..ec016ce 100644 --- a/cmApBuf.h +++ b/cmApBuf.h @@ -46,7 +46,7 @@ extern "C" { /// Allocate and initialize an audio buffer. /// devCnt - count of devices this buffer will handle. - /// meterMs - length of the meter buffers in milliseconds + /// meterMs - length of the meter buffers in milliseconds (automatically limit to the range:10 to 1000) cmAbRC_t cmApBufInitialize( unsigned devCnt, unsigned meterMs ); /// Deallocate and release any resource held by an audio buffer allocated via cmApBufInitialize(). @@ -106,6 +106,9 @@ extern "C" { /// Return the meter window period as set by cmApBufInitialize() unsigned cmApBufMeterMs(); + + // Set the meter update period. THis function limits the value to between 10 and 1000. + void cmApBufSetMeterMs( unsigned meterMs ); /// Returns the channel count set via cmApBufSetup(). unsigned cmApBufChannelCount( unsigned devIdx, unsigned flags );