|
@@ -10,6 +10,7 @@
|
10
|
10
|
#include "cmAudioFile.h"
|
11
|
11
|
#include "cmMidi.h"
|
12
|
12
|
#include "cmMidiFile.h"
|
|
13
|
+#include "cmFileSys.h"
|
13
|
14
|
#include "cmTimeLine.h"
|
14
|
15
|
|
15
|
16
|
// id's used to track the type of a serialized object
|
|
@@ -55,6 +56,7 @@ typedef struct
|
55
|
56
|
unsigned nextSeqId;
|
56
|
57
|
cmTlCb_t cbFunc;
|
57
|
58
|
void* cbArg;
|
|
59
|
+ cmChar_t* prefixPath;
|
58
|
60
|
unsigned nextUId;
|
59
|
61
|
char* tmpBuf;
|
60
|
62
|
unsigned seqCnt;
|
|
@@ -592,10 +594,17 @@ cmTlRC_t _cmTlAllocAudioFileRecd( _cmTl_t* p, const cmChar_t* nameStr, const cmC
|
592
|
594
|
cmRC_t afRC = cmOkRC;
|
593
|
595
|
cmTlRC_t rc;
|
594
|
596
|
_cmTlObj_t* op = NULL;
|
|
597
|
+
|
|
598
|
+ // prepend the time-line path prefix to the filename
|
|
599
|
+ fn = cmFsMakeFn( p->prefixPath, fn, NULL, NULL );
|
|
600
|
+
|
595
|
601
|
unsigned recdByteCnt = sizeof(cmTlAudioFile_t) + strlen(fn) + 1;
|
596
|
602
|
|
597
|
603
|
if( cmAudioFileIsValid( afH = cmAudioFileNewOpen(fn, &info, &afRC, p->err.rpt )) == false )
|
598
|
|
- return cmErrMsg(&p->err,kAudioFileFailTlRC,"The time line audio file '%s' could not be opened.",cmStringNullGuard(fn));
|
|
604
|
+ {
|
|
605
|
+ rc = cmErrMsg(&p->err,kAudioFileFailTlRC,"The time line audio file '%s' could not be opened.",cmStringNullGuard(fn));
|
|
606
|
+ goto errLabel;
|
|
607
|
+ }
|
599
|
608
|
|
600
|
609
|
if((rc = _cmTlAllocRecd(p,nameStr,refIdStr,begSmpIdx,info.frameCnt,kAudioFileTlId,seqId,recdByteCnt,&op)) != kOkTlRC )
|
601
|
610
|
goto errLabel;
|
|
@@ -621,6 +630,8 @@ cmTlRC_t _cmTlAllocAudioFileRecd( _cmTl_t* p, const cmChar_t* nameStr, const cmC
|
621
|
630
|
//_cmTlNotifyListener(p, kInsertMsgTlId, op );
|
622
|
631
|
|
623
|
632
|
errLabel:
|
|
633
|
+ cmFsFreeFn(fn);
|
|
634
|
+
|
624
|
635
|
if( rc != kOkTlRC )
|
625
|
636
|
cmAudioFileDelete(&afH);
|
626
|
637
|
|
|
@@ -718,6 +729,9 @@ cmTlRC_t _cmTlAllocMidiFileRecd( _cmTl_t* p, const cmChar_t* nameStr, const cmCh
|
718
|
729
|
cmTlRC_t rc = kOkTlRC;
|
719
|
730
|
_cmTlObj_t* op = NULL;
|
720
|
731
|
|
|
732
|
+ // prepend the time-line path prefix to the filename
|
|
733
|
+ fn = cmFsMakeFn( p->prefixPath, fn, NULL, NULL );
|
|
734
|
+
|
721
|
735
|
// open the midi file
|
722
|
736
|
if( cmMidiFileOpen(fn, &mfH, &p->ctx ) != kOkMfRC )
|
723
|
737
|
return cmErrMsg(&p->err,kMidiFileFailTlRC,"The time line midi file '%s' could not be opened.",cmStringNullGuard(fn));
|
|
@@ -763,6 +777,8 @@ cmTlRC_t _cmTlAllocMidiFileRecd( _cmTl_t* p, const cmChar_t* nameStr, const cmCh
|
763
|
777
|
|
764
|
778
|
|
765
|
779
|
errLabel:
|
|
780
|
+ cmFsFreeFn(fn);
|
|
781
|
+
|
766
|
782
|
if( rc != kOkTlRC )
|
767
|
783
|
{
|
768
|
784
|
cmMidiFileClose(&mfH);
|
|
@@ -890,6 +906,8 @@ cmTlRC_t _cmTimeLineFinalize( _cmTl_t* p )
|
890
|
906
|
|
891
|
907
|
cmMemPtrFree(&p->tmpBuf);
|
892
|
908
|
|
|
909
|
+ cmMemPtrFree(&p->prefixPath);
|
|
910
|
+
|
893
|
911
|
cmMemPtrFree(&p);
|
894
|
912
|
|
895
|
913
|
|
|
@@ -899,7 +917,7 @@ cmTlRC_t _cmTimeLineFinalize( _cmTl_t* p )
|
899
|
917
|
return cmErrMsg(&p->err,kFinalizeFailTlRC,"Finalize failed.");
|
900
|
918
|
}
|
901
|
919
|
|
902
|
|
-cmTlRC_t cmTimeLineInitialize( cmCtx_t* ctx, cmTlH_t* hp, cmTlCb_t cbFunc, void* cbArg )
|
|
920
|
+cmTlRC_t cmTimeLineInitialize( cmCtx_t* ctx, cmTlH_t* hp, cmTlCb_t cbFunc, void* cbArg, const cmChar_t* prefixPath )
|
903
|
921
|
{
|
904
|
922
|
cmTlRC_t rc;
|
905
|
923
|
|
|
@@ -909,9 +927,10 @@ cmTlRC_t cmTimeLineInitialize( cmCtx_t* ctx, cmTlH_t* hp, cmTlCb_t cbFunc, void*
|
909
|
927
|
_cmTl_t* p = cmMemAllocZ( _cmTl_t, 1 );
|
910
|
928
|
|
911
|
929
|
cmErrSetup(&p->err,&ctx->rpt,"Time Line");
|
912
|
|
- p->ctx = *ctx;
|
913
|
|
- p->cbFunc = cbFunc;
|
914
|
|
- p->cbArg = cbArg;
|
|
930
|
+ p->ctx = *ctx;
|
|
931
|
+ p->cbFunc = cbFunc;
|
|
932
|
+ p->cbArg = cbArg;
|
|
933
|
+ p->prefixPath = cmMemAllocStr(prefixPath);
|
915
|
934
|
|
916
|
935
|
if(cmLHeapIsValid( p->lH = cmLHeapCreate( 8192, ctx )) == false )
|
917
|
936
|
{
|
|
@@ -928,10 +947,10 @@ cmTlRC_t cmTimeLineInitialize( cmCtx_t* ctx, cmTlH_t* hp, cmTlCb_t cbFunc, void*
|
928
|
947
|
return rc;
|
929
|
948
|
}
|
930
|
949
|
|
931
|
|
-cmTlRC_t cmTimeLineInitializeFromFile( cmCtx_t* ctx, cmTlH_t* hp, cmTlCb_t cbFunc, void* cbArg, const cmChar_t* fn )
|
|
950
|
+cmTlRC_t cmTimeLineInitializeFromFile( cmCtx_t* ctx, cmTlH_t* hp, cmTlCb_t cbFunc, void* cbArg, const cmChar_t* fn, const cmChar_t* prefixPath )
|
932
|
951
|
{
|
933
|
952
|
cmTlRC_t rc;
|
934
|
|
- if((rc = cmTimeLineInitialize(ctx,hp,cbFunc,cbArg)) != kOkTlRC )
|
|
953
|
+ if((rc = cmTimeLineInitialize(ctx,hp,cbFunc,cbArg,prefixPath)) != kOkTlRC )
|
935
|
954
|
return rc;
|
936
|
955
|
|
937
|
956
|
return cmTimeLineReadJson(hp,fn);
|
|
@@ -1595,12 +1614,12 @@ cmTlRC_t cmTimeLinePrint( cmTlH_t h, cmRpt_t* rpt )
|
1595
|
1614
|
return kOkTlRC;
|
1596
|
1615
|
}
|
1597
|
1616
|
|
1598
|
|
-cmTlRC_t cmTimeLinePrintFn( cmCtx_t* ctx, const cmChar_t* fn, cmRpt_t* rpt )
|
|
1617
|
+cmTlRC_t cmTimeLinePrintFn( cmCtx_t* ctx, const cmChar_t* fn, const cmChar_t* prefixPath, cmRpt_t* rpt )
|
1599
|
1618
|
{
|
1600
|
1619
|
cmTlRC_t rc;
|
1601
|
1620
|
cmTlH_t h = cmTimeLineNullHandle;
|
1602
|
1621
|
|
1603
|
|
- if((rc = cmTimeLineInitializeFromFile(ctx,&h,NULL,NULL,fn)) != kOkTlRC )
|
|
1622
|
+ if((rc = cmTimeLineInitializeFromFile(ctx,&h,NULL,NULL,fn,prefixPath)) != kOkTlRC )
|
1604
|
1623
|
return rc;
|
1605
|
1624
|
|
1606
|
1625
|
cmTimeLinePrint(h,rpt);
|
|
@@ -1609,12 +1628,12 @@ cmTlRC_t cmTimeLinePrintFn( cmCtx_t* ctx, const cmChar_t* fn, cmRpt_t* rpt )
|
1609
|
1628
|
}
|
1610
|
1629
|
|
1611
|
1630
|
|
1612
|
|
-cmTlRC_t cmTimeLineTest( cmCtx_t* ctx, const cmChar_t* jsFn )
|
|
1631
|
+cmTlRC_t cmTimeLineTest( cmCtx_t* ctx, const cmChar_t* jsFn, const cmChar_t* prefixPath )
|
1613
|
1632
|
{
|
1614
|
1633
|
cmTlRC_t rc = kOkTlRC;
|
1615
|
1634
|
cmTlH_t tlH = cmTimeLineNullHandle;
|
1616
|
1635
|
|
1617
|
|
- if((rc = cmTimeLineInitialize(ctx,&tlH,NULL,NULL)) != kOkTlRC )
|
|
1636
|
+ if((rc = cmTimeLineInitialize(ctx,&tlH,NULL,NULL,prefixPath)) != kOkTlRC )
|
1618
|
1637
|
return rc;
|
1619
|
1638
|
|
1620
|
1639
|
if((rc = cmTimeLineReadJson(&tlH,jsFn)) != kOkTlRC )
|