cmAudioFile.h/c : Fixed crash bug in cmAudioFilecreate() caused by using a file name without and extension.
_cmAudioFileReadInt() now returns in error instead of asserting when an invalid input channel count is encountered.
This commit is contained in:
parent
d863299265
commit
e65764d7a4
@ -75,6 +75,7 @@ cmAudioErrRecd _cmAudioFileErrArray[] =
|
|||||||
{ kInvalidBitWidthAfRC, "Invalid audio file bit width."},
|
{ kInvalidBitWidthAfRC, "Invalid audio file bit width."},
|
||||||
{ kInvalidFileModeAfRC, "Invalid audio file mode."},
|
{ kInvalidFileModeAfRC, "Invalid audio file mode."},
|
||||||
{ kInvalidHandleAfRC, "Invalid audio file handle."},
|
{ kInvalidHandleAfRC, "Invalid audio file handle."},
|
||||||
|
{ kInvalidChCountAfRC, "Invalid channel index or count."},
|
||||||
{ kUnknownErrAfRC, "Uknown audio file error."}
|
{ kUnknownErrAfRC, "Uknown audio file error."}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -696,18 +697,22 @@ cmRC_t cmAudioFileCreate( cmAudioFileH_t h, const cmChar_t* fn, double srat
|
|||||||
return rc;
|
return rc;
|
||||||
|
|
||||||
// all audio files are written as AIF's - if the file name is given some other extension then issue a warning
|
// all audio files are written as AIF's - if the file name is given some other extension then issue a warning
|
||||||
if( strlen(fn) && ((pp = cmFsPathParts(fn)) != NULL) )
|
if( fn!=NULL && strlen(fn) && ((pp = cmFsPathParts(fn)) != NULL) )
|
||||||
{
|
{
|
||||||
unsigned i;
|
unsigned i;
|
||||||
unsigned n = strlen(pp->extStr);
|
unsigned n = pp->extStr==NULL ? 0 : strlen(pp->extStr);
|
||||||
cmChar_t ext[n+1];
|
cmChar_t ext[n+1];
|
||||||
strcpy(ext,pp->extStr);
|
|
||||||
|
|
||||||
// convert the extension to upper case
|
if( pp->extStr != NULL )
|
||||||
for(i=0; i<n; ++i)
|
{
|
||||||
ext[i] = toupper(ext[i]);
|
strcpy(ext,pp->extStr);
|
||||||
|
|
||||||
if( strcmp(ext,"AIF") && strcmp(ext,"AIFF") )
|
// convert the extension to upper case
|
||||||
|
for(i=0; i<n; ++i)
|
||||||
|
ext[i] = toupper(ext[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
if( pp->extStr==NULL || (strcmp(ext,"AIF") && strcmp(ext,"AIFF")) )
|
||||||
cmRptPrintf(p->err.rpt,"The AIF audio file '%s' is being written with a file extension other than 'AIF' or 'AIFF'.",cmStringNullGuard(fn));
|
cmRptPrintf(p->err.rpt,"The AIF audio file '%s' is being written with a file extension other than 'AIF' or 'AIFF'.",cmStringNullGuard(fn));
|
||||||
|
|
||||||
cmFsFreePathParts(pp);
|
cmFsFreePathParts(pp);
|
||||||
@ -845,6 +850,9 @@ cmRC_t _cmAudioFileReadInt( cmAudioFileH_t h, unsigned totalFrmCnt, unsigned chI
|
|||||||
if( rc != kOkAfRC )
|
if( rc != kOkAfRC )
|
||||||
return rc;
|
return rc;
|
||||||
|
|
||||||
|
if( chIdx+chCnt > p->info.chCnt )
|
||||||
|
return _cmAudioFileError(p,kInvalidChCountAfRC);
|
||||||
|
|
||||||
if( actualFrmCntPtr != NULL )
|
if( actualFrmCntPtr != NULL )
|
||||||
*actualFrmCntPtr = 0;
|
*actualFrmCntPtr = 0;
|
||||||
|
|
||||||
|
@ -37,6 +37,7 @@ extern "C" {
|
|||||||
kInvalidBitWidthAfRC,
|
kInvalidBitWidthAfRC,
|
||||||
kInvalidFileModeAfRC,
|
kInvalidFileModeAfRC,
|
||||||
kInvalidHandleAfRC,
|
kInvalidHandleAfRC,
|
||||||
|
kInvalidChCountAfRC,
|
||||||
kUnknownErrAfRC
|
kUnknownErrAfRC
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user