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
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; 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 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.");

View File

@ -148,11 +148,14 @@ 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(str != NULL )
cmDsvSetStrcz(&v,str);
else
if(iv == cmInvalidIdx )
cmDsvSetDouble(&v,dv);
else
@ -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); }

View File

@ -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()

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.
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,

View File

@ -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; //