cmAudioDsp.c,cmAudDspIF.h/c,cmMsgProtocol.h,cmDspClass.h:Changes to

new procedure cmDspSysPrintPgm().
This commit is contained in:
kpl 2013-08-12 00:10:03 -07:00
parent 78faec2960
commit c5b8c68e11
5 changed files with 61 additions and 15 deletions

View File

@ -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 // the audio system must be configured before a program is loaded
if((rc = _cmAdIsAudioSysLoaded(p)) != kOkAdRC ) 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. // validate the sub-system index arg.
if( asSubSysIdx!=cmInvalidIdx && asSubSysIdx >= p->dsSsCnt ) 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; goto errLabel;
} }
@ -982,6 +982,36 @@ cmAdRC_t _cmAudDspLoadPgm( cmAd_t* p, unsigned asSubSysIdx, unsigned pgmIdx )
return rc; 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; i<p->dsSsCnt; ++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 _cmAdReinitAudioSys( cmAd_t* p )
{ {
cmAdRC_t rc = kOkAdRC; cmAdRC_t rc = kOkAdRC;
@ -1294,6 +1324,10 @@ cmAdRC_t cmAudDspReceiveClientMsg( cmAdH_t h, unsigned msgByteCnt, const void* m
rc = _cmAudDspClientMsgPoll(p); rc = _cmAudDspClientMsgPoll(p);
break; break;
case kPrintPgmDuiId:
_cmAudDspPrintPgm(p,m->asSubIdx,cmDsvStrcz(&m->value));
break;
default: default:
if( cmAudioSysDeliverMsg(p->asH,msg,msgByteCnt,cmInvalidId) != kOkAsRC ) if( cmAudioSysDeliverMsg(p->asH,msg,msgByteCnt,cmInvalidId) != kOkAsRC )
rc = cmErrMsg(&p->err,kSendMsgFailAdRC,"Message delivery to the audio system failed."); rc = cmErrMsg(&p->err,kSendMsgFailAdRC,"Message delivery to the audio system failed.");

View File

@ -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 ); cmAi_t* p = _cmAiHandleToPtr( h );
cmDspValue_t v; cmDspValue_t v;
if(iv == cmInvalidIdx ) if(str != NULL )
cmDsvSetDouble(&v,dv); cmDsvSetStrcz(&v,str);
else 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 ) 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); 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 ) 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 ) 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 ) 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 ) 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 ) 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 ) 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 ) 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( cmAiRC_t cmAdIfSendMsgToAudioDSP(
cmAiH_t h, cmAiH_t h,
@ -287,5 +294,5 @@ cmAiRC_t cmAdIfSendMsgToAudioDSP(
cmAiRC_t cmAdIfDispatchMsgToHost( cmAiH_t h ) 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); }

View File

@ -118,6 +118,10 @@ extern "C" {
// prior to calling this function. // prior to calling this function.
cmAiRC_t cmAdIfLoadProgram( cmAiH_t h, unsigned asSubIdx, unsigned pgmIdx ); 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. // Start the audio streaming.
// An audio configuration must have been selected via cmAdIfSetAudioSysCfg() // An audio configuration must have been selected via cmAdIfSetAudioSysCfg()
// and a DSP program must have been selected via cmAdIfLoadProgram() // and a DSP program must have been selected via cmAdIfLoadProgram()

View File

@ -47,6 +47,7 @@ extern "C" {
kClientMsgPollDuiId, // Periodic check for and deliver messages waiting in the audio system for delivery to the client. kClientMsgPollDuiId, // Periodic check for and deliver messages waiting in the audio system for delivery to the client.
kSendMsgDuiId, // forward msg to the audio system kSendMsgDuiId, // forward msg to the audio system
kDevReportDuiId, // print a device report kDevReportDuiId, // print a device report
kPrintPgmDuiId, // write the currently loaded pgm as a JSON file
kRightAlignDuiId = 0, // label alignment id used by kLabelDuiId kRightAlignDuiId = 0, // label alignment id used by kLabelDuiId
kLeftAlignDuiId, kLeftAlignDuiId,

View File

@ -177,7 +177,7 @@ extern "C" {
typedef struct cmDspInst_str typedef struct cmDspInst_str
{ {
struct cmDspClass_str* classPtr; // ptr to class for this instance 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 id; // id is unique among all insts
unsigned flags; // See kXXXInstFl above unsigned flags; // See kXXXInstFl above
cmDspVar_t* varArray; // cmDspVar_t* varArray; //