Fix potential divide-by-0

This commit is contained in:
Chris Robinson 2011-10-01 08:37:42 -07:00
parent 8b2e1fdd9a
commit 2f453eba35

View File

@ -844,9 +844,12 @@ AL_API ALvoid AL_APIENTRY alGetBufferf(ALuint buffer, ALenum eParam, ALfloat *pf
{
case AL_SEC_LENGTH:
ReadLock(&pBuffer->lock);
*pflValue = (pBuffer->size /
FrameSizeFromFmt(pBuffer->FmtChannels, pBuffer->FmtType)) /
(ALfloat)pBuffer->Frequency;
if(pBuffer->size != 0)
*pflValue = (pBuffer->size /
FrameSizeFromFmt(pBuffer->FmtChannels, pBuffer->FmtType)) /
(ALfloat)pBuffer->Frequency;
else
*pflValue = 0.0f;
ReadUnlock(&pBuffer->lock);
break;
@ -965,8 +968,11 @@ AL_API ALvoid AL_APIENTRY alGetBufferi(ALuint buffer, ALenum eParam, ALint *plVa
case AL_SAMPLE_LENGTH:
ReadLock(&pBuffer->lock);
*plValue = pBuffer->size /
FrameSizeFromFmt(pBuffer->FmtChannels, pBuffer->FmtType);
if(pBuffer->size != 0)
*plValue = pBuffer->size /
FrameSizeFromFmt(pBuffer->FmtChannels, pBuffer->FmtType);
else
*plValue = 0;
ReadUnlock(&pBuffer->lock);
break;