From c5b8c68e118560a34fd52b5c432f1504f16eb154 Mon Sep 17 00:00:00 2001 From: kpl Date: Mon, 12 Aug 2013 00:10:03 -0700 Subject: [PATCH] cmAudioDsp.c,cmAudDspIF.h/c,cmMsgProtocol.h,cmDspClass.h:Changes to new procedure cmDspSysPrintPgm(). --- cmAudDsp.c | 38 ++++++++++++++++++++++++++++++++++++-- cmAudDspIF.c | 31 +++++++++++++++++++------------ cmAudDspIF.h | 4 ++++ cmMsgProtocol.h | 1 + dsp/cmDspClass.h | 2 +- 5 files changed, 61 insertions(+), 15 deletions(-) diff --git a/cmAudDsp.c b/cmAudDsp.c index 46ac5e5..69f7f0c 100644 --- a/cmAudDsp.c +++ b/cmAudDsp.c @@ -943,12 +943,12 @@ cmAdRC_t _cmAudDspLoadPgm( cmAd_t* p, unsigned asSubSysIdx, unsigned pgmIdx ) // the audio system must be configured before a program is loaded if((rc = _cmAdIsAudioSysLoaded(p)) != kOkAdRC ) - return cmErrMsg(&p->err,rc,"Program load failed."); + return cmErrMsg(&p->err,rc,"The audio system is not configured. Program load failed."); // validate the sub-system index arg. if( asSubSysIdx!=cmInvalidIdx && asSubSysIdx >= p->dsSsCnt ) { - rc = cmErrMsg(&p->err,kInvalidSubSysIdxAdRC,"The sub-system index %i is invalid.",asSubSysIdx); + rc = cmErrMsg(&p->err,kInvalidSubSysIdxAdRC,"The sub-system index %i is invalid. Program load failed.",asSubSysIdx); goto errLabel; } @@ -982,6 +982,36 @@ cmAdRC_t _cmAudDspLoadPgm( cmAd_t* p, unsigned asSubSysIdx, unsigned pgmIdx ) return rc; } +cmAdRC_t _cmAudDspPrintPgm( cmAd_t* p, unsigned asSubSysIdx, const cmChar_t* fn ) +{ + cmAdRC_t rc = kOkAdRC; + unsigned i; + + // the audio system must be configured before a program is loaded + if((rc = _cmAdIsAudioSysLoaded(p)) != kOkAdRC ) + return cmErrMsg(&p->err,rc,"The audio system is not configured. Program print failed."); + + // validate the sub-system index arg. + if( asSubSysIdx!=cmInvalidIdx && asSubSysIdx >= p->dsSsCnt ) + { + rc = cmErrMsg(&p->err,kInvalidSubSysIdxAdRC,"The sub-system index %i is invalid. Program print failed.",asSubSysIdx); + goto errLabel; + } + + // for each sub-system + for(i=0; idsSsCnt; ++i) + if( i==asSubSysIdx || asSubSysIdx==cmInvalidIdx ) + { + if( cmDspSysPrintPgm(p->dsSsArray[i].dsH,fn) != kOkDspRC ) + rc = cmErrMsg(&p->err,kDspSysFailAdRC,"The program print failed."); + + break; + } + + errLabel: + return rc; +} + cmAdRC_t _cmAdReinitAudioSys( cmAd_t* p ) { cmAdRC_t rc = kOkAdRC; @@ -1294,6 +1324,10 @@ cmAdRC_t cmAudDspReceiveClientMsg( cmAdH_t h, unsigned msgByteCnt, const void* m rc = _cmAudDspClientMsgPoll(p); break; + case kPrintPgmDuiId: + _cmAudDspPrintPgm(p,m->asSubIdx,cmDsvStrcz(&m->value)); + break; + default: if( cmAudioSysDeliverMsg(p->asH,msg,msgByteCnt,cmInvalidId) != kOkAsRC ) rc = cmErrMsg(&p->err,kSendMsgFailAdRC,"Message delivery to the audio system failed."); diff --git a/cmAudDspIF.c b/cmAudDspIF.c index 297fe37..f938f1c 100644 --- a/cmAudDspIF.c +++ b/cmAudDspIF.c @@ -148,15 +148,18 @@ cmAiRC_t _cmAdIfReadCfgFile( cmAi_t* p, cmCtx_t* ctx ) } -cmAiRC_t _cmAdIfSendIntMsg(cmAiH_t h, unsigned selId, unsigned asSubIdx, unsigned flags, unsigned iv, double dv ) +cmAiRC_t _cmAdIfSendIntMsg(cmAiH_t h, unsigned selId, unsigned asSubIdx, unsigned flags, unsigned iv, double dv, const cmChar_t* str ) { cmAi_t* p = _cmAiHandleToPtr( h ); cmDspValue_t v; - if(iv == cmInvalidIdx ) - cmDsvSetDouble(&v,dv); + if(str != NULL ) + cmDsvSetStrcz(&v,str); else - cmDsvSetUInt(&v,iv); + if(iv == cmInvalidIdx ) + cmDsvSetDouble(&v,dv); + else + cmDsvSetUInt(&v,iv); if( cmMsgSend(&p->err,asSubIdx,kUiSelAsId,selId,flags,cmInvalidId,cmInvalidId,&v,p->parms.audDspFunc,p->parms.audDspFuncDataPtr) != kOkMsgRC ) return cmErrMsg(&p->err,kSendFailAiRC,"The integer message sel id:%i value:%i transmission failed.",selId,iv); @@ -245,25 +248,29 @@ cmAiRC_t cmAdIfRecvAudDspMsg( cmAiH_t h, unsigned msgByteCnt, const void* } cmAiRC_t cmAdIfDeviceReport( cmAiH_t h ) -{ return _cmAdIfSendIntMsg(h,kDevReportDuiId,cmInvalidIdx,0,cmInvalidIdx,0.0); } +{ return _cmAdIfSendIntMsg(h,kDevReportDuiId,cmInvalidIdx,0,cmInvalidIdx,0.0,NULL); } cmAiRC_t cmAdIfSetAudioSysCfg( cmAiH_t h, unsigned asCfgIdx ) -{ return _cmAdIfSendIntMsg(h,kSetAudioCfgDuiId,cmInvalidIdx,0,asCfgIdx,0.0); } +{ return _cmAdIfSendIntMsg(h,kSetAudioCfgDuiId,cmInvalidIdx,0,asCfgIdx,0.0,NULL); } cmAiRC_t cmAdIfSetAudioDevice( cmAiH_t h, unsigned asSubIdx, bool inputFl, unsigned devIdx ) -{ return _cmAdIfSendIntMsg(h,kSetAudioDevDuiId,asSubIdx,inputFl,devIdx,0.0); } +{ return _cmAdIfSendIntMsg(h,kSetAudioDevDuiId,asSubIdx,inputFl,devIdx,0.0,NULL); } cmAiRC_t cmAdIfSetSampleRate( cmAiH_t h, unsigned asSubIdx, double srate ) -{ return _cmAdIfSendIntMsg(h,kSetSampleRateDuiId,asSubIdx,0,cmInvalidIdx,srate); } +{ return _cmAdIfSendIntMsg(h,kSetSampleRateDuiId,asSubIdx,0,cmInvalidIdx,srate,NULL); } cmAiRC_t cmAdIfLoadProgram( cmAiH_t h, unsigned asSubIdx, unsigned pgmIdx ) -{ return _cmAdIfSendIntMsg(h,kSetPgmDuiId,asSubIdx,0,pgmIdx,0.0); } +{ return _cmAdIfSendIntMsg(h,kSetPgmDuiId,asSubIdx,0,pgmIdx,0.0,NULL); } + +cmAiRC_t cmAdIfPrintPgm( cmAiH_t h,unsigned asSubIdx, const cmChar_t* fn ) +{ return _cmAdIfSendIntMsg(h,kPrintPgmDuiId,asSubIdx,0,cmInvalidIdx,0.0,fn); } + cmAiRC_t cmAdIfEnableAudio( cmAiH_t h, bool enableFl ) -{ return _cmAdIfSendIntMsg(h,kEnableDuiId,cmInvalidIdx,enableFl,cmInvalidIdx,0.0); } +{ return _cmAdIfSendIntMsg(h,kEnableDuiId,cmInvalidIdx,enableFl,cmInvalidIdx,0.0,NULL); } cmAiRC_t cmAdIfEnableStatusNotify( cmAiH_t h, bool enableFl ) -{ return _cmAdIfSendIntMsg(h,kSetNotifyEnableDuiId,cmInvalidIdx,enableFl,cmInvalidIdx,0.0); } +{ return _cmAdIfSendIntMsg(h,kSetNotifyEnableDuiId,cmInvalidIdx,enableFl,cmInvalidIdx,0.0,NULL); } cmAiRC_t cmAdIfSendMsgToAudioDSP( cmAiH_t h, @@ -287,5 +294,5 @@ cmAiRC_t cmAdIfSendMsgToAudioDSP( cmAiRC_t cmAdIfDispatchMsgToHost( cmAiH_t h ) -{ return _cmAdIfSendIntMsg(h,kClientMsgPollDuiId,cmInvalidIdx,0,cmInvalidIdx,0.0); } +{ return _cmAdIfSendIntMsg(h,kClientMsgPollDuiId,cmInvalidIdx,0,cmInvalidIdx,0.0,NULL); } diff --git a/cmAudDspIF.h b/cmAudDspIF.h index eae3ba1..df4209d 100644 --- a/cmAudDspIF.h +++ b/cmAudDspIF.h @@ -118,6 +118,10 @@ extern "C" { // prior to calling this function. cmAiRC_t cmAdIfLoadProgram( cmAiH_t h, unsigned asSubIdx, unsigned pgmIdx ); + // Print a representation (instances and connections) of the loaded program + // to a JSON file. + cmAiRC_t cmAdIfPrintPgm( cmAiH_t h, unsigned asSubIdx, const cmChar_t* fn ); + // Start the audio streaming. // An audio configuration must have been selected via cmAdIfSetAudioSysCfg() // and a DSP program must have been selected via cmAdIfLoadProgram() diff --git a/cmMsgProtocol.h b/cmMsgProtocol.h index f351661..725a76b 100644 --- a/cmMsgProtocol.h +++ b/cmMsgProtocol.h @@ -47,6 +47,7 @@ extern "C" { kClientMsgPollDuiId, // Periodic check for and deliver messages waiting in the audio system for delivery to the client. kSendMsgDuiId, // forward msg to the audio system kDevReportDuiId, // print a device report + kPrintPgmDuiId, // write the currently loaded pgm as a JSON file kRightAlignDuiId = 0, // label alignment id used by kLabelDuiId kLeftAlignDuiId, diff --git a/dsp/cmDspClass.h b/dsp/cmDspClass.h index cb7d221..4fa1e2e 100644 --- a/dsp/cmDspClass.h +++ b/dsp/cmDspClass.h @@ -177,7 +177,7 @@ extern "C" { typedef struct cmDspInst_str { struct cmDspClass_str* classPtr; // ptr to class for this instance - unsigned symId; // optional instance label symbol id + unsigned symId; // optional unique instance label symbol id unsigned id; // id is unique among all insts unsigned flags; // See kXXXInstFl above cmDspVar_t* varArray; //