Browse Source

cmSyncRecd.h/c : Changed result codes from cmXXXSrRC to cmXXXSyRc to avoid

conflicts with same named result codes from cmSerialize.h.
master
kevin 10 years ago
parent
commit
c8d4648af5
2 changed files with 73 additions and 72 deletions
  1. 62
    61
      cmSyncRecd.c
  2. 11
    11
      cmSyncRecd.h

+ 62
- 61
cmSyncRecd.c View File

11
 #include "cmSyncRecd.h"
11
 #include "cmSyncRecd.h"
12
 #include "cmVectOpsTemplateMain.h"
12
 #include "cmVectOpsTemplateMain.h"
13
 #include "cmMidi.h"
13
 #include "cmMidi.h"
14
+
14
 typedef enum
15
 typedef enum
15
 {
16
 {
16
   kInvalidSrId,
17
   kInvalidSrId,
76
   return p;
77
   return p;
77
 }
78
 }
78
 
79
 
79
-cmSrRC_t _cmSrWriteCache( cmSr_t* p )
80
+cmSyRC_t _cmSrWriteCache( cmSr_t* p )
80
 {
81
 {
81
   if( cmFileWrite(p->fH,p->cache,p->ci * sizeof(cmSrRecd_t)) != kOkFileRC )
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
   p->fn += p->ci;
85
   p->fn += p->ci;
85
   p->ci = 0;
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
   // write any remaining cache records
96
   // write any remaining cache records
96
   if( cmIsFlag(p->flags,kReadSrFl) == false )
97
   if( cmIsFlag(p->flags,kReadSrFl) == false )
97
   {
98
   {
98
-    if((rc = _cmSrWriteCache(p)) == kOkSrRC )
99
+    if((rc = _cmSrWriteCache(p)) == kOkSyRC )
99
     {
100
     {
100
       if(cmFileSeek(p->fH,kBeginFileFl,p->offs) != kOkFileRC )
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
       else
103
       else
103
         if(cmFileWriteUInt(p->fH,&p->fn,1) != kOkFileRC )
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
   // release the audio file object
109
   // release the audio file object
109
   if( cmAudioFileIsValid(p->afH) )
110
   if( cmAudioFileIsValid(p->afH) )
110
     if( cmAudioFileDelete(&p->afH) != kOkAfRC )
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
   // release the sync-recd file object
114
   // release the sync-recd file object
114
   if( cmFileIsValid(p->fH) )
115
   if( cmFileIsValid(p->fH) )
115
     if( cmFileClose(&p->fH) != kOkFileRC )
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
   cmMemFree(p->cache);
119
   cmMemFree(p->cache);
119
   cmMemFree(p->map);
120
   cmMemFree(p->map);
134
   return p;
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
   cmRC_t   afRC = kOkAfRC;
141
   cmRC_t   afRC = kOkAfRC;
141
 
142
 
142
   assert( audioFn != NULL );
143
   assert( audioFn != NULL );
143
 
144
 
144
-  if((rc = cmSyncRecdFinal(hp)) != kOkSrRC )
145
+  if((rc = cmSyncRecdFinal(hp)) != kOkSyRC )
145
     return rc;
146
     return rc;
146
 
147
 
147
   cmSr_t* p = _cmSrAlloc(ctx,0);
148
   cmSr_t* p = _cmSrAlloc(ctx,0);
148
 
149
 
149
   if( cmFileOpen(&p->fH,srFn,kWriteFileFl,&ctx->rpt) != kOkFileRC )
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
     goto errLabel;
153
     goto errLabel;
153
   }
154
   }
154
 
155
 
155
   if( cmAudioFileIsValid(p->afH = cmAudioFileNewCreate(audioFn,srate,bits,chCnt,&afRC,&ctx->rpt))==false)
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
     goto errLabel;
159
     goto errLabel;
159
   }
160
   }
160
 
161
 
163
 
164
 
164
   if( cmFileWriteUInt(p->fH,&fileUUId,1) != kOkFileRC )
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
     goto errLabel;
168
     goto errLabel;
168
   }
169
   }
