aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2010-03-17 15:15:12 -0700
committerChris Robinson <[email protected]>2010-03-17 15:15:12 -0700
commitdd82b68175e2edca9b126ea109292890fdafcad5 (patch)
tree02e98882fe0b60eaf8d1c4d9a29143f53e74295d
parent05a081a7b8660a90b1000f0727fda5a29e8fe3fa (diff)
Handle source offsets for muLaw formats
-rw-r--r--OpenAL32/alSource.c42
1 files changed, 31 insertions, 11 deletions
diff --git a/OpenAL32/alSource.c b/OpenAL32/alSource.c
index a2c24a12..7dbe8452 100644
--- a/OpenAL32/alSource.c
+++ b/OpenAL32/alSource.c
@@ -1908,6 +1908,21 @@ static ALboolean GetSourceOffset(ALsource *pSource, ALenum eName, ALfloat *pflOf
else
pflOffset[1] = pflOffset[0];
}
+ else if(eOriginalFormat == AL_FORMAT_MONO_MULAW ||
+ eOriginalFormat == AL_FORMAT_STEREO_MULAW ||
+ eOriginalFormat == AL_FORMAT_QUAD_MULAW ||
+ eOriginalFormat == AL_FORMAT_51CHN_MULAW ||
+ eOriginalFormat == AL_FORMAT_61CHN_MULAW ||
+ eOriginalFormat == AL_FORMAT_71CHN_MULAW)
+ {
+ pflOffset[0] = (ALfloat)(readPos / lBytes * 1);
+ pflOffset[1] = (ALfloat)(writePos / lBytes * 1);
+ }
+ else if(eOriginalFormat == AL_FORMAT_REAR_MULAW)
+ {
+ pflOffset[0] = (ALfloat)(readPos / 2 / lBytes * 1);
+ pflOffset[1] = (ALfloat)(writePos / 2 / lBytes * 1);
+ }
else if (eOriginalFormat == AL_FORMAT_REAR8)
{
pflOffset[0] = (ALfloat)(readPos / 2 / lBytes * 1);
@@ -2047,31 +2062,36 @@ static ALint GetByteOffset(ALsource *pSource)
{
// Round down to nearest ADPCM block
lByteOffset = pSource->lOffset / (36 * lChannels);
- // Multiply by compression rate
+ // Multiply by compression rate (65 samples per 36 byte block)
lByteOffset = lByteOffset * 65 * lChannels * lBytes;
- lByteOffset -= (lByteOffset % (lChannels * lBytes));
}
- else if(OriginalFormat == AL_FORMAT_REAR8)
+ else if(OriginalFormat == AL_FORMAT_MONO_MULAW ||
+ OriginalFormat == AL_FORMAT_STEREO_MULAW ||
+ OriginalFormat == AL_FORMAT_QUAD_MULAW ||
+ OriginalFormat == AL_FORMAT_51CHN_MULAW ||
+ OriginalFormat == AL_FORMAT_61CHN_MULAW ||
+ OriginalFormat == AL_FORMAT_71CHN_MULAW)
{
+ /* muLaw has 1 byte per sample */
+ lByteOffset = pSource->lOffset / 1 * lBytes;
+ }
+ else if(OriginalFormat == AL_FORMAT_REAR_MULAW)
+ {
+ /* Rear is converted from 2 -> 4 channel */
lByteOffset = pSource->lOffset / 1 * lBytes * 2;
- lByteOffset -= (lByteOffset % (lChannels * lBytes));
}
+ else if(OriginalFormat == AL_FORMAT_REAR8)
+ lByteOffset = pSource->lOffset / 1 * lBytes * 2;
else if(OriginalFormat == AL_FORMAT_REAR16)
- {
lByteOffset = pSource->lOffset / 2 * lBytes * 2;
- lByteOffset -= (lByteOffset % (lChannels * lBytes));
- }
else if(OriginalFormat == AL_FORMAT_REAR32)
- {
lByteOffset = pSource->lOffset / 4 * lBytes * 2;
- lByteOffset -= (lByteOffset % (lChannels * lBytes));
- }
else
{
ALuint OrigBytes = aluBytesFromFormat(OriginalFormat);
lByteOffset = pSource->lOffset / OrigBytes * lBytes;
- lByteOffset -= (lByteOffset % (lChannels * lBytes));
}
+ lByteOffset -= (lByteOffset % (lChannels * lBytes));
break;
case AL_SAMPLE_OFFSET: