|
@@ -11,6 +11,7 @@
|
11
|
11
|
#include "cmSyncRecd.h"
|
12
|
12
|
#include "cmVectOpsTemplateMain.h"
|
13
|
13
|
#include "cmMidi.h"
|
|
14
|
+
|
14
|
15
|
typedef enum
|
15
|
16
|
{
|
16
|
17
|
kInvalidSrId,
|
|
@@ -76,44 +77,44 @@ cmSr_t* _cmSrHtoP( cmSyncRecdH_t h )
|
76
|
77
|
return p;
|
77
|
78
|
}
|
78
|
79
|
|
79
|
|
-cmSrRC_t _cmSrWriteCache( cmSr_t* p )
|
|
80
|
+cmSyRC_t _cmSrWriteCache( cmSr_t* p )
|
80
|
81
|
{
|
81
|
82
|
if( cmFileWrite(p->fH,p->cache,p->ci * sizeof(cmSrRecd_t)) != kOkFileRC )
|
82
|
|
- return cmErrMsg(&p->err,kFileFailSrRC,"File write failed.");
|
|
83
|
+ return cmErrMsg(&p->err,kFileFailSyRC,"File write failed.");
|
83
|
84
|
|
84
|
85
|
p->fn += p->ci;
|
85
|
86
|
p->ci = 0;
|
86
|
87
|
|
87
|
|
- return kOkSrRC;
|
|
88
|
+ return kOkSyRC;
|
88
|
89
|
}
|
89
|
90
|
|
90
|
91
|
|
91
|
|
-cmSrRC_t _cmSrFinal( cmSr_t* p )
|
|
92
|
+cmSyRC_t _cmSrFinal( cmSr_t* p )
|
92
|
93
|
{
|
93
|
|
- cmSrRC_t rc = kOkSrRC;
|
|
94
|
+ cmSyRC_t rc = kOkSyRC;
|
94
|
95
|
|
95
|
96
|
// write any remaining cache records
|
96
|
97
|
if( cmIsFlag(p->flags,kReadSrFl) == false )
|
97
|
98
|
{
|
98
|
|
- if((rc = _cmSrWriteCache(p)) == kOkSrRC )
|
|
99
|
+ if((rc = _cmSrWriteCache(p)) == kOkSyRC )
|
99
|
100
|
{
|
100
|
101
|
if(cmFileSeek(p->fH,kBeginFileFl,p->offs) != kOkFileRC )
|
101
|
|
- rc = cmErrMsg(&p->err,kFileFailSrRC, "File seek fail on file offset positioning.");
|
|
102
|
+ rc = cmErrMsg(&p->err,kFileFailSyRC, "File seek fail on file offset positioning.");
|
102
|
103
|
else
|
103
|
104
|
if(cmFileWriteUInt(p->fH,&p->fn,1) != kOkFileRC )
|
104
|
|
- rc = cmErrMsg(&p->err,kFileFailSrRC, "File write failed on record count.");
|
|
105
|
+ rc = cmErrMsg(&p->err,kFileFailSyRC, "File write failed on record count.");
|
105
|
106
|
}
|
106
|
107
|
}
|
107
|
108
|
|
108
|
109
|
// release the audio file object
|
109
|
110
|
if( cmAudioFileIsValid(p->afH) )
|
110
|
111
|
if( cmAudioFileDelete(&p->afH) != kOkAfRC )
|
111
|
|
- return cmErrMsg(&p->err,kAudioFileFailSrRC,"Audio file object delete failed.");
|
|
112
|
+ return cmErrMsg(&p->err,kAudioFileFailSyRC,"Audio file object delete failed.");
|
112
|
113
|
|
113
|
114
|
// release the sync-recd file object
|
114
|
115
|
if( cmFileIsValid(p->fH) )
|
115
|
116
|
if( cmFileClose(&p->fH) != kOkFileRC )
|
116
|
|
- return cmErrMsg(&p->err,kFileFailSrRC,"File close failed.");
|
|
117
|
+ return cmErrMsg(&p->err,kFileFailSyRC,"File close failed.");
|
117
|
118
|
|
118
|
119
|
cmMemFree(p->cache);
|
119
|
120
|
cmMemFree(p->map);
|
|
@@ -134,27 +135,27 @@ cmSr_t* _cmSrAlloc( cmCtx_t* ctx, unsigned flags )
|
134
|
135
|
return p;
|
135
|
136
|
}
|
136
|
137
|
|
137
|
|
-cmSrRC_t cmSyncRecdCreate( cmCtx_t* ctx, cmSyncRecdH_t* hp, const cmChar_t* srFn, const cmChar_t* audioFn, double srate, unsigned chCnt, unsigned bits )
|
|
138
|
+cmSyRC_t cmSyncRecdCreate( cmCtx_t* ctx, cmSyncRecdH_t* hp, const cmChar_t* srFn, const cmChar_t* audioFn, double srate, unsigned chCnt, unsigned bits )
|
138
|
139
|
{
|
139
|
|
- cmSrRC_t rc = kOkSrRC;
|
|
140
|
+ cmSyRC_t rc = kOkSyRC;
|
140
|
141
|
cmRC_t afRC = kOkAfRC;
|
141
|
142
|
|
142
|
143
|
assert( audioFn != NULL );
|
143
|
144
|
|
144
|
|
- if((rc = cmSyncRecdFinal(hp)) != kOkSrRC )
|
|
145
|
+ if((rc = cmSyncRecdFinal(hp)) != kOkSyRC )
|
145
|
146
|
return rc;
|
146
|
147
|
|
147
|
148
|
cmSr_t* p = _cmSrAlloc(ctx,0);
|
148
|
149
|
|
149
|
150
|
if( cmFileOpen(&p->fH,srFn,kWriteFileFl,&ctx->rpt) != kOkFileRC )
|
150
|
151
|
{
|
151
|
|
- rc = cmErrMsg(&p->err,kFileFailSrRC,"Unable to create the sync-recd file '%s'.",cmStringNullGuard(srFn));
|
|
152
|
+ rc = cmErrMsg(&p->err,kFileFailSyRC,"Unable to create the sync-recd file '%s'.",cmStringNullGuard(srFn));
|
152
|
153
|
goto errLabel;
|
153
|
154
|
}
|
154
|
155
|
|
155
|
156
|
if( cmAudioFileIsValid(p->afH = cmAudioFileNewCreate(audioFn,srate,bits,chCnt,&afRC,&ctx->rpt))==false)
|
156
|
157
|
{
|
157
|
|
- rc = cmErrMsg(&p->err,kAudioFileFailSrRC,"Unable to create the sync-recd audio file '%s'.",cmStringNullGuard(audioFn));
|
|
158
|
+ rc = cmErrMsg(&p->err,kAudioFileFailSyRC,"Unable to create the sync-recd audio file '%s'.",cmStringNullGuard(audioFn));
|
158
|
159
|
goto errLabel;
|
159
|
160
|
}
|
160
|
161
|
|
|
@@ -163,47 +164,47 @@ cmSrRC_t cmSyncRecdCreate( cmCtx_t* ctx, cmSyncRecdH_t* hp, const cmChar_t* srFn
|
163
|
164
|
|
164
|
165
|
if( cmFileWriteUInt(p->fH,&fileUUId,1) != kOkFileRC )
|
165
|
166
|
{
|
166
|
|
- rc = cmErrMsg(&p->err,kFileFailSrRC,"File write failed on UUID.");
|
|
167
|
+ rc = cmErrMsg(&p->err,kFileFailSyRC,"File write failed on UUID.");
|
167
|
168
|
goto errLabel;
|
168
|
169
|
}
|
169
|
170
|
|
170
|
171
|
if( cmFileWriteUInt(p->fH,&audioFnCnt,1) != kOkFileRC )
|
171
|
172
|
{
|
172
|
|
- rc = cmErrMsg(&p->err,kFileFailSrRC,"File write failed on audio file length write count.");
|
|
173
|
+ rc = cmErrMsg(&p->err,kFileFailSyRC,"File write failed on audio file length write count.");
|
173
|
174
|
goto errLabel;
|
174
|
175
|
}
|
175
|
176
|
|
176
|
177
|
if( cmFileWriteChar(p->fH,audioFn,audioFnCnt) != kOkFileRC )
|
177
|
178
|
{
|
178
|
|
- rc = cmErrMsg(&p->err,kFileFailSrRC,"File write failed on audio file string.");
|
|
179
|
+ rc = cmErrMsg(&p->err,kFileFailSyRC,"File write failed on audio file string.");
|
179
|
180
|
goto errLabel;
|
180
|
181
|
}
|
181
|
182
|
|
182
|
183
|
if( cmFileTell(p->fH,&p->offs) != kOkFileRC )
|
183
|
184
|
{
|
184
|
|
- rc = cmErrMsg(&p->err,kFileFailSrRC,"Unable to determine file offset.");
|
|
185
|
+ rc = cmErrMsg(&p->err,kFileFailSyRC,"Unable to determine file offset.");
|
185
|
186
|
goto errLabel;
|
186
|
187
|
}
|
187
|
188
|
|
188
|
189
|
if( cmFileWriteUInt(p->fH,&p->fn,1) != kOkFileRC )
|
189
|
190
|
{
|
190
|
|
- rc = cmErrMsg(&p->err,kFileFailSrRC,"File write failed on initial record count.");
|
|
191
|
+ rc = cmErrMsg(&p->err,kFileFailSyRC,"File write failed on initial record count.");
|
191
|
192
|
goto errLabel;
|
192
|
193
|
}
|
193
|
194
|
|
194
|
195
|
hp->h = p;
|
195
|
196
|
|
196
|
197
|
errLabel:
|
197
|
|
- if( rc != kOkSrRC )
|
|
198
|
+ if( rc != kOkSyRC )
|
198
|
199
|
_cmSrFinal(p);
|
199
|
200
|
|
200
|
201
|
return rc;
|
201
|
202
|
}
|
202
|
203
|
|
203
|
204
|
|
204
|
|
-cmSrRC_t cmSyncRecdOpen( cmCtx_t* ctx, cmSyncRecdH_t* hp, const cmChar_t* srFn )
|
|
205
|
+cmSyRC_t cmSyncRecdOpen( cmCtx_t* ctx, cmSyncRecdH_t* hp, const cmChar_t* srFn )
|
205
|
206
|
{
|
206
|
|
- cmSrRC_t rc = kOkSrRC;
|
|
207
|
+ cmSyRC_t rc = kOkSyRC;
|
207
|
208
|
cmRC_t afRC = kOkAfRC;
|
208
|
209
|
unsigned fileUUId = cmInvalidId;
|
209
|
210
|
unsigned audioFnCnt = 0;
|
|
@@ -213,26 +214,26 @@ cmSrRC_t cmSyncRecdOpen( cmCtx_t* ctx, cmSyncRecdH_t* hp, const cmChar_t* srFn
|
213
|
214
|
unsigned mcnt = 0;
|
214
|
215
|
unsigned* tiV = NULL;
|
215
|
216
|
|
216
|
|
- if((rc = cmSyncRecdFinal(hp)) != kOkSrRC )
|
|
217
|
+ if((rc = cmSyncRecdFinal(hp)) != kOkSyRC )
|
217
|
218
|
return rc;
|
218
|
219
|
|
219
|
220
|
cmSr_t* p = _cmSrAlloc(ctx,kReadSrFl);
|
220
|
221
|
|
221
|
222
|
if( cmFileOpen(&p->fH,srFn,kReadFileFl,&ctx->rpt) != kOkFileRC )
|
222
|
223
|
{
|
223
|
|
- rc = cmErrMsg(&p->err,kFileFailSrRC,"Unable to open the sync-recd file '%s'.",cmStringNullGuard(srFn));
|
|
224
|
+ rc = cmErrMsg(&p->err,kFileFailSyRC,"Unable to open the sync-recd file '%s'.",cmStringNullGuard(srFn));
|
224
|
225
|
goto errLabel;
|
225
|
226
|
}
|
226
|
227
|
|
227
|
228
|
if( cmFileReadUInt(p->fH,&fileUUId,1) != kOkFileRC )
|
228
|
229
|
{
|
229
|
|
- rc = cmErrMsg(&p->err,kFileFailSrRC,"File read failed on UUId.");
|
|
230
|
+ rc = cmErrMsg(&p->err,kFileFailSyRC,"File read failed on UUId.");
|
230
|
231
|
goto errLabel;
|
231
|
232
|
}
|
232
|
233
|
|
233
|
234
|
if( cmFileReadUInt(p->fH,&audioFnCnt,1) != kOkFileRC )
|
234
|
235
|
{
|
235
|
|
- rc = cmErrMsg(&p->err,kFileFailSrRC,"File read failed on audio file name count.");
|
|
236
|
+ rc = cmErrMsg(&p->err,kFileFailSyRC,"File read failed on audio file name count.");
|
236
|
237
|
goto errLabel;
|
237
|
238
|
}
|
238
|
239
|
|
|
@@ -240,20 +241,20 @@ cmSrRC_t cmSyncRecdOpen( cmCtx_t* ctx, cmSyncRecdH_t* hp, const cmChar_t* srFn
|
240
|
241
|
|
241
|
242
|
if( cmFileReadChar(p->fH,audioFn,audioFnCnt) != kOkFileRC )
|
242
|
243
|
{
|
243
|
|
- rc = cmErrMsg(&p->err,kFileFailSrRC,"File read failed on audio file string.");
|
|
244
|
+ rc = cmErrMsg(&p->err,kFileFailSyRC,"File read failed on audio file string.");
|
244
|
245
|
goto errLabel;
|
245
|
246
|
}
|
246
|
247
|
|
247
|
248
|
if( cmFileReadUInt(p->fH,&p->fn,1) != kOkFileRC )
|
248
|
249
|
{
|
249
|
|
- rc = cmErrMsg(&p->err,kFileFailSrRC,"File read failed on record count.");
|
|
250
|
+ rc = cmErrMsg(&p->err,kFileFailSyRC,"File read failed on record count.");
|
250
|
251
|
goto errLabel;
|
251
|
252
|
}
|
252
|
253
|
|
253
|
254
|
// store the file offset to the first recd
|
254
|
255
|
if( cmFileTell(p->fH,&p->offs) != kOkFileRC )
|
255
|
256
|
{
|
256
|
|
- rc = cmErrMsg(&p->err,kFileFailSrRC,"Unable to determine the current file offset.");
|
|
257
|
+ rc = cmErrMsg(&p->err,kFileFailSyRC,"Unable to determine the current file offset.");
|
257
|
258
|
goto errLabel;
|
258
|
259
|
}
|
259
|
260
|
|
|
@@ -264,7 +265,7 @@ cmSrRC_t cmSyncRecdOpen( cmCtx_t* ctx, cmSyncRecdH_t* hp, const cmChar_t* srFn
|
264
|
265
|
cmSrRecd_t r;
|
265
|
266
|
if( cmFileRead(p->fH,&r,sizeof(r)) != kOkFileRC )
|
266
|
267
|
{
|
267
|
|
- rc = cmErrMsg(&p->err,kFileFailSrRC,"Unable to read the record at index %i.");
|
|
268
|
+ rc = cmErrMsg(&p->err,kFileFailSyRC,"Unable to read the record at index %i.");
|
268
|
269
|
goto errLabel;
|
269
|
270
|
}
|
270
|
271
|
|
|
@@ -288,7 +289,7 @@ cmSrRC_t cmSyncRecdOpen( cmCtx_t* ctx, cmSyncRecdH_t* hp, const cmChar_t* srFn
|
288
|
289
|
// rewind to the begining of the records
|
289
|
290
|
if( cmFileSeek(p->fH,kBeginFileFl,p->offs) != kOkFileRC )
|
290
|
291
|
{
|
291
|
|
- rc = cmErrMsg(&p->err,kFileFailSrRC,"Unable to seek to first recd offset.");
|
|
292
|
+ rc = cmErrMsg(&p->err,kFileFailSyRC,"Unable to seek to first recd offset.");
|
292
|
293
|
goto errLabel;
|
293
|
294
|
}
|
294
|
295
|
|
|
@@ -303,7 +304,7 @@ cmSrRC_t cmSyncRecdOpen( cmCtx_t* ctx, cmSyncRecdH_t* hp, const cmChar_t* srFn
|
303
|
304
|
{
|
304
|
305
|
if( cmFileRead(p->fH,p->cache + p->ci,sizeof(cmSrRecd_t)) != kOkFileRC )
|
305
|
306
|
{
|
306
|
|
- rc = cmErrMsg(&p->err,kFileFailSrRC,"Unable to read the record at index %i.");
|
|
307
|
+ rc = cmErrMsg(&p->err,kFileFailSyRC,"Unable to read the record at index %i.");
|
307
|
308
|
goto errLabel;
|
308
|
309
|
}
|
309
|
310
|
|
|
@@ -317,7 +318,7 @@ cmSrRC_t cmSyncRecdOpen( cmCtx_t* ctx, cmSyncRecdH_t* hp, const cmChar_t* srFn
|
317
|
318
|
// rewind to the first recd
|
318
|
319
|
if( cmFileSeek(p->fH,kBeginFileFl,p->offs) != kOkFileRC )
|
319
|
320
|
{
|
320
|
|
- rc = cmErrMsg(&p->err,kFileFailSrRC,"Unable to seek to first recd offset.");
|
|
321
|
+ rc = cmErrMsg(&p->err,kFileFailSyRC,"Unable to seek to first recd offset.");
|
321
|
322
|
goto errLabel;
|
322
|
323
|
}
|
323
|
324
|
|
|
@@ -328,7 +329,7 @@ cmSrRC_t cmSyncRecdOpen( cmCtx_t* ctx, cmSyncRecdH_t* hp, const cmChar_t* srFn
|
328
|
329
|
cmSrRecd_t r;
|
329
|
330
|
if( cmFileRead(p->fH,&r,sizeof(r)) != kOkFileRC )
|
330
|
331
|
{
|
331
|
|
- rc = cmErrMsg(&p->err,kFileFailSrRC,"Unable to read the record at index %i.");
|
|
332
|
+ rc = cmErrMsg(&p->err,kFileFailSyRC,"Unable to read the record at index %i.");
|
332
|
333
|
goto errLabel;
|
333
|
334
|
}
|
334
|
335
|
|
|
@@ -358,7 +359,7 @@ cmSrRC_t cmSyncRecdOpen( cmCtx_t* ctx, cmSyncRecdH_t* hp, const cmChar_t* srFn
|
358
|
359
|
// open the audio file
|
359
|
360
|
if( cmAudioFileIsValid(p->afH = cmAudioFileNewOpen(audioFn,&p->afInfo,&afRC,&ctx->rpt ))==false)
|
360
|
361
|
{
|
361
|
|
- rc = cmErrMsg(&p->err,kAudioFileFailSrRC,"Unable to open the sync-recd audio file '%s'.",cmStringNullGuard(audioFn));
|
|
362
|
+ rc = cmErrMsg(&p->err,kAudioFileFailSyRC,"Unable to open the sync-recd audio file '%s'.",cmStringNullGuard(audioFn));
|
362
|
363
|
goto errLabel;
|
363
|
364
|
}
|
364
|
365
|
|
|
@@ -371,22 +372,22 @@ cmSrRC_t cmSyncRecdOpen( cmCtx_t* ctx, cmSyncRecdH_t* hp, const cmChar_t* srFn
|
371
|
372
|
cmMemFree(tiV);
|
372
|
373
|
cmMemFree(audioFn);
|
373
|
374
|
|
374
|
|
- if( rc != kOkSrRC )
|
|
375
|
+ if( rc != kOkSyRC )
|
375
|
376
|
_cmSrFinal(p);
|
376
|
377
|
|
377
|
378
|
return rc;
|
378
|
379
|
}
|
379
|
380
|
|
380
|
|
-cmSrRC_t cmSyncRecdFinal( cmSyncRecdH_t* hp )
|
|
381
|
+cmSyRC_t cmSyncRecdFinal( cmSyncRecdH_t* hp )
|
381
|
382
|
{
|
382
|
|
- cmSrRC_t rc = kOkSrRC;
|
|
383
|
+ cmSyRC_t rc = kOkSyRC;
|
383
|
384
|
|
384
|
385
|
if( hp==NULL || cmSyncRecdIsValid(*hp)==false)
|
385
|
386
|
return rc;
|
386
|
387
|
|
387
|
388
|
cmSr_t* p = _cmSrHtoP(*hp);
|
388
|
389
|
|
389
|
|
- if((rc = _cmSrFinal(p)) != kOkSrRC )
|
|
390
|
+ if((rc = _cmSrFinal(p)) != kOkSyRC )
|
390
|
391
|
return rc;
|
391
|
392
|
|
392
|
393
|
hp->h = NULL;
|
|
@@ -397,9 +398,9 @@ cmSrRC_t cmSyncRecdFinal( cmSyncRecdH_t* hp )
|
397
|
398
|
bool cmSyncRecdIsValid( cmSyncRecdH_t h )
|
398
|
399
|
{ return h.h != NULL; }
|
399
|
400
|
|
400
|
|
-cmSrRC_t cmSyncRecdMidiWrite( cmSyncRecdH_t h, const cmTimeSpec_t* timestamp, unsigned status, unsigned d0, unsigned d1 )
|
|
401
|
+cmSyRC_t cmSyncRecdMidiWrite( cmSyncRecdH_t h, const cmTimeSpec_t* timestamp, unsigned status, unsigned d0, unsigned d1 )
|
401
|
402
|
{
|
402
|
|
- cmSrRC_t rc = kOkSrRC;
|
|
403
|
+ cmSyRC_t rc = kOkSyRC;
|
403
|
404
|
cmSr_t* p = _cmSrHtoP(h);
|
404
|
405
|
cmSrRecd_t* rp = p->cache + p->ci;
|
405
|
406
|
rp->tid = kMidiSrId;
|
|
@@ -416,9 +417,9 @@ cmSrRC_t cmSyncRecdMidiWrite( cmSyncRecdH_t h, const cmTimeSpec_t* timestamp, u
|
416
|
417
|
return rc;
|
417
|
418
|
}
|
418
|
419
|
|
419
|
|
-cmSrRC_t cmSyncRecdAudioWrite( cmSyncRecdH_t h, const cmTimeSpec_t* timestamp, unsigned smpIdx, const cmSample_t* ch[], unsigned chCnt, unsigned frmCnt )
|
|
420
|
+cmSyRC_t cmSyncRecdAudioWrite( cmSyncRecdH_t h, const cmTimeSpec_t* timestamp, unsigned smpIdx, const cmSample_t* ch[], unsigned chCnt, unsigned frmCnt )
|
420
|
421
|
{
|
421
|
|
- cmSrRC_t rc = kOkSrRC;
|
|
422
|
+ cmSyRC_t rc = kOkSyRC;
|
422
|
423
|
cmSr_t* p = _cmSrHtoP(h);
|
423
|
424
|
cmSrRecd_t* rp = p->cache + p->ci;
|
424
|
425
|
rp->tid = kAudioSrId;
|
|
@@ -428,25 +429,25 @@ cmSrRC_t cmSyncRecdAudioWrite( cmSyncRecdH_t h, const cmTimeSpec_t* timestamp, u
|
428
|
429
|
p->ci += 1;
|
429
|
430
|
|
430
|
431
|
if( p->ci == p->cn )
|
431
|
|
- if((rc = _cmSrWriteCache(p)) != kOkSrRC )
|
|
432
|
+ if((rc = _cmSrWriteCache(p)) != kOkSyRC )
|
432
|
433
|
goto errLabel;
|
433
|
434
|
|
434
|
435
|
if( cmAudioFileWriteSample(p->afH,frmCnt,chCnt,(cmSample_t**)ch) != kOkAfRC )
|
435
|
|
- rc = cmErrMsg(&p->err,kAudioFileFailSrRC,"Audio file write failed.");
|
|
436
|
+ rc = cmErrMsg(&p->err,kAudioFileFailSyRC,"Audio file write failed.");
|
436
|
437
|
|
437
|
438
|
errLabel:
|
438
|
439
|
return rc;
|
439
|
440
|
}
|
440
|
441
|
|
441
|
442
|
|
442
|
|
-cmSrRC_t cmSyncRecdPrint( cmSyncRecdH_t h )
|
|
443
|
+cmSyRC_t cmSyncRecdPrint( cmSyncRecdH_t h )
|
443
|
444
|
{
|
444
|
|
- cmSrRC_t rc = kOkSrRC;
|
|
445
|
+ cmSyRC_t rc = kOkSyRC;
|
445
|
446
|
cmSr_t* p = _cmSrHtoP(h);
|
446
|
447
|
unsigned i;
|
447
|
448
|
|
448
|
449
|
if( cmIsFlag(p->flags,kReadSrFl)==false)
|
449
|
|
- return cmErrMsg(&p->err,kInvalidOpSrRC,"The 'print' operation is only valid on sync-recd files opened for reading.");
|
|
450
|
+ return cmErrMsg(&p->err,kInvalidOpSyRC,"The 'print' operation is only valid on sync-recd files opened for reading.");
|
450
|
451
|
|
451
|
452
|
for(i=0; i<p->cn; ++i)
|
452
|
453
|
{
|
|
@@ -457,9 +458,9 @@ cmSrRC_t cmSyncRecdPrint( cmSyncRecdH_t h )
|
457
|
458
|
return rc;
|
458
|
459
|
}
|
459
|
460
|
|
460
|
|
-cmSrRC_t cmSyncRecdAudioFile( cmSyncRecdH_t h, const cmChar_t* fn )
|
|
461
|
+cmSyRC_t cmSyncRecdAudioFile( cmSyncRecdH_t h, const cmChar_t* fn )
|
461
|
462
|
{
|
462
|
|
- cmSrRC_t rc = kOkSrRC;
|
|
463
|
+ cmSyRC_t rc = kOkSyRC;
|
463
|
464
|
cmSr_t* p = _cmSrHtoP(h);
|
464
|
465
|
cmAudioFileH_t afH = cmNullAudioFileH;
|
465
|
466
|
unsigned chCnt = 2;
|
|
@@ -474,19 +475,19 @@ cmSrRC_t cmSyncRecdAudioFile( cmSyncRecdH_t h, const cmChar_t* fn )
|
474
|
475
|
chs[1] = buf+frmCnt;
|
475
|
476
|
|
476
|
477
|
if( cmIsFlag(p->flags,kReadSrFl)==false)
|
477
|
|
- return cmErrMsg(&p->err,kInvalidOpSrRC,"The 'audio-file-output' operation is only valid on sync-recd files opened for reading.");
|
|
478
|
+ return cmErrMsg(&p->err,kInvalidOpSyRC,"The 'audio-file-output' operation is only valid on sync-recd files opened for reading.");
|
478
|
479
|
|
479
|
480
|
/// Open an audio file for writing
|
480
|
481
|
if(cmAudioFileIsValid(afH = cmAudioFileNewCreate(fn, p->afInfo.srate, p->afInfo.bits, chCnt, &afRC, p->err.rpt))==false)
|
481
|
482
|
{
|
482
|
|
- rc = cmErrMsg(&p->err,kAudioFileFailSrRC,"Unable to create the synchronized audio file '%s'.",cmStringNullGuard(fn));
|
|
483
|
+ rc = cmErrMsg(&p->err,kAudioFileFailSyRC,"Unable to create the synchronized audio file '%s'.",cmStringNullGuard(fn));
|
483
|
484
|
goto errLabel;
|
484
|
485
|
}
|
485
|
486
|
|
486
|
487
|
// rewind the input audio file
|
487
|
488
|
if( cmAudioFileSeek(p->afH,0) != kOkAfRC )
|
488
|
489
|
{
|
489
|
|
- rc = cmErrMsg(&p->err,kAudioFileFailSrRC,"Seek failed during synchronized audio file output.");
|
|
490
|
+ rc = cmErrMsg(&p->err,kAudioFileFailSyRC,"Seek failed during synchronized audio file output.");
|
490
|
491
|
goto errLabel;
|
491
|
492
|
}
|
492
|
493
|
|
|
@@ -500,7 +501,7 @@ cmSrRC_t cmSyncRecdAudioFile( cmSyncRecdH_t h, const cmChar_t* fn )
|
500
|
501
|
// read frmCnt samples from the first channel of the input audio file
|
501
|
502
|
if( cmAudioFileReadSample(p->afH, frmCnt, chIdx, 1, chs, &actFrmCnt ) != kOkAfRC )
|
502
|
503
|
{
|
503
|
|
- rc = cmErrMsg(&p->err,kAudioFileFailSrRC,"Audio file read failed.");
|
|
504
|
+ rc = cmErrMsg(&p->err,kAudioFileFailSyRC,"Audio file read failed.");
|
504
|
505
|
break;
|
505
|
506
|
}
|
506
|
507
|
|
|
@@ -515,7 +516,7 @@ cmSrRC_t cmSyncRecdAudioFile( cmSyncRecdH_t h, const cmChar_t* fn )
|
515
|
516
|
// write the audio output samples
|
516
|
517
|
if( cmAudioFileWriteSample(afH, frmCnt, chCnt, chs ) != kOkAfRC )
|
517
|
518
|
{
|
518
|
|
- rc = cmErrMsg(&p->err,kAudioFileFailSrRC,"Synchronized audio file write failed.");
|
|
519
|
+ rc = cmErrMsg(&p->err,kAudioFileFailSyRC,"Synchronized audio file write failed.");
|
519
|
520
|
break;
|
520
|
521
|
}
|
521
|
522
|
|
|
@@ -523,12 +524,12 @@ cmSrRC_t cmSyncRecdAudioFile( cmSyncRecdH_t h, const cmChar_t* fn )
|
523
|
524
|
|
524
|
525
|
errLabel:
|
525
|
526
|
if( cmAudioFileDelete(&afH) != kOkAfRC )
|
526
|
|
- rc = cmErrMsg(&p->err,kAudioFileFailSrRC,"Synchronized audio file close failed.");
|
|
527
|
+ rc = cmErrMsg(&p->err,kAudioFileFailSyRC,"Synchronized audio file close failed.");
|
527
|
528
|
|
528
|
529
|
return rc;
|
529
|
530
|
}
|
530
|
531
|
|
531
|
|
-cmSrRC_t cmSyncRecdTest( cmCtx_t* ctx )
|
|
532
|
+cmSyRC_t cmSyncRecdTest( cmCtx_t* ctx )
|
532
|
533
|
{
|
533
|
534
|
enum
|
534
|
535
|
{
|
|
@@ -536,7 +537,7 @@ cmSrRC_t cmSyncRecdTest( cmCtx_t* ctx )
|
536
|
537
|
kTestFailRC,
|
537
|
538
|
};
|
538
|
539
|
|
539
|
|
- cmSrRC_t rc = kOkSrRC;
|
|
540
|
+ cmSyRC_t rc = kOkSyRC;
|
540
|
541
|
const cmChar_t* srFn = "/home/kevin/temp/kr/sr/sr0.sr";
|
541
|
542
|
const cmChar_t* aFn = "/home/kevin/temp/kr/sr/sync_af.aiff";
|
542
|
543
|
cmErr_t err;
|
|
@@ -545,7 +546,7 @@ cmSrRC_t cmSyncRecdTest( cmCtx_t* ctx )
|
545
|
546
|
cmErrSetup(&err,&ctx->rpt,"SyncRecdTest");
|
546
|
547
|
|
547
|
548
|
|
548
|
|
- if((rc = cmSyncRecdOpen(ctx, &srH, srFn )) != kOkSrRC )
|
|
549
|
+ if((rc = cmSyncRecdOpen(ctx, &srH, srFn )) != kOkSyRC )
|
549
|
550
|
{
|
550
|
551
|
cmErrMsg(&err,kTestFailRC,"Sync-recd open failed.");
|
551
|
552
|
goto errLabel;
|
|
@@ -555,7 +556,7 @@ cmSrRC_t cmSyncRecdTest( cmCtx_t* ctx )
|
555
|
556
|
cmSyncRecdAudioFile(srH,aFn);
|
556
|
557
|
|
557
|
558
|
errLabel:
|
558
|
|
- if((rc = cmSyncRecdFinal(&srH)) != kOkSrRC )
|
|
559
|
+ if((rc = cmSyncRecdFinal(&srH)) != kOkSyRC )
|
559
|
560
|
cmErrMsg(&err,kTestFailRC,"Sync-recd close failed.");
|
560
|
561
|
|
561
|
562
|
return rc;
|