Skip to content

Commit

Permalink
Merge branch 'kcat:c++-rewrite' into c++-rewrite
Browse files Browse the repository at this point in the history
  • Loading branch information
ThreeDeeJay authored Sep 12, 2024
2 parents 5272ad1 + 14a8ca5 commit 71096d1
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
11 changes: 10 additions & 1 deletion src/dsoundoal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ ds::expected<std::unique_ptr<SharedDevice>,HRESULT> CreateDeviceShare(const GUID
};
const std::array sExtensionList{
ExtensionEntry{"EAX5.0", EXT_EAX},
ExtensionEntry{"ALC_EXT_EFX", EXT_EFX},
ExtensionEntry{"AL_EXT_FLOAT32", EXT_FLOAT32},
ExtensionEntry{"AL_EXT_MCFORMATS", EXT_MCFORMATS},
ExtensionEntry{"AL_EXT_STATIC_BUFFER", EXT_STATIC_BUFFER}
Expand All @@ -195,7 +196,15 @@ ds::expected<std::unique_ptr<SharedDevice>,HRESULT> CreateDeviceShare(const GUID
std::bitset<ExtensionCount> extensions{};
for(auto &ext : sExtensionList)
{
if(alIsExtensionPresent(ext.name))
if(std::string_view{ext.name}.substr(0,3) == "ALC")
{
if(alcIsExtensionPresent(aldev.get(), ext.name))
{
extensions.set(ext.flag);
TRACE("CreateDeviceShare Found extension %s\n", ext.name);
}
}
else if(alIsExtensionPresent(ext.name))
{
extensions.set(ext.flag);
TRACE("CreateDeviceShare Found extension %s\n", ext.name);
Expand Down
1 change: 1 addition & 0 deletions src/dsoundoal.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ struct BufferSubList;

enum Extensions : uint8_t {
EXT_EAX,
EXT_EFX,
EXT_FLOAT32,
EXT_MCFORMATS,
EXT_STATIC_BUFFER,
Expand Down
10 changes: 9 additions & 1 deletion src/primarybuffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -631,7 +631,11 @@ void PrimaryBuffer::setParams(const DS3DLISTENER &params, const std::bitset<Flag
alListenerfv(AL_ORIENTATION, ori.data());
}
if(flags.test(DistanceFactor))
{
alSpeedOfSound(343.3f / params.flDistanceFactor);
if(mParent.haveExtension(EXT_EFX))
alListenerf(AL_METERS_PER_UNIT, params.flDistanceFactor);
}
if(flags.test(RolloffFactor))
{
for(Buffer *buffer : mParent.get3dBuffers())
Expand Down Expand Up @@ -862,9 +866,13 @@ HRESULT STDMETHODCALLTYPE PrimaryBuffer::Listener3D::SetDistanceFactor(D3DVALUE
else
{
ALSection alsection{self->mContext};
alcSuspendContext(self->mContext);
self->mImmediate.flDistanceFactor = distanceFactor;
alSpeedOfSound(343.3f/distanceFactor);
alSpeedOfSound(343.3f / distanceFactor);
if(self->mParent.haveExtension(EXT_EFX))
alListenerf(AL_METERS_PER_UNIT, distanceFactor);
alGetError();
alcProcessContext(self->mContext);
}

return S_OK;
Expand Down

0 comments on commit 71096d1

Please sign in to comment.