169
 
170
 
170
   if( cmFileWriteUInt(p->fH,&audioFnCnt,1) != kOkFileRC )
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
     goto errLabel;
174
     goto errLabel;
174
   }
175
   }
175
 
176
 
176
   if( cmFileWriteChar(p->fH,audioFn,audioFnCnt) != kOkFileRC )
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
     goto errLabel;
180
     goto errLabel;
180
   }
181
   }
181
 
182
 
182
   if( cmFileTell(p->fH,&p->offs) != kOkFileRC )
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
     goto errLabel;
186
     goto errLabel;
186
   }
187
   }
187
 
188
 
188
   if( cmFileWriteUInt(p->fH,&p->fn,1) != kOkFileRC )
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
     goto errLabel;
192
     goto errLabel;
192
   }
193
   }
193
 
194
 
194
   hp->h = p;
195
   hp->h = p;
195
 
196
 
196
  errLabel:
197
  errLabel:
197
-  if( rc != kOkSrRC )
198
+  if( rc != kOkSyRC )
198
     _cmSrFinal(p);
199
     _cmSrFinal(p);
199
 
200
 
200
   return rc;
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
   cmRC_t    afRC       = kOkAfRC;
208
   cmRC_t    afRC       = kOkAfRC;
208
   unsigned  fileUUId   = cmInvalidId;
209
   unsigned  fileUUId   = cmInvalidId;
209
   unsigned  audioFnCnt = 0;
210
   unsigned  audioFnCnt = 0;
213
   unsigned mcnt = 0;
214
   unsigned mcnt = 0;
214
   unsigned* tiV  = NULL;
215
   unsigned* tiV  = NULL;
215
 
216
 
216
-  if((rc = cmSyncRecdFinal(hp)) != kOkSrRC )
217
+  if((rc = cmSyncRecdFinal(hp)) != kOkSyRC )
217
     return rc;
218
     return rc;
218
 
219
 
219
   cmSr_t* p = _cmSrAlloc(ctx,kReadSrFl);
220
   cmSr_t* p = _cmSrAlloc(ctx,kReadSrFl);
220
 
221
 
221
   if( cmFileOpen(&p->fH,srFn,kReadFileFl,&ctx->rpt) != kOkFileRC )
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
     goto errLabel;
225
     goto errLabel;
225
   }
226
   }
226
 
227
 
227
   if( cmFileReadUInt(p->fH,&fileUUId,1) != kOkFileRC )
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
     goto errLabel;
231
     goto errLabel;
231
   }
232
   }
232
 
233
 
233
   if( cmFileReadUInt(p->fH,&audioFnCnt,1) != kOkFileRC )
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
     goto errLabel;
237
     goto errLabel;
237
   }
238
   }
238
 
239
 
240
 
241
 
241
   if( cmFileReadChar(p->fH,audioFn,audioFnCnt) != kOkFileRC )
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
     goto errLabel;
245
     goto errLabel;
245
   }
246
   }
246
 
247
 
247
   if( cmFileReadUInt(p->fH,&p->fn,1) != kOkFileRC )
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
     goto errLabel;
251
     goto errLabel;
251
   }
252
   }
252
 
253
 
253
   // store the file offset to the first recd
254
   // store the file offset to the first recd
254
   if( cmFileTell(p->fH,&p->offs) != kOkFileRC )
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
     goto errLabel;
258
     goto errLabel;
258
   }
259
   }
259
 
260
 
264
     cmSrRecd_t r;
265
     cmSrRecd_t r;
265
     if( cmFileRead(p->fH,&r,sizeof(r)) != kOkFileRC )
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
       goto errLabel;
269
       goto errLabel;
269
     }
270
     }
270
 
271
 
288
   // rewind to the begining of the records
