Check specific formats before general properties

This commit is contained in:
Chris Robinson 2007-12-31 02:57:58 -08:00
parent 1c85273662
commit 79b95da0a3

View File

@ -1908,7 +1908,15 @@ static ALboolean GetSourceOffset(ALsource *pSource, ALenum eName, ALfloat *pflOf
break;
case AL_BYTE_OFFSET:
// Take into account the original format of the Buffer
if (aluBytesFromFormat(eOriginalFormat) == 1)
if ((eOriginalFormat == AL_FORMAT_MONO_IMA4) ||
(eOriginalFormat == AL_FORMAT_STEREO_IMA4))
{
// Compression rate of the ADPCM supported is 3.6111 to 1
lBytesPlayed = (ALint)((ALfloat)lBytesPlayed / 3.6111f);
// Round down to nearest ADPCM block
*pflOffset = (ALfloat)((lBytesPlayed / (36 * lChannels)) * 36 * lChannels);
}
else if (aluBytesFromFormat(eOriginalFormat) == 1)
{
*pflOffset = (ALfloat)(lBytesPlayed >> 1);
}
@ -1916,14 +1924,6 @@ static ALboolean GetSourceOffset(ALsource *pSource, ALenum eName, ALfloat *pflOf
{
*pflOffset = (ALfloat)(lBytesPlayed << 1);
}
else if ((eOriginalFormat == AL_FORMAT_MONO_IMA4) ||
(eOriginalFormat == AL_FORMAT_STEREO_IMA4))
{
// Compression rate of the ADPCM supported is 3.6111 to 1
lBytesPlayed = (ALint)((ALfloat)lBytesPlayed / 3.6111f);
// Round down to nearest ADPCM block
*pflOffset = (ALfloat)((lBytesPlayed / (36 * lChannels)) * 36 * lChannels);
}
else
{
*pflOffset = (ALfloat)lBytesPlayed;
@ -2062,7 +2062,16 @@ static ALint GetByteOffset(ALsource *pSource)
{
case AL_BYTE_OFFSET:
// Take into consideration the original format
if (aluBytesFromFormat(pBuffer->eOriginalFormat) == 1)
if ((pBuffer->eOriginalFormat == AL_FORMAT_MONO_IMA4) ||
(pBuffer->eOriginalFormat == AL_FORMAT_STEREO_IMA4))
{
// Round down to nearest ADPCM block
lByteOffset = (pSource->lOffset / (36 * lChannels)) * 36 * lChannels;
// Multiply by compression rate
lByteOffset = (ALint)(3.6111f * (ALfloat)lByteOffset);
lByteOffset -= (lByteOffset % (lChannels * 2));
}
else if (aluBytesFromFormat(pBuffer->eOriginalFormat) == 1)
{
lByteOffset = pSource->lOffset * 2;
lByteOffset -= (lByteOffset % (lChannels * 2));
@ -2072,15 +2081,6 @@ static ALint GetByteOffset(ALsource *pSource)
lByteOffset = pSource->lOffset / 2;
lByteOffset -= (lByteOffset % (lChannels * 2));
}
else if ((pBuffer->eOriginalFormat == AL_FORMAT_MONO_IMA4) ||
(pBuffer->eOriginalFormat == AL_FORMAT_STEREO_IMA4))
{
// Round down to nearest ADPCM block
lByteOffset = (pSource->lOffset / (36 * lChannels)) * 36 * lChannels;
// Multiply by compression rate
lByteOffset = (ALint)(3.6111f * (ALfloat)lByteOffset);
lByteOffset -= (lByteOffset % (lChannels * 2));
}
else
{
lByteOffset = pSource->lOffset;