cmAudDsp.h/c, cmAudioNrtDev.c,cmAudioSys.h : Audio devices are now set in aud_dsp.js by their name rather than their index.
This commit is contained in:
parent
4d5e88e766
commit
186f815636
@ -354,10 +354,15 @@ cmAdRC_t _cmAdParseSysJsonTree( cmAd_t* p )
|
||||
{
|
||||
cmAudioSysArgs_t* asap = &p->asCfgArray[i].cfg.ssArray[j].args;
|
||||
const cmJsonNode_t* argsNodePtr = cmJsonArrayElementC(ssArrayNodePtr,j);
|
||||
|
||||
asap->inDevIdx = cmInvalidIdx;
|
||||
asap->outDevIdx = cmInvalidIdx;
|
||||
asap->inDevLabel = NULL;
|
||||
asap->outDevLabel = NULL;
|
||||
|
||||
if((jsRC = cmJsonMemberValues( argsNodePtr, &errLabelPtr,
|
||||
"inDevIdx", kIntTId, &asap->inDevIdx,
|
||||
"outDevIdx", kIntTId, &asap->outDevIdx,
|
||||
"inDevLabel", kStringTId, &asap->inDevLabel,
|
||||
"outDevLabel", kStringTId, &asap->outDevLabel,
|
||||
"syncToInputFl", kTrueTId, &asap->syncInputFl,
|
||||
"msgQueueByteCnt", kIntTId, &asap->msgQueueByteCnt,
|
||||
"devFramesPerCycle", kIntTId, &asap->devFramesPerCycle,
|
||||
@ -443,6 +448,35 @@ cmAdRC_t _cmAdCreateAggDevices( cmAd_t* p )
|
||||
return rc;
|
||||
}
|
||||
|
||||
cmAdRC_t _cmAdResolveDeviceLabels( cmAd_t* p )
|
||||
{
|
||||
cmAdRC_t rc = kOkAdRC;
|
||||
unsigned i,j;
|
||||
|
||||
// for each cmAsAudioSysCfg record in audioSysCfgArray[]
|
||||
for(i=0; i<p->asCfgCnt; ++i)
|
||||
{
|
||||
// for each audio system sub-subsystem
|
||||
for(j=0; j<p->asCfgArray[i].cfg.ssCnt; ++j)
|
||||
{
|
||||
cmAudioSysArgs_t* asap = &p->asCfgArray[i].cfg.ssArray[j].args;
|
||||
if((asap->inDevIdx = cmApDeviceLabelToIndex( asap->inDevLabel )) == cmInvalidId )
|
||||
{
|
||||
rc = cmErrMsg(&p->err,kInvalidAudioDevIdxAdRC,"The audio input device '%s' could not be found.", cmStringNullGuard(asap->inDevLabel));
|
||||
goto errLabel;
|
||||
}
|
||||
|
||||
if((asap->outDevIdx = cmApDeviceLabelToIndex( asap->outDevLabel )) == cmInvalidId )
|
||||
{
|
||||
rc = cmErrMsg(&p->err,kInvalidAudioDevIdxAdRC,"The audio input device '%s' could not be found.", cmStringNullGuard(asap->inDevLabel));
|
||||
goto errLabel;
|
||||
}
|
||||
}
|
||||
}
|
||||
errLabel:
|
||||
return rc;
|
||||
}
|
||||
|
||||
cmAdRC_t _cmAdCreateNrtDevices( cmAd_t* p )
|
||||
{
|
||||
cmAdRC_t rc = kOkAdRC;
|
||||
@ -721,10 +755,11 @@ cmAdRC_t cmAudDspAlloc( cmCtx_t* ctx, cmAdH_t* hp, cmMsgSendFuncPtr_t cbFunc, vo
|
||||
if((rc = _cmAdParseSysJsonTree(p)) != kOkAdRC )
|
||||
goto errLabel;
|
||||
|
||||
|
||||
// create the aggregate device
|
||||
if( _cmAdCreateAggDevices(p) != kOkAdRC )
|
||||
goto errLabel;
|
||||
|
||||
|
||||
// create the non-real-time devices
|
||||
if( _cmAdCreateNrtDevices(p) != kOkAdRC )
|
||||
goto errLabel;
|
||||
@ -740,6 +775,12 @@ cmAdRC_t cmAudDspAlloc( cmCtx_t* ctx, cmAdH_t* hp, cmMsgSendFuncPtr_t cbFunc, vo
|
||||
goto errLabel;
|
||||
}
|
||||
|
||||
if( _cmAdResolveDeviceLabels(p) != kOkApRC )
|
||||
{
|
||||
rc = cmErrMsg(&p->err,kAudioPortFailAdRC,"Audio device labels could not be resolved..");
|
||||
goto errLabel;
|
||||
}
|
||||
|
||||
// initialize the audio buffer
|
||||
if( cmApBufInitialize( cmApDeviceCount(), p->meterMs ) != kOkApRC )
|
||||
{
|
||||
|
@ -27,7 +27,8 @@ extern "C" {
|
||||
kAggDevCreateFailAdRC,
|
||||
kNrtDevSysFailAdRC,
|
||||
kAfpDevSysFailAdRC,
|
||||
kNetSysFailAdRC
|
||||
kNetSysFailAdRC,
|
||||
kInvalidAudioDevIdxAdRC
|
||||
};
|
||||
|
||||
|
||||
|
@ -189,6 +189,10 @@ cmApRC_t cmApNrtAllocate( cmRpt_t* rpt )
|
||||
cmApRC_t cmApNrtFree()
|
||||
{
|
||||
cmApRC_t rc = kOkApRC;
|
||||
|
||||
if( _cmNrt == NULL )
|
||||
return rc;
|
||||
|
||||
cmApNrtDev_t* dp = _cmNrt->devs;
|
||||
while( dp != NULL )
|
||||
{
|
||||
|
@ -130,16 +130,18 @@ extern "C" {
|
||||
// Audio device sub-sytem configuration record
|
||||
typedef struct cmAudioSysArgs_str
|
||||
{
|
||||
cmRpt_t* rpt; // system console object
|
||||
unsigned inDevIdx; // input audio device
|
||||
unsigned outDevIdx; // output audio device
|
||||
bool syncInputFl; // true/false sync the DSP update callbacks with audio input/output
|
||||
unsigned msgQueueByteCnt; // Size of the internal msg queue used to buffer msgs arriving via cmAudioSysDeliverMsg().
|
||||
unsigned devFramesPerCycle; // (512) Audio device samples per channel per device update buffer.
|
||||
unsigned dspFramesPerCycle; // (64) Audio samples per channel per DSP cycle.
|
||||
unsigned audioBufCnt; // (3) Audio device buffers.
|
||||
double srate; // Audio sample rate.
|
||||
int srateMult; // Sample rate multiplication factor (negative for divide)
|
||||
cmRpt_t* rpt; // system console object
|
||||
const cmChar_t* inDevLabel; // input audio device text label
|
||||
const cmChar_t* outDevLabel; // output audio device text label
|
||||
unsigned inDevIdx; // input audio device index
|
||||
unsigned outDevIdx; // output audio device index
|
||||
bool syncInputFl; // true/false sync the DSP update callbacks with audio input/output
|
||||
unsigned msgQueueByteCnt; // Size of the internal msg queue used to buffer msgs arriving via cmAudioSysDeliverMsg().
|
||||
unsigned devFramesPerCycle; // (512) Audio device samples per channel per device update buffer.
|
||||
unsigned dspFramesPerCycle; // (64) Audio samples per channel per DSP cycle.
|
||||
unsigned audioBufCnt; // (3) Audio device buffers.
|
||||
double srate; // Audio sample rate.
|
||||
int srateMult; // Sample rate multiplication factor (negative for divide)
|
||||
} cmAudioSysArgs_t;
|
||||
|
||||
// Audio sub-system configuration record.
|
||||
|
Loading…
Reference in New Issue
Block a user