289
   // rewind to the begining of the records
289
   if( cmFileSeek(p->fH,kBeginFileFl,p->offs) != kOkFileRC )
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
     goto errLabel;
293
     goto errLabel;
293
   }
294
   }
294
 
295
 
303
   {
304
   {
304
     if( cmFileRead(p->fH,p->cache + p->ci,sizeof(cmSrRecd_t)) != kOkFileRC )
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
       goto errLabel;
308
       goto errLabel;
308
     }
309
     }
309
 
310
 
317
   // rewind to the first recd
318
   // rewind to the first recd
318
   if( cmFileSeek(p->fH,kBeginFileFl,p->offs) != kOkFileRC )
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
     goto errLabel;
322
     goto errLabel;
322
   }
323
   }
323
 
324
 
328
     cmSrRecd_t r;
329
     cmSrRecd_t r;
329
     if( cmFileRead(p->fH,&r,sizeof(r)) != kOkFileRC )
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
       goto errLabel;
333
       goto errLabel;
333
     }
334
     }
334
 
335
 
358
   // open the audio file
359
   // open the audio file
359
   if( cmAudioFileIsValid(p->afH = cmAudioFileNewOpen(audioFn,&p->afInfo,&afRC,&ctx->rpt ))==false)
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
     goto errLabel;
363
     goto errLabel;
363
   }
364
   }
364
  
365
  
371
   cmMemFree(tiV);
372
   cmMemFree(tiV);
372
   cmMemFree(audioFn);
373
   cmMemFree(audioFn);
373
 
374
 
374
-  if( rc != kOkSrRC )
375
+  if( rc != kOkSyRC )
375
     _cmSrFinal(p);
376
     _cmSrFinal(p);
376
 
377
 
377
   return rc;
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
   if( hp==NULL || cmSyncRecdIsValid(*hp)==false)
385
   if( hp==NULL || cmSyncRecdIsValid(*hp)==false)
385
     return rc;
386
     return rc;
386
 
387
 
387
   cmSr_t* p = _cmSrHtoP(*hp);
388
   cmSr_t* p = _cmSrHtoP(*hp);
388
 
389
 
389
-  if((rc = _cmSrFinal(p)) != kOkSrRC )
390
+  if((rc = _cmSrFinal(p)) != kOkSyRC )
390
     return rc;
391
     return rc;
391
 
392
 
392
   hp->h = NULL;
393
   hp->h = NULL;
397
 bool     cmSyncRecdIsValid( cmSyncRecdH_t h )
398
 bool     cmSyncRecdIsValid( cmSyncRecdH_t h )
398
 { return h.h != NULL; }
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
   cmSr_t*     p     = _cmSrHtoP(h);
404
   cmSr_t*     p     = _cmSrHtoP(h);
404
   cmSrRecd_t* rp    = p->cache + p->ci;
405
   cmSrRecd_t* rp    = p->cache + p->ci;
405
   rp->tid           = kMidiSrId;
406
   rp->tid           = kMidiSrId;
416
   return rc;
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
   cmSr_t*     p     = _cmSrHtoP(h);
423
   cmSr_t*     p     = _cmSrHtoP(h);
423
   cmSrRecd_t* rp    = p->cache + p->ci;
424
   cmSrRecd_t* rp    = p->cache + p->ci;
424
   rp->tid           = kAudioSrId;
425
   rp->tid           = kAudioSrId;
428
   p->ci += 1;
429
   p->ci += 1;
429
 
430
 
430
   if( p->ci == p->cn )
431
   if( p->ci == p->cn )
431
-    if((rc = _cmSrWriteCache(p)) != kOkSrRC )
432
+    if((rc = _cmSrWriteCache(p)) != kOkSyRC )
432
       goto errLabel;
433
       goto errLabel;
433
 
434
 
434
   if( cmAudioFileWriteSample(p->afH,frmCnt,chCnt,(cmSample_t**)ch) != kOkAfRC )
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
  errLabel:
