Check specific formats before general properties
This commit is contained in:
parent
1c85273662
commit
79b95da0a3
@ -1908,7 +1908,15 @@ static ALboolean GetSourceOffset(ALsource *pSource, ALenum eName, ALfloat *pflOf
|
|||||||
break;
|
break;
|
||||||
case AL_BYTE_OFFSET:
|
case AL_BYTE_OFFSET:
|
||||||
// Take into account the original format of the Buffer
|
// 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);
|
*pflOffset = (ALfloat)(lBytesPlayed >> 1);
|
||||||
}
|
}
|
||||||
@ -1916,14 +1924,6 @@ static ALboolean GetSourceOffset(ALsource *pSource, ALenum eName, ALfloat *pflOf
|
|||||||
{
|
{
|
||||||
*pflOffset = (ALfloat)(lBytesPlayed << 1);
|
*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
|
else
|
||||||
{
|
{
|
||||||
*pflOffset = (ALfloat)lBytesPlayed;
|
*pflOffset = (ALfloat)lBytesPlayed;
|
||||||
@ -2062,7 +2062,16 @@ static ALint GetByteOffset(ALsource *pSource)
|
|||||||
{
|
{
|
||||||
case AL_BYTE_OFFSET:
|
case AL_BYTE_OFFSET:
|
||||||
// Take into consideration the original format
|
// 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 = pSource->lOffset * 2;
|
||||||
lByteOffset -= (lByteOffset % (lChannels * 2));
|
lByteOffset -= (lByteOffset % (lChannels * 2));
|
||||||
@ -2072,15 +2081,6 @@ static ALint GetByteOffset(ALsource *pSource)
|
|||||||
lByteOffset = pSource->lOffset / 2;
|
lByteOffset = pSource->lOffset / 2;
|
||||||
lByteOffset -= (lByteOffset % (lChannels * 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
|
else
|
||||||
{
|
{
|
||||||
lByteOffset = pSource->lOffset;
|
lByteOffset = pSource->lOffset;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user