Skip to content

Commit

Permalink
Add a Buffer::SetFX stub
Browse files Browse the repository at this point in the history
  • Loading branch information
kcat committed Sep 5, 2024
1 parent e15e4fb commit 4be16f9
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 2 deletions.
43 changes: 41 additions & 2 deletions src/buffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1245,9 +1245,48 @@ HRESULT STDMETHODCALLTYPE Buffer::Restore() noexcept
#define PREFIX CLASS_PREFIX "SetFX"
HRESULT STDMETHODCALLTYPE Buffer::SetFX(DWORD effectsCount, DSEFFECTDESC *dsFXDesc, DWORD *resultCodes) noexcept
{
FIXME(PREFIX "(%p)->(%lu, %p, %p)\n", voidp{this}, effectsCount, voidp{dsFXDesc},
TRACE(PREFIX "(%p)->(%lu, %p, %p)\n", voidp{this}, effectsCount, voidp{dsFXDesc},
voidp{resultCodes});
return E_NOTIMPL;

if(!(mBuffer->mFlags&DSBCAPS_CTRLFX))
return DSERR_CONTROLUNAVAIL;

if(effectsCount == 0)
{
/* No effects, we can do that. */
if(dsFXDesc || resultCodes)
{
WARN("Non-null pointers for no effects (%p, %p)\n", voidp{dsFXDesc},
voidp{resultCodes});
return E_INVALIDARG;
}
return DS_OK;
}

if(!dsFXDesc)
{
WARN("Missing FX descriptions\n");
return E_INVALIDARG;
}
const auto fxdescs = std::span{dsFXDesc, effectsCount};
const auto rescodes = std::span{resultCodes, resultCodes ? effectsCount : 0ul};

/* We don't handle DS8 FX. Still not sure how exactly this is supposed to
* work, surely it doesn't instantiate a unique effect processor for each
* buffer? But you may sometimes want multiple instances of the same effect
* type...
*
* Not that many apps used this API, so it's not likely a big loss.
*/
std::fill(rescodes.begin(), rescodes.end(), DSFXR_FAILED);

std::for_each(fxdescs.begin(), fxdescs.end(), [](const DSEFFECTDESC &desc)
{
DEBUG("Unsupported effect: 0x%lx, %s\n", desc.dwFlags,
DsfxPrinter{desc.guidDSFXClass}.c_str());
});

return DSERR_FXUNAVAILABLE;
}
#undef PREFIX

Expand Down
26 changes: 26 additions & 0 deletions src/guidprinter.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ struct PropidTag { };
struct DevidTag { };
struct Ds3dalgTag { };
struct FmtidTag { };
struct DsfxTag { };

class GuidPrinter {
std::array<char,48> mMsg{};
Expand Down Expand Up @@ -83,6 +84,23 @@ class GuidPrinter {
store(guid);
}

void store_dsfxid(const GUID &guid)
{
if(false) { }
CHECKID(GUID_DSFX_STANDARD_CHORUS)
CHECKID(GUID_DSFX_STANDARD_COMPRESSOR)
CHECKID(GUID_DSFX_STANDARD_DISTORTION)
CHECKID(GUID_DSFX_STANDARD_ECHO)
CHECKID(GUID_DSFX_STANDARD_FLANGER)
CHECKID(GUID_DSFX_STANDARD_GARGLE)
CHECKID(GUID_DSFX_STANDARD_I3DL2REVERB)
CHECKID(GUID_DSFX_STANDARD_PARAMEQ)
CHECKID(GUID_DSFX_WAVES_REVERB)
if(mIdStr) return;

store(guid);
}

void store_ds3dalg(const GUID &guid)
{
if(false) { }
Expand Down Expand Up @@ -141,13 +159,15 @@ class GuidPrinter {
GuidPrinter(PropidTag, const GUID &guid) { store_propid(guid); }
GuidPrinter(Ds3dalgTag, const GUID &guid) { store_ds3dalg(guid); }
GuidPrinter(FmtidTag, const GUID &guid) { store_fmtid(guid); }
GuidPrinter(DsfxTag, const GUID &guid) { store_dsfxid(guid); }

GuidPrinter(const GUID *guid) { if(!guid) mIdStr = "{null}"; else store(*guid); }
GuidPrinter(ClsidTag, const GUID *guid) { if(!guid) mIdStr = "{null}"; else store_clsid(*guid); }
GuidPrinter(DevidTag, const GUID *guid) { if(!guid) mIdStr = "{null}"; else store_devid(*guid); }
GuidPrinter(PropidTag, const GUID *guid) { if(!guid) mIdStr = "{null}"; else store_propid(*guid); }
GuidPrinter(Ds3dalgTag, const GUID *guid) { if(!guid) mIdStr = "{null}"; else store_ds3dalg(*guid); }
GuidPrinter(FmtidTag, const GUID *guid) { if(!guid) mIdStr = "{null}"; else store_fmtid(*guid); }
GuidPrinter(DsfxTag, const GUID *guid) { if(!guid) mIdStr = "{null}"; else store_dsfxid(*guid); }

[[nodiscard]]
const char *c_str() const { return mIdStr; }
Expand Down Expand Up @@ -189,4 +209,10 @@ class FmtidPrinter : public GuidPrinter {
FmtidPrinter(T&& guid) : GuidPrinter{FmtidTag{}, std::forward<T>(guid)} { }
};

class DsfxPrinter : public GuidPrinter {
public:
template<typename T, std::enable_if_t<!std::is_same_v<std::remove_cvref_t<T>,DsfxPrinter>,bool> = true>
DsfxPrinter(T&& guid) : GuidPrinter{DsfxTag{}, std::forward<T>(guid)} { }
};

#endif // GUIDPRINTER_H

0 comments on commit 4be16f9

Please sign in to comment.