cwFlowTypes.cpp : abuf_create() now indicates an error when the channel count or frame count arg's are invalid.

This commit is contained in:
kevin 2024-07-11 11:03:26 -04:00
parent 332c8309f6
commit c1231d48ef

View File

@ -1194,11 +1194,19 @@ void cw::flow::value_print( const value_t* value, bool info_fl)
cw::flow::abuf_t* cw::flow::abuf_create( srate_t srate, unsigned chN, unsigned frameN )
{
if( chN*frameN == 0 )
{
cwLogError(kInvalidArgRC,"The %s audio signal parameter cannot be zero.", chN==0 ? "channel count" : "frame count");
return nullptr;
}
abuf_t* a = mem::allocZ<abuf_t>();
a->srate = srate;
a->chN = chN;
a->frameN = frameN;
a->bufAllocSmpN = chN*frameN;
a->buf = mem::allocZ<sample_t>(a->bufAllocSmpN);
return a;
@ -1225,6 +1233,7 @@ cw::flow::abuf_t* cw::flow::abuf_duplicate( abuf_t* dst, const abuf_t* src )
else
abuf = dst;
if( abuf != nullptr )
vop::copy(abuf->buf,src->buf,src->chN*src->frameN);
return abuf;