aboutsummaryrefslogtreecommitdiffstats
path: root/al
diff options
context:
space:
mode:
Diffstat (limited to 'al')
-rw-r--r--al/buffer.cpp14
-rw-r--r--al/buffer.h1
-rw-r--r--al/source.cpp27
3 files changed, 22 insertions, 20 deletions
diff --git a/al/buffer.cpp b/al/buffer.cpp
index ff416fda..bc007219 100644
--- a/al/buffer.cpp
+++ b/al/buffer.cpp
@@ -571,7 +571,7 @@ void LoadData(ALCcontext *context, ALbuffer *ALBuf, ALsizei freq, ALuint size,
/* Can only preserve data with the same format and alignment. */
if(ALBuf->mChannels != *DstChannels || ALBuf->OriginalType != SrcType) [[unlikely]]
return context->setError(AL_INVALID_VALUE, "Preserving data of mismatched format");
- if(ALBuf->OriginalAlign != align) [[unlikely]]
+ if(ALBuf->mBlockAlign != align) [[unlikely]]
return context->setError(AL_INVALID_VALUE, "Preserving data of mismatched alignment");
if(ALBuf->mAmbiOrder != ambiorder) [[unlikely]]
return context->setError(AL_INVALID_VALUE, "Preserving data of mismatched order");
@@ -641,7 +641,7 @@ void LoadData(ALCcontext *context, ALbuffer *ALBuf, ALsizei freq, ALuint size,
if(SrcData != nullptr && !ALBuf->mData.empty())
Convert_int16_ima4(reinterpret_cast<int16_t*>(ALBuf->mData.data()), SrcData,
NumChannels, frames, align);
- ALBuf->OriginalAlign = align;
+ ALBuf->mBlockAlign = align;
}
else if(SrcType == UserFmtMSADPCM)
{
@@ -649,14 +649,14 @@ void LoadData(ALCcontext *context, ALbuffer *ALBuf, ALsizei freq, ALuint size,
if(SrcData != nullptr && !ALBuf->mData.empty())
Convert_int16_msadpcm(reinterpret_cast<int16_t*>(ALBuf->mData.data()), SrcData,
NumChannels, frames, align);
- ALBuf->OriginalAlign = align;
+ ALBuf->mBlockAlign = align;
}
else
{
assert(DstType.has_value());
if(SrcData != nullptr && !ALBuf->mData.empty())
std::copy_n(SrcData, frames*FrameSize, ALBuf->mData.begin());
- ALBuf->OriginalAlign = 1;
+ ALBuf->mBlockAlign = 1;
}
ALBuf->OriginalSize = size;
ALBuf->OriginalType = SrcType;
@@ -722,7 +722,7 @@ void PrepareCallback(ALCcontext *context, ALbuffer *ALBuf, ALsizei freq,
ALBuf->OriginalType = SrcType;
ALBuf->OriginalSize = 0;
- ALBuf->OriginalAlign = 1;
+ ALBuf->mBlockAlign = 1;
ALBuf->Access = 0;
ALBuf->mSampleRate = static_cast<ALuint>(freq);
@@ -1105,10 +1105,10 @@ START_API_FUNC
else if(al::to_underlying(usrfmt->channels) != al::to_underlying(albuf->mChannels)
|| usrfmt->type != albuf->OriginalType) [[unlikely]]
context->setError(AL_INVALID_ENUM, "Unpacking data with mismatched format");
- else if(align != albuf->OriginalAlign) [[unlikely]]
+ else if(align != albuf->mBlockAlign) [[unlikely]]
context->setError(AL_INVALID_VALUE,
"Unpacking data with alignment %u does not match original alignment %u", align,
- albuf->OriginalAlign);
+ albuf->mBlockAlign);
else if(albuf->isBFormat() && albuf->UnpackAmbiOrder != albuf->mAmbiOrder) [[unlikely]]
context->setError(AL_INVALID_VALUE, "Unpacking data with mismatched ambisonic order");
else if(albuf->MappedAccess != 0) [[unlikely]]
diff --git a/al/buffer.h b/al/buffer.h
index 7ded83bd..322b918f 100644
--- a/al/buffer.h
+++ b/al/buffer.h
@@ -51,7 +51,6 @@ struct ALbuffer : public BufferStorage {
UserFmtType OriginalType{UserFmtShort};
ALuint OriginalSize{0};
- ALuint OriginalAlign{0};
ALuint UnpackAlign{0};
ALuint PackAlign{0};
diff --git a/al/source.cpp b/al/source.cpp
index 7dc5df37..7db175ef 100644
--- a/al/source.cpp
+++ b/al/source.cpp
@@ -334,8 +334,8 @@ double GetSourceOffset(ALsource *Source, ALenum name, ALCcontext *context)
case AL_BYTE_OFFSET:
if(BufferFmt->OriginalType == UserFmtIMA4)
{
- ALuint FrameBlockSize{BufferFmt->OriginalAlign};
- ALuint align{(BufferFmt->OriginalAlign-1)/2 + 4};
+ ALuint FrameBlockSize{BufferFmt->mBlockAlign};
+ ALuint align{(BufferFmt->mBlockAlign-1)/2 + 4};
ALuint BlockSize{align * BufferFmt->channelsFromFmt()};
/* Round down to nearest ADPCM block */
@@ -343,7 +343,7 @@ double GetSourceOffset(ALsource *Source, ALenum name, ALCcontext *context)
}
else if(BufferFmt->OriginalType == UserFmtMSADPCM)
{
- ALuint FrameBlockSize{BufferFmt->OriginalAlign};
+ ALuint FrameBlockSize{BufferFmt->mBlockAlign};
ALuint align{(FrameBlockSize-2)/2 + 7};
ALuint BlockSize{align * BufferFmt->channelsFromFmt()};
@@ -390,8 +390,8 @@ double GetSourceLength(const ALsource *source, ALenum name)
case AL_BYTE_LENGTH_SOFT:
if(BufferFmt->OriginalType == UserFmtIMA4)
{
- ALuint FrameBlockSize{BufferFmt->OriginalAlign};
- ALuint align{(BufferFmt->OriginalAlign-1)/2 + 4};
+ ALuint FrameBlockSize{BufferFmt->mBlockAlign};
+ ALuint align{(BufferFmt->mBlockAlign-1)/2 + 4};
ALuint BlockSize{align * BufferFmt->channelsFromFmt()};
/* Round down to nearest ADPCM block */
@@ -399,7 +399,7 @@ double GetSourceLength(const ALsource *source, ALenum name)
}
else if(BufferFmt->OriginalType == UserFmtMSADPCM)
{
- ALuint FrameBlockSize{BufferFmt->OriginalAlign};
+ ALuint FrameBlockSize{BufferFmt->mBlockAlign};
ALuint align{(FrameBlockSize-2)/2 + 7};
ALuint BlockSize{align * BufferFmt->channelsFromFmt()};
@@ -474,15 +474,15 @@ al::optional<VoicePos> GetSampleOffset(al::deque<ALbufferQueueItem> &BufferList,
/* Determine the ByteOffset (and ensure it is block aligned) */
if(BufferFmt->OriginalType == UserFmtIMA4)
{
- const ALuint align{(BufferFmt->OriginalAlign-1)/2 + 4};
+ const ALuint align{(BufferFmt->mBlockAlign-1)/2 + 4};
Offset = std::floor(Offset / align / BufferFmt->channelsFromFmt());
- Offset *= BufferFmt->OriginalAlign;
+ Offset *= BufferFmt->mBlockAlign;
}
else if(BufferFmt->OriginalType == UserFmtMSADPCM)
{
- const ALuint align{(BufferFmt->OriginalAlign-2)/2 + 7};
+ const ALuint align{(BufferFmt->mBlockAlign-2)/2 + 7};
Offset = std::floor(Offset / align / BufferFmt->channelsFromFmt());
- Offset *= BufferFmt->OriginalAlign;
+ Offset *= BufferFmt->mBlockAlign;
}
else
Offset = std::floor(Offset / BufferFmt->channelsFromFmt());
@@ -530,14 +530,15 @@ void InitVoice(Voice *voice, ALsource *source, ALbufferQueueItem *BufferList, AL
FmtSuperStereo : buffer->mChannels;
voice->mFmtType = buffer->mType;
voice->mFrameStep = buffer->channelsFromFmt();
- voice->mFrameSize = buffer->frameSizeFromFmt();
+ voice->mBytesPerBlock = buffer->blockSizeFromFmt();
+ voice->mSamplesPerBlock = buffer->mBlockAlign;
voice->mAmbiLayout = IsUHJ(voice->mFmtChannels) ? AmbiLayout::FuMa : buffer->mAmbiLayout;
voice->mAmbiScaling = IsUHJ(voice->mFmtChannels) ? AmbiScaling::UHJ : buffer->mAmbiScaling;
voice->mAmbiOrder = (voice->mFmtChannels == FmtSuperStereo) ? 1 : buffer->mAmbiOrder;
if(buffer->mCallback) voice->mFlags.set(VoiceIsCallback);
else if(source->SourceType == AL_STATIC) voice->mFlags.set(VoiceIsStatic);
- voice->mNumCallbackSamples = 0;
+ voice->mNumCallbackBlocks = 0;
voice->prepare(device);
@@ -1536,6 +1537,7 @@ try {
newlist.emplace_back();
newlist.back().mCallback = buffer->mCallback;
newlist.back().mUserData = buffer->mUserData;
+ newlist.back().mBlockAlign = buffer->mBlockAlign;
newlist.back().mSampleLen = buffer->mSampleLen;
newlist.back().mLoopStart = buffer->mLoopStart;
newlist.back().mLoopEnd = buffer->mLoopEnd;
@@ -3604,6 +3606,7 @@ START_API_FUNC
BufferList = &item;
}
if(!buffer) continue;
+ BufferList->mBlockAlign = buffer->mBlockAlign;
BufferList->mSampleLen = buffer->mSampleLen;
BufferList->mLoopEnd = buffer->mSampleLen;
BufferList->mSamples = buffer->mData.data();