Copyright (C) Kevin Larke 2009-2020

This file is part of libcm.

libcm is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

libcm is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

See the GNU General Public License distributed with the libcm package or look here: .


cmAudioBuf : Obsolete audio buffer class. This class is superceded by cmApBuf.

enum
{
  kOkBaRC = cmOkRC
  kBufOverunBaRC,
  kBufUnderunBaRC
};

enum
{
  kInBaFl  = 0x01,
  kOutBaFl = 0x02
};

typedef cmRC_t cmBaRC_t;

cmBaRC_t cmAudioBufInit( cmCtx_t* ctx, unsigned devCnt );

cmBaRC_t cmAudioBufFinal();

cmBaRC_t cmAudioBufSetup(
unsigned devIdx,
unsigned cycleCnt,
unsigned inSubDevCnt,
unsigned inChCnt,
unsigned inFrameCnt,
unsigned outChCnt,
unsigned outFrameCnt,
unsigned outSubDevCnt );

// Called from the audio driver within incoming samples to store (inPktArray)
// and empty buffers (outPktArray) to fill with outgoin samples.
cmBaRC_t cmAudioBufUpdate(
cmApAudioPacket_t* inPktArray,   // /&lt full audio packets from incoming audio (from ADC)
unsigned           inPktCnt,     // /&lt count of incoming audio packets
cmApAudioPacket_t* outPktArray,  // /&lt empty audio packet for outgoing audio (to DAC) 
unsigned           outPktCnt     // /&lt count of outgoing audio packets
);

bool cmAudioBufIsDeviceReady( unsigned devIdx, unsigned flags );

cmBaRC_t cmAudioBufGet(     
unsigned devIdx, 
unsigned flags, 
cmApAudioPacket_t* pktArray[], 
unsigned pktCnt );

cmBaRC_t cmAudioBufAdvance( unsigned devIdx, unsigned flags );