cmSyncRecd.h/c: Added cmSyncRecdTest() and cmSyncRecdPrint().

This commit is contained in:
kevin 2013-12-15 19:49:08 -05:00
parent 50677f8f0f
commit 377429d33a
2 changed files with 53 additions and 2 deletions

View File

@ -66,7 +66,7 @@ typedef struct cmSr_str
} cmSr_t; } cmSr_t;
cmSyncRecdH_t cmSyncRecdNullHandle = cmSTATIC_NULL_HANDLE;
cmSr_t* _cmSrHtoP( cmSyncRecdH_t h ) cmSr_t* _cmSrHtoP( cmSyncRecdH_t h )
{ {
@ -435,3 +435,52 @@ cmSrRC_t cmSyncRecdAudioWrite( cmSyncRecdH_t h, const cmTimeSpec_t* timestamp, u
errLabel: errLabel:
return rc; return rc;
} }
cmSrRC_t cmSyncRecdPrint( cmSyncRecdH_t h )
{
cmSrRC_t rc = kOkSrRC;
cmSr_t* p = _cmSrHtoP(h);
unsigned i;
for(i=0; i<p->cn; ++i)
{
cmSrRecd_t* r = p->cache + i;
cmRptPrintf(p->err.rpt,"0x%x %3i %3i %ld %5.3f %ld %5.3f",r->u.m.status,r->u.m.d0,r->u.m.d1,r->u.m.timestamp.tv_sec,r->u.m.timestamp.tv_nsec/1000000000.0,p->map[i].timestamp.tv_sec,p->map[i].timestamp.tv_nsec/1000000000.0);
}
return rc;
}
cmSrRC_t cmSyncRecdTest( cmCtx_t* ctx )
{
enum
{
kOkTestRC,
kTestFailRC,
};
cmSrRC_t rc = kOkSrRC;
const cmChar_t* srFn = "/home/kevin/temp/kr/sr/sr10.sr";
cmErr_t err;
cmSyncRecdH_t srH = cmSyncRecdNullHandle;
cmErrSetup(&err,&ctx->rpt,"SyncRecdTest");
if((rc = cmSyncRecdOpen(ctx, &srH, srFn )) != kOkSrRC )
{
cmErrMsg(&err,kTestFailRC,"Sync-recd open failed.");
goto errLabel;
}
cmSyncRecdPrint(srH);
errLabel:
if((rc = cmSyncRecdFinal(&srH)) != kOkSrRC )
cmErrMsg(&err,kTestFailRC,"Sync-recd close failed.");
return rc;
}

View File

@ -25,6 +25,8 @@ extern "C" {
cmSrRC_t cmSyncRecdAudioWrite( cmSyncRecdH_t h, const cmTimeSpec_t* timestamp, unsigned smpIdx, const cmSample_t* ch[], unsigned chCnt, unsigned frmCnt ); cmSrRC_t cmSyncRecdAudioWrite( cmSyncRecdH_t h, const cmTimeSpec_t* timestamp, unsigned smpIdx, const cmSample_t* ch[], unsigned chCnt, unsigned frmCnt );
cmSrRC_t cmSyncRecdTest( cmCtx_t* ctx );
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif