aboutsummaryrefslogtreecommitdiffstats
path: root/al/buffer.cpp
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2021-03-31 10:03:31 -0700
committerChris Robinson <[email protected]>2021-03-31 10:03:31 -0700
commitb5e36007f136f817e6d14685377e781e224daf17 (patch)
tree2b16156169cba4f4139ff16391e619f49fedce80 /al/buffer.cpp
parent35a0f2665f834c107e39ec2dcfc3d9ae0a0b33ce (diff)
Handle 3-channel UHJ audio buffers
Diffstat (limited to 'al/buffer.cpp')
-rw-r--r--al/buffer.cpp13
1 files changed, 10 insertions, 3 deletions
diff --git a/al/buffer.cpp b/al/buffer.cpp
index 436be9ae..23020559 100644
--- a/al/buffer.cpp
+++ b/al/buffer.cpp
@@ -274,6 +274,7 @@ ALuint ChannelsFromUserFmt(UserFmtChannels chans, ALuint ambiorder) noexcept
case UserFmtBFormat2D: return (ambiorder*2) + 1;
case UserFmtBFormat3D: return (ambiorder+1) * (ambiorder+1);
case UserFmtUHJ2: return 2;
+ case UserFmtUHJ3: return 3;
}
return 0;
}
@@ -469,6 +470,7 @@ void LoadData(ALCcontext *context, ALbuffer *ALBuf, ALsizei freq, ALuint size,
case UserFmtBFormat2D: DstChannels = FmtBFormat2D; break;
case UserFmtBFormat3D: DstChannels = FmtBFormat3D; break;
case UserFmtUHJ2: DstChannels = FmtUHJ2; break;
+ case UserFmtUHJ3: DstChannels = FmtUHJ3; break;
}
if UNLIKELY(static_cast<long>(SrcChannels) != static_cast<long>(DstChannels))
SETERR_RETURN(context, AL_INVALID_ENUM, , "Invalid format");
@@ -505,7 +507,7 @@ void LoadData(ALCcontext *context, ALbuffer *ALBuf, ALsizei freq, ALuint size,
unpackalign, NameFromUserFmtType(SrcType));
const ALuint ambiorder{(DstChannels == FmtBFormat2D || DstChannels == FmtBFormat3D) ?
- ALBuf->UnpackAmbiOrder : ((DstChannels == FmtUHJ2) ? 1 : 0)};
+ ALBuf->UnpackAmbiOrder : ((DstChannels == FmtUHJ2 || DstChannels == FmtUHJ3) ? 1 : 0)};
if((access&AL_PRESERVE_DATA_BIT_SOFT))
{
@@ -627,6 +629,7 @@ void PrepareCallback(ALCcontext *context, ALbuffer *ALBuf, ALsizei freq,
case UserFmtBFormat2D: DstChannels = FmtBFormat2D; break;
case UserFmtBFormat3D: DstChannels = FmtBFormat3D; break;
case UserFmtUHJ2: DstChannels = FmtUHJ2; break;
+ case UserFmtUHJ3: DstChannels = FmtUHJ3; break;
}
if UNLIKELY(static_cast<long>(SrcChannels) != static_cast<long>(DstChannels))
SETERR_RETURN(context, AL_INVALID_ENUM,, "Invalid format");
@@ -648,7 +651,7 @@ void PrepareCallback(ALCcontext *context, ALbuffer *ALBuf, ALsizei freq,
SETERR_RETURN(context, AL_INVALID_ENUM,, "Unsupported callback format");
const ALuint ambiorder{(DstChannels == FmtBFormat2D || DstChannels == FmtBFormat3D) ?
- ALBuf->UnpackAmbiOrder : ((DstChannels == FmtUHJ2) ? 1 : 0)};
+ ALBuf->UnpackAmbiOrder : ((DstChannels == FmtUHJ2 || DstChannels == FmtUHJ3) ? 1 : 0)};
constexpr uint line_size{BufferLineSize + MaxPostVoiceLoad};
al::vector<al::byte,16>(FrameSizeFromFmt(DstChannels, DstType, ambiorder) *
@@ -681,7 +684,7 @@ al::optional<DecompResult> DecomposeUserFormat(ALenum format)
UserFmtChannels channels;
UserFmtType type;
};
- static const std::array<FormatMap,49> UserFmtList{{
+ static const std::array<FormatMap,52> UserFmtList{{
{ AL_FORMAT_MONO8, UserFmtMono, UserFmtUByte },
{ AL_FORMAT_MONO16, UserFmtMono, UserFmtShort },
{ AL_FORMAT_MONO_FLOAT32, UserFmtMono, UserFmtFloat },
@@ -741,6 +744,10 @@ al::optional<DecompResult> DecomposeUserFormat(ALenum format)
{ AL_FORMAT_UHJ2CHN8, UserFmtUHJ2, UserFmtUByte },
{ AL_FORMAT_UHJ2CHN16, UserFmtUHJ2, UserFmtShort },
{ AL_FORMAT_UHJ2CHN_FLOAT32, UserFmtUHJ2, UserFmtFloat },
+
+ { AL_FORMAT_UHJ3CHN8, UserFmtUHJ3, UserFmtUByte },
+ { AL_FORMAT_UHJ3CHN16, UserFmtUHJ3, UserFmtShort },
+ { AL_FORMAT_UHJ3CHN_FLOAT32, UserFmtUHJ3, UserFmtFloat },
}};
for(const auto &fmt : UserFmtList)