cwFlowProc : 'audio_file_in' and 'audio_file_out' now use proc_expand_filename().
This commit is contained in:
parent
a4dc668640
commit
04e85138c1
@ -846,7 +846,7 @@ namespace cw
|
|||||||
{
|
{
|
||||||
audiofile::handle_t afH;
|
audiofile::handle_t afH;
|
||||||
bool eofFl;
|
bool eofFl;
|
||||||
const char* filename;
|
char* filename;
|
||||||
} inst_t;
|
} inst_t;
|
||||||
|
|
||||||
rc_t create( proc_t* proc )
|
rc_t create( proc_t* proc )
|
||||||
@ -854,6 +854,7 @@ namespace cw
|
|||||||
rc_t rc = kOkRC;
|
rc_t rc = kOkRC;
|
||||||
audiofile::info_t info;
|
audiofile::info_t info;
|
||||||
ftime_t seekSecs;
|
ftime_t seekSecs;
|
||||||
|
const char* fname = nullptr;
|
||||||
inst_t* inst = mem::allocZ<inst_t>();
|
inst_t* inst = mem::allocZ<inst_t>();
|
||||||
proc->userPtr = inst;
|
proc->userPtr = inst;
|
||||||
|
|
||||||
@ -864,13 +865,20 @@ namespace cw
|
|||||||
|
|
||||||
// Register variable and get their current value
|
// Register variable and get their current value
|
||||||
if((rc = var_register_and_get( proc, kAnyChIdx,
|
if((rc = var_register_and_get( proc, kAnyChIdx,
|
||||||
kFnamePId, "fname", kBaseSfxId, inst->filename,
|
kFnamePId, "fname", kBaseSfxId, fname,
|
||||||
kSeekSecsPId, "seekSecs", kBaseSfxId, seekSecs,
|
kSeekSecsPId, "seekSecs", kBaseSfxId, seekSecs,
|
||||||
kEofFlPId, "eofFl", kBaseSfxId, inst->eofFl )) != kOkRC )
|
kEofFlPId, "eofFl", kBaseSfxId, inst->eofFl )) != kOkRC )
|
||||||
{
|
{
|
||||||
goto errLabel;
|
goto errLabel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if((inst->filename = proc_expand_filename(proc,fname)) == nullptr )
|
||||||
|
{
|
||||||
|
rc = cwLogError(kInvalidArgRC,"The audio output filename could not be formed.");
|
||||||
|
goto errLabel;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// open the audio file
|
// open the audio file
|
||||||
if((rc = audiofile::open(inst->afH,inst->filename,&info)) != kOkRC )
|
if((rc = audiofile::open(inst->afH,inst->filename,&info)) != kOkRC )
|
||||||
{
|
{
|
||||||
@ -905,6 +913,7 @@ namespace cw
|
|||||||
rc = cwLogError(kOpFailRC,"The close failed on the audio file '%s'.", cwStringNullGuard(inst->filename) );
|
rc = cwLogError(kOpFailRC,"The close failed on the audio file '%s'.", cwStringNullGuard(inst->filename) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mem::release(inst->filename);
|
||||||
mem::release(inst);
|
mem::release(inst);
|
||||||
|
|
||||||
return rc;
|
return rc;
|
||||||
@ -1000,7 +1009,7 @@ namespace cw
|
|||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
audiofile::handle_t afH;
|
audiofile::handle_t afH;
|
||||||
const char* filename;
|
char* filename;
|
||||||
unsigned durSmpN;
|
unsigned durSmpN;
|
||||||
} inst_t;
|
} inst_t;
|
||||||
|
|
||||||
@ -1010,17 +1019,26 @@ namespace cw
|
|||||||
unsigned audioFileBits = 0; // set audio file sample format to 'float32'.
|
unsigned audioFileBits = 0; // set audio file sample format to 'float32'.
|
||||||
inst_t* inst = mem::allocZ<inst_t>(); //
|
inst_t* inst = mem::allocZ<inst_t>(); //
|
||||||
const abuf_t* src_abuf = nullptr;
|
const abuf_t* src_abuf = nullptr;
|
||||||
|
const char* fname = nullptr;
|
||||||
|
|
||||||
proc->userPtr = inst;
|
proc->userPtr = inst;
|
||||||
|
|
||||||
// Register variables and get their current value
|
// Register variables and get their current value
|
||||||
if((rc = var_register_and_get( proc, kAnyChIdx,
|
if((rc = var_register_and_get( proc, kAnyChIdx,
|
||||||
kFnamePId, "fname", kBaseSfxId, inst->filename,
|
kFnamePId, "fname", kBaseSfxId, fname,
|
||||||
kBitsPId, "bits", kBaseSfxId, audioFileBits,
|
kBitsPId, "bits", kBaseSfxId, audioFileBits,
|
||||||
kInPId, "in", kBaseSfxId, src_abuf )) != kOkRC )
|
kInPId, "in", kBaseSfxId, src_abuf )) != kOkRC )
|
||||||
{
|
{
|
||||||
goto errLabel;
|
goto errLabel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if((inst->filename = proc_expand_filename(proc,fname)) == nullptr )
|
||||||
|
{
|
||||||
|
rc = cwLogError(kInvalidArgRC,"The audio output filename could not be formed.");
|
||||||
|
goto errLabel;
|
||||||
|
}
|
||||||
|
|
||||||
// create the audio file with the same channel count as the incoming signal
|
// create the audio file with the same channel count as the incoming signal
|
||||||
if((rc = audiofile::create( inst->afH, inst->filename, src_abuf->srate, audioFileBits, src_abuf->chN)) != kOkRC )
|
if((rc = audiofile::create( inst->afH, inst->filename, src_abuf->srate, audioFileBits, src_abuf->chN)) != kOkRC )
|
||||||
{
|
{
|
||||||
@ -1044,6 +1062,7 @@ namespace cw
|
|||||||
goto errLabel;
|
goto errLabel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mem::release(inst->filename);
|
||||||
mem::release(inst);
|
mem::release(inst);
|
||||||
|
|
||||||
errLabel:
|
errLabel:
|
||||||
|
Loading…
Reference in New Issue
Block a user