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

This commit is contained in:
kevin 2013-03-31 22:13:07 -07:00
parent 81e55deee4
commit 2ccd818b55
2 changed files with 10 additions and 2 deletions

View File

@ -215,7 +215,7 @@ cmAbRC_t cmApBufInitialize( unsigned devCnt, unsigned meterMs )
_cmApBuf.devArray = cmMemAllocZ( cmApDev, devCnt ); _cmApBuf.devArray = cmMemAllocZ( cmApDev, devCnt );
_cmApBuf.devCnt = devCnt; _cmApBuf.devCnt = devCnt;
_cmApBuf.meterMs = meterMs; cmApBufSetMeterMs(meterMs);
return kOkAbRC; return kOkAbRC;
} }
@ -451,6 +451,11 @@ cmAbRC_t cmApBufUpdate(
unsigned cmApBufMeterMs() unsigned cmApBufMeterMs()
{ return _cmApBuf.meterMs; } { return _cmApBuf.meterMs; }
void cmApBufSetMeterMs( unsigned meterMs )
{
_cmApBuf.meterMs = cmMin(1000,cmMax(10,meterMs));
}
unsigned cmApBufChannelCount( unsigned devIdx, unsigned flags ) unsigned cmApBufChannelCount( unsigned devIdx, unsigned flags )
{ {
if( devIdx == cmInvalidIdx ) if( devIdx == cmInvalidIdx )

View File

@ -46,7 +46,7 @@ extern "C" {
/// Allocate and initialize an audio buffer. /// Allocate and initialize an audio buffer.
/// devCnt - count of devices this buffer will handle. /// 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 ); cmAbRC_t cmApBufInitialize( unsigned devCnt, unsigned meterMs );
/// Deallocate and release any resource held by an audio buffer allocated via cmApBufInitialize(). /// 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() /// Return the meter window period as set by cmApBufInitialize()
unsigned cmApBufMeterMs(); 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(). /// Returns the channel count set via cmApBufSetup().
unsigned cmApBufChannelCount( unsigned devIdx, unsigned flags ); unsigned cmApBufChannelCount( unsigned devIdx, unsigned flags );