cmAudDsp.c : Added _cmAdSendProgramDefault(0 and _cmAdSendAudioSysCfgDefault().

This commit is contained in:
kevin 2016-05-23 18:37:36 -04:00
parent cf82ed61e1
commit 555ac64cce

View File

@ -45,6 +45,7 @@ typedef struct
typedef struct typedef struct
{ {
const cmChar_t* label; const cmChar_t* label;
bool dfltFl;
cmAudioSysCfg_t cfg; cmAudioSysCfg_t cfg;
} cmAdAsCfg_t; } cmAdAsCfg_t;
@ -88,6 +89,7 @@ typedef struct
unsigned midiPortBufByteCnt; unsigned midiPortBufByteCnt;
unsigned meterMs; unsigned meterMs;
unsigned msgsPerClientPoll; unsigned msgsPerClientPoll;
const cmChar_t* dfltProgramLabel;
cmAdAggDev_t* aggDevArray; cmAdAggDev_t* aggDevArray;
unsigned aggDevCnt; unsigned aggDevCnt;
@ -183,6 +185,7 @@ cmAdRC_t _cmAdParseSysJsonTree( cmAd_t* p )
"midiPortBufByteCnt", kIntTId, &p->midiPortBufByteCnt, "midiPortBufByteCnt", kIntTId, &p->midiPortBufByteCnt,
"meterMs", kIntTId, &p->meterMs, "meterMs", kIntTId, &p->meterMs,
"msgsPerClientPoll", kIntTId, &p->msgsPerClientPoll, "msgsPerClientPoll", kIntTId, &p->msgsPerClientPoll,
"dfltProgramLabel", kStringTId | kOptArgJsFl, &p->dfltProgramLabel,
"audioSysCfgArray", kArrayTId, &asCfgArrNodePtr, "audioSysCfgArray", kArrayTId, &asCfgArrNodePtr,
"aggDevArray", kArrayTId | kOptArgJsFl, &aggDevArrNodePtr, "aggDevArray", kArrayTId | kOptArgJsFl, &aggDevArrNodePtr,
"nrtDevArray", kArrayTId | kOptArgJsFl, &nrtDevArrNodePtr, "nrtDevArray", kArrayTId | kOptArgJsFl, &nrtDevArrNodePtr,
@ -301,10 +304,12 @@ cmAdRC_t _cmAdParseSysJsonTree( cmAd_t* p )
const cmJsonNode_t* asCfgNodePtr = cmJsonArrayElementC(asCfgArrNodePtr,i); const cmJsonNode_t* asCfgNodePtr = cmJsonArrayElementC(asCfgArrNodePtr,i);
const cmJsonNode_t* ssArrayNodePtr = NULL; const cmJsonNode_t* ssArrayNodePtr = NULL;
const char* cfgLabel = NULL; const char* cfgLabel = NULL;
bool dfltFl = false;
// read cmAsAudioSysCfg record values // read cmAsAudioSysCfg record values
if(( jsRC = cmJsonMemberValues( asCfgNodePtr, &errLabelPtr, if(( jsRC = cmJsonMemberValues( asCfgNodePtr, &errLabelPtr,
"label", kStringTId, &cfgLabel, "label", kStringTId, &cfgLabel,
"default", kTrueTId | kOptArgJsFl, &dfltFl,
"ssArray", kArrayTId, &ssArrayNodePtr, "ssArray", kArrayTId, &ssArrayNodePtr,
NULL )) != kOkJsRC ) NULL )) != kOkJsRC )
{ {
@ -313,6 +318,7 @@ cmAdRC_t _cmAdParseSysJsonTree( cmAd_t* p )
} }
p->asCfgArray[i].label = cfgLabel; p->asCfgArray[i].label = cfgLabel;
p->asCfgArray[i].dfltFl = dfltFl;
p->asCfgArray[i].cfg.ssCnt = cmJsonChildCount( ssArrayNodePtr ); p->asCfgArray[i].cfg.ssCnt = cmJsonChildCount( ssArrayNodePtr );
p->asCfgArray[i].cfg.ssArray = cmMemResizeZ( cmAudioSysSubSys_t, p->asCfgArray[i].cfg.ssArray, p->asCfgArray[i].cfg.ssCnt ); p->asCfgArray[i].cfg.ssArray = cmMemResizeZ( cmAudioSysSubSys_t, p->asCfgArray[i].cfg.ssArray, p->asCfgArray[i].cfg.ssCnt );
p->asCfgArray[i].cfg.clientCbFunc = _cmAudioSysToClientCallback; p->asCfgArray[i].cfg.clientCbFunc = _cmAudioSysToClientCallback;
@ -452,6 +458,28 @@ cmAdRC_t _cmAdSendAudioSysCfgLabels( cmAd_t* p)
return rc; return rc;
} }
cmAdRC_t _cmAdSendAudioSysCfgDefault( cmAd_t* p)
{
cmAdRC_t rc = kOkAdRC;
unsigned i;
for(i=0; i<p->asCfgCnt; ++i)
if( p->asCfgArray[i].dfltFl )
{
cmDspValue_t v;
cmDsvSetStrcz(&v, p->asCfgArray[i].label);
if( cmMsgSend( &p->err,cmInvalidIdx,kUiSelAsId,kAudioSysCfgDfltDuiId,0,i,p->asCfgCnt,&v,p->cbFunc,p->cbDataPtr) != kOkMsgRC )
rc = cmErrMsg(&p->err,kSendMsgFailAdRC,"Error sending audio system default cfg. label message to host.");
break;
}
return rc;
}
cmAdRC_t _cmAdSendDeviceLabels( cmAd_t* p ) cmAdRC_t _cmAdSendDeviceLabels( cmAd_t* p )
{ {
cmAdRC_t rc = kOkAdRC; cmAdRC_t rc = kOkAdRC;
@ -503,6 +531,23 @@ cmAdRC_t _cmAdSendProgramLabels( cmAd_t* p )
return rc; return rc;
} }
cmAdRC_t _cmAdSendProgramDefault( cmAd_t* p)
{
cmAdRC_t rc = kOkAdRC;
if( p->dfltProgramLabel != NULL )
{
cmDspValue_t v;
cmDsvSetStrcz(&v, p->dfltProgramLabel);
if( cmMsgSend( &p->err,cmInvalidIdx,kUiSelAsId,kProgramDfltDuiId,0,0,0,&v,p->cbFunc,p->cbDataPtr) != kOkMsgRC )
rc = cmErrMsg(&p->err,kSendMsgFailAdRC,"Error sending default program label message to host.");
}
return rc;
}
cmAdRC_t _cmAudDspFree( cmAd_t* p ) cmAdRC_t _cmAudDspFree( cmAd_t* p )
{ {
cmAdRC_t rc = kOkAdRC; cmAdRC_t rc = kOkAdRC;
@ -732,6 +777,15 @@ cmAdRC_t cmAudDspSendSetup( cmAdH_t h )
if((rc = _cmAdSendProgramLabels(p)) != kOkAdRC ) if((rc = _cmAdSendProgramLabels(p)) != kOkAdRC )
goto errLabel; goto errLabel;
// notify the client of the default audio sys cfg
if((rc= _cmAdSendAudioSysCfgDefault(p)) != kOkAdRC )
goto errLabel;
// notify the client of the default program
if((rc= _cmAdSendProgramDefault(p)) != kOkAdRC )
goto errLabel;
errLabel: errLabel:
return rc; return rc;
} }