aboutsummaryrefslogtreecommitdiffstats
path: root/OpenAL32
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2007-12-31 02:57:58 -0800
committerChris Robinson <[email protected]>2007-12-31 02:57:58 -0800
commit79b95da0a3084dc1ba285f4f464b67d2ac76a9eb (patch)
treeb2741e15a1a1629f54ae13e39142ead15263b92f /OpenAL32
parent1c852736620d97e2ce5be27479167046074c347e (diff)
Check specific formats before general properties
Diffstat (limited to 'OpenAL32')
-rw-r--r--OpenAL32/alSource.c38
1 files changed, 19 insertions, 19 deletions
diff --git a/OpenAL32/alSource.c b/OpenAL32/alSource.c
index 44cd8b41..9b4909c5 100644
--- a/OpenAL32/alSource.c
+++ b/OpenAL32/alSource.c
@@ -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,23 +2062,23 @@ 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))
{
- lByteOffset = pSource->lOffset * 2;
+ // 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) == 4)
+ else if (aluBytesFromFormat(pBuffer->eOriginalFormat) == 1)
{
- lByteOffset = pSource->lOffset / 2;
+ lByteOffset = pSource->lOffset * 2;
lByteOffset -= (lByteOffset % (lChannels * 2));
}
- else if ((pBuffer->eOriginalFormat == AL_FORMAT_MONO_IMA4) ||
- (pBuffer->eOriginalFormat == AL_FORMAT_STEREO_IMA4))
+ else if (aluBytesFromFormat(pBuffer->eOriginalFormat) == 4)
{
- // Round down to nearest ADPCM block
- lByteOffset = (pSource->lOffset / (36 * lChannels)) * 36 * lChannels;
- // Multiply by compression rate
- lByteOffset = (ALint)(3.6111f * (ALfloat)lByteOffset);
+ lByteOffset = pSource->lOffset / 2;
lByteOffset -= (lByteOffset % (lChannels * 2));
}
else