aboutsummaryrefslogtreecommitdiffstats
path: root/OpenAL32/alSource.c
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2014-03-04 22:44:30 -0800
committerChris Robinson <[email protected]>2014-03-04 22:44:30 -0800
commita1c440bd09d6b0bec36ef84dc474306ce6171b26 (patch)
treeb0666578ef6110d6a956759445654c5adb054af1 /OpenAL32/alSource.c
parentf3a87d72b266640a706ddd3234aa4313b53cabce (diff)
Add an extension to support MSADPCM buffer formats
Diffstat (limited to 'OpenAL32/alSource.c')
-rw-r--r--OpenAL32/alSource.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/OpenAL32/alSource.c b/OpenAL32/alSource.c
index 4a46b77e..e0ae9768 100644
--- a/OpenAL32/alSource.c
+++ b/OpenAL32/alSource.c
@@ -2551,6 +2551,23 @@ static ALvoid GetSourceOffsets(const ALsource *Source, ALenum name, ALdouble *of
FrameBlockSize * BlockSize);
}
}
+ else if(Buffer->OriginalType == UserFmtMSADPCM)
+ {
+ ALsizei align = (Buffer->OriginalAlign-2)/2 + 7;
+ ALuint BlockSize = align * ChannelsFromFmt(Buffer->FmtChannels);
+ ALuint FrameBlockSize = Buffer->OriginalAlign;
+
+ /* Round down to nearest ADPCM block */
+ offset[0] = (ALdouble)(readPos / FrameBlockSize * BlockSize);
+ if(Source->state != AL_PLAYING)
+ offset[1] = offset[0];
+ else
+ {
+ /* Round up to nearest ADPCM block */
+ offset[1] = (ALdouble)((writePos+FrameBlockSize-1) /
+ FrameBlockSize * BlockSize);
+ }
+ }
else
{
ALuint FrameSize = FrameSizeFromUserFmt(Buffer->OriginalChannels, Buffer->OriginalType);
@@ -2655,6 +2672,12 @@ static ALint GetSampleOffset(ALsource *Source)
Offset /= align * ChannelsFromUserFmt(Buffer->OriginalChannels);
Offset *= Buffer->OriginalAlign;
}
+ else if(Buffer->OriginalType == UserFmtMSADPCM)
+ {
+ ALsizei align = (Buffer->OriginalAlign-2)/2 + 7;
+ Offset /= align * ChannelsFromUserFmt(Buffer->OriginalChannels);
+ Offset *= Buffer->OriginalAlign;
+ }
else
Offset /= FrameSizeFromUserFmt(Buffer->OriginalChannels, Buffer->OriginalType);
break;