cwFlowTypes.cpp : abuf_create() now indicates an error when the channel count or frame count arg's are invalid.
This commit is contained in:
parent
332c8309f6
commit
c1231d48ef
@ -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 )
|
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>();
|
abuf_t* a = mem::allocZ<abuf_t>();
|
||||||
a->srate = srate;
|
a->srate = srate;
|
||||||
a->chN = chN;
|
a->chN = chN;
|
||||||
a->frameN = frameN;
|
a->frameN = frameN;
|
||||||
a->bufAllocSmpN = chN*frameN;
|
a->bufAllocSmpN = chN*frameN;
|
||||||
|
|
||||||
|
|
||||||
a->buf = mem::allocZ<sample_t>(a->bufAllocSmpN);
|
a->buf = mem::allocZ<sample_t>(a->bufAllocSmpN);
|
||||||
|
|
||||||
return a;
|
return a;
|
||||||
@ -1225,6 +1233,7 @@ cw::flow::abuf_t* cw::flow::abuf_duplicate( abuf_t* dst, const abuf_t* src )
|
|||||||
else
|
else
|
||||||
abuf = dst;
|
abuf = dst;
|
||||||
|
|
||||||
|
if( abuf != nullptr )
|
||||||
vop::copy(abuf->buf,src->buf,src->chN*src->frameN);
|
vop::copy(abuf->buf,src->buf,src->chN*src->frameN);
|
||||||
|
|
||||||
return abuf;
|
return abuf;
|
||||||
|
Loading…
Reference in New Issue
Block a user