438
  errLabel:
438
   return rc;
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
   cmSr_t*  p  = _cmSrHtoP(h);
446
   cmSr_t*  p  = _cmSrHtoP(h);
446
   unsigned i;
447
   unsigned i;
447
 
448
 
448
   if( cmIsFlag(p->flags,kReadSrFl)==false)
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
   for(i=0; i<p->cn; ++i)
452
   for(i=0; i<p->cn; ++i)
452
   {
453
   {
457
   return rc;
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
   cmSr_t*        p         = _cmSrHtoP(h);
464
   cmSr_t*        p         = _cmSrHtoP(h);
464
   cmAudioFileH_t afH       = cmNullAudioFileH;
465
   cmAudioFileH_t afH       = cmNullAudioFileH;
465
   unsigned       chCnt     = 2;
466
   unsigned       chCnt     = 2;
474
   chs[1] = buf+frmCnt;
475
   chs[1] = buf+frmCnt;
475
 
476
 
476
   if( cmIsFlag(p->flags,kReadSrFl)==false)
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
   /// Open an audio file for writing
480
   /// Open an audio file for writing
480
   if(cmAudioFileIsValid(afH = cmAudioFileNewCreate(fn, p->afInfo.srate, p->afInfo.bits, chCnt, &afRC, p->err.rpt))==false)
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
     goto errLabel;
484
     goto errLabel;
484
   }
485
   }
485
   
486
   
486
   // rewind the input audio file
487
   // rewind the input audio file
487
   if( cmAudioFileSeek(p->afH,0) != kOkAfRC )
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
     goto errLabel;
491
     goto errLabel;
491
   }
492
   }
492
 
493
 
500
     // read frmCnt samples from the first channel of the input audio file
501
     // read frmCnt samples from the first channel of the input audio file
501
     if( cmAudioFileReadSample(p->afH, frmCnt, chIdx, 1, chs, &actFrmCnt ) != kOkAfRC )
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
       break;
505
       break;
505
     }
506
     }
506
 
507
 
515
     // write the audio output samples
516
     // write the audio output samples
516
     if( cmAudioFileWriteSample(afH, frmCnt, chCnt, chs ) != kOkAfRC )
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
       break;
520
       break;
520
     }    
521
     }    
521
 
522
 
523
 
524
 
524
  errLabel:
525
  errLabel:
525
   if( cmAudioFileDelete(&afH) != kOkAfRC )
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
   return rc;
529
   return rc;
529
 }
530
 }
530
 
531
 
531
-cmSrRC_t cmSyncRecdTest( cmCtx_t* ctx )
532
+cmSyRC_t cmSyncRecdTest( cmCtx_t* ctx )
532
 {
533
 {
533
   enum
534
   enum
534
   {
535
   {
536
     kTestFailRC,
537
     kTestFailRC,
537
   };
538
   };
538
 
539
 
539
-  cmSrRC_t rc = kOkSrRC;
540
+  cmSyRC_t rc = kOkSyRC;
540
   const cmChar_t* srFn = "/home/kevin/temp/kr/sr/sr0.sr";
541
   const cmChar_t* srFn = "/home/kevin/temp/kr/sr/sr0.sr";
541
   const cmChar_t* aFn  = "/home/kevin/temp/kr/sr/sync_af.aiff";
542
   const cmChar_t* aFn  = "/home/kevin/temp/kr/sr/sync_af.aiff";
542
   cmErr_t err;
543
   cmErr_t err;
545
   cmErrSetup(&err,&ctx->rpt,"SyncRecdTest");
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
     cmErrMsg(&err,kTestFailRC,"Sync-recd open failed.");
551
     cmErrMsg(&err,kTestFailRC,"Sync-recd open failed.");
551
     goto errLabel;
552
     goto errLabel;
555
   cmSyncRecdAudioFile(srH,aFn);
556
   cmSyncRecdAudioFile(srH,aFn);
556
 
557
 
557
  errLabel:
558
  errLabel:
558
-  if((rc = cmSyncRecdFinal(&srH)) != kOkSrRC )
559
+  if((rc = cmSyncRecdFinal(&srH)) != kOkSyRC )
559
     cmErrMsg(&err,kTestFailRC,"Sync-recd close failed.");
560
     cmErrMsg(&err,kTestFailRC,"Sync-recd close failed.");
560
 
561
 
561
   return rc;
562
   return rc;

+ 11
- 11
cmSyncRecd.h View File

7
 
7
 
8
   enum
8
   enum
9
   {
9
   {
10
-    kOkSrRC,
11
-    kFileFailSrRC,
12
-    kAudioFileFailSrRC,
13
-    kInvalidOpSrRC
10
+    kOkSyRC,
11
+    kFileFailSyRC,
12
+    kAudioFileFailSyRC,
13
+    kInvalidOpSyRC
14
   };
14
   };
15
 
15
 
16
   typedef cmHandle_t cmSyncRecdH_t;
16
   typedef cmHandle_t cmSyncRecdH_t;
17
-  typedef cmRC_t     cmSrRC_t;
17
+  typedef cmRC_t     cmSyRC_t;
18
   extern cmSyncRecdH_t cmSyncRecdNullHandle;
18
   extern cmSyncRecdH_t cmSyncRecdNullHandle;
19
   
19
   
20
-  cmSrRC_t cmSyncRecdCreate(  cmCtx_t* ctx, cmSyncRecdH_t* hp, const cmChar_t* srFn, const cmChar_t* audioFn, double srate, unsigned chCnt, unsigned bits );
21
-  cmSrRC_t cmSyncRecdOpen(    cmCtx_t* ctx, cmSyncRecdH_t* hp, const cmChar_t* srFn );
22
-  cmSrRC_t cmSyncRecdFinal(   cmSyncRecdH_t* hp );
20
+  cmSyRC_t cmSyncRecdCreate(  cmCtx_t* ctx, cmSyncRecdH_t* hp, const cmChar_t* srFn, const cmChar_t* audioFn, double srate, unsigned chCnt, unsigned bits );
21
+  cmSyRC_t cmSyncRecdOpen(    cmCtx_t* ctx, cmSyncRecdH_t* hp, const cmChar_t* srFn );
22
+  cmSyRC_t cmSyncRecdFinal(   cmSyncRecdH_t* hp );
23
   bool     cmSyncRecdIsValid( cmSyncRecdH_t h );
23
   bool     cmSyncRecdIsValid( cmSyncRecdH_t h );
24
 
24
 
25
-  cmSrRC_t cmSyncRecdMidiWrite(  cmSyncRecdH_t h, const cmTimeSpec_t* timestamp, unsigned status, unsigned d0, unsigned d1 );
26
-  cmSrRC_t cmSyncRecdAudioWrite( cmSyncRecdH_t h, const cmTimeSpec_t* timestamp, unsigned smpIdx, const cmSample_t* ch[], unsigned chCnt, unsigned frmCnt );
25
+  cmSyRC_t cmSyncRecdMidiWrite(  cmSyncRecdH_t h, const cmTimeSpec_t* timestamp, unsigned status, unsigned d0, unsigned d1 );
26
+  cmSyRC_t cmSyncRecdAudioWrite( cmSyncRecdH_t h, const cmTimeSpec_t* timestamp, unsigned smpIdx, const cmSample_t* ch[], unsigned chCnt, unsigned frmCnt );
27
   
27
   
28
 
28
 
29
-  cmSrRC_t cmSyncRecdTest( cmCtx_t* ctx );
29
+  cmSyRC_t cmSyncRecdTest( cmCtx_t* ctx );
30
 
30
 
31
 #ifdef __cplusplus
31
 #ifdef __cplusplus
32
 }
32
 }

Loading…
Cancel
Save