123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218 |
- #include "config.h"
- #include "call.h"
- #include "exception.h"
- namespace {
- constexpr auto deferred_flag = 0x80000000U;
- class EaxCallException : public EaxException {
- public:
- explicit EaxCallException(const char* message)
- : EaxException{"EAX_CALL", message}
- {}
- }; // EaxCallException
- } // namespace
- EaxCall::EaxCall(
- EaxCallType type,
- const GUID& property_set_guid,
- ALuint property_id,
- ALuint property_source_id,
- ALvoid* property_buffer,
- ALuint property_size)
- : mCallType{type}, mIsDeferred{(property_id & deferred_flag) != 0}
- , mPropertyId{property_id & ~deferred_flag}, mPropertySourceId{property_source_id}
- , mPropertyBuffer{property_buffer}, mPropertyBufferSize{property_size}
- {
- switch(mCallType)
- {
- case EaxCallType::get:
- case EaxCallType::set:
- break;
- default:
- fail("Invalid type.");
- }
- if (false)
- {
- }
- else if (property_set_guid == EAXPROPERTYID_EAX40_Context)
- {
- mVersion = 4;
- mPropertySetId = EaxCallPropertySetId::context;
- }
- else if (property_set_guid == EAXPROPERTYID_EAX50_Context)
- {
- mVersion = 5;
- mPropertySetId = EaxCallPropertySetId::context;
- }
- else if (property_set_guid == DSPROPSETID_EAX20_ListenerProperties)
- {
- mVersion = 2;
- mFxSlotIndex = 0u;
- mPropertySetId = EaxCallPropertySetId::fx_slot_effect;
- }
- else if (property_set_guid == DSPROPSETID_EAX30_ListenerProperties)
- {
- mVersion = 3;
- mFxSlotIndex = 0u;
- mPropertySetId = EaxCallPropertySetId::fx_slot_effect;
- }
- else if (property_set_guid == EAXPROPERTYID_EAX40_FXSlot0)
- {
- mVersion = 4;
- mFxSlotIndex = 0u;
- mPropertySetId = EaxCallPropertySetId::fx_slot;
- }
- else if (property_set_guid == EAXPROPERTYID_EAX50_FXSlot0)
- {
- mVersion = 5;
- mFxSlotIndex = 0u;
- mPropertySetId = EaxCallPropertySetId::fx_slot;
- }
- else if (property_set_guid == EAXPROPERTYID_EAX40_FXSlot1)
- {
- mVersion = 4;
- mFxSlotIndex = 1u;
- mPropertySetId = EaxCallPropertySetId::fx_slot;
- }
- else if (property_set_guid == EAXPROPERTYID_EAX50_FXSlot1)
- {
- mVersion = 5;
- mFxSlotIndex = 1u;
- mPropertySetId = EaxCallPropertySetId::fx_slot;
- }
- else if (property_set_guid == EAXPROPERTYID_EAX40_FXSlot2)
- {
- mVersion = 4;
- mFxSlotIndex = 2u;
- mPropertySetId = EaxCallPropertySetId::fx_slot;
- }
- else if (property_set_guid == EAXPROPERTYID_EAX50_FXSlot2)
- {
- mVersion = 5;
- mFxSlotIndex = 2u;
- mPropertySetId = EaxCallPropertySetId::fx_slot;
- }
- else if (property_set_guid == EAXPROPERTYID_EAX40_FXSlot3)
- {
- mVersion = 4;
- mFxSlotIndex = 3u;
- mPropertySetId = EaxCallPropertySetId::fx_slot;
- }
- else if (property_set_guid == EAXPROPERTYID_EAX50_FXSlot3)
- {
- mVersion = 5;
- mFxSlotIndex = 3u;
- mPropertySetId = EaxCallPropertySetId::fx_slot;
- }
- else if (property_set_guid == DSPROPSETID_EAX20_BufferProperties)
- {
- mVersion = 2;
- mPropertySetId = EaxCallPropertySetId::source;
- }
- else if (property_set_guid == DSPROPSETID_EAX30_BufferProperties)
- {
- mVersion = 3;
- mPropertySetId = EaxCallPropertySetId::source;
- }
- else if (property_set_guid == EAXPROPERTYID_EAX40_Source)
- {
- mVersion = 4;
- mPropertySetId = EaxCallPropertySetId::source;
- }
- else if (property_set_guid == EAXPROPERTYID_EAX50_Source)
- {
- mVersion = 5;
- mPropertySetId = EaxCallPropertySetId::source;
- }
- else if (property_set_guid == DSPROPSETID_EAX_ReverbProperties)
- {
- mVersion = 1;
- mFxSlotIndex = 0u;
- mPropertySetId = EaxCallPropertySetId::fx_slot_effect;
- }
- else if (property_set_guid == DSPROPSETID_EAXBUFFER_ReverbProperties)
- {
- mVersion = 1;
- mPropertySetId = EaxCallPropertySetId::source;
- }
- else
- {
- fail("Unsupported property set id.");
- }
- switch(mPropertyId)
- {
- case EAXCONTEXT_LASTERROR:
- case EAXCONTEXT_SPEAKERCONFIG:
- case EAXCONTEXT_EAXSESSION:
- case EAXFXSLOT_NONE:
- case EAXFXSLOT_ALLPARAMETERS:
- case EAXFXSLOT_LOADEFFECT:
- case EAXFXSLOT_VOLUME:
- case EAXFXSLOT_LOCK:
- case EAXFXSLOT_FLAGS:
- case EAXFXSLOT_OCCLUSION:
- case EAXFXSLOT_OCCLUSIONLFRATIO:
- // EAX allow to set "defer" flag on immediate-only properties.
- // If we don't clear our flag then "applyAllUpdates" in EAX context won't be called.
- mIsDeferred = false;
- break;
- }
- if(!mIsDeferred)
- {
- if(mPropertySetId != EaxCallPropertySetId::fx_slot && mPropertyId != 0)
- {
- if(mPropertyBuffer == nullptr)
- fail("Null property buffer.");
- if(mPropertyBufferSize == 0)
- fail("Empty property.");
- }
- }
- if(mPropertySetId == EaxCallPropertySetId::source && mPropertySourceId == 0)
- fail("Null AL source id.");
- if(mPropertySetId == EaxCallPropertySetId::fx_slot)
- {
- if(mPropertyId < EAXFXSLOT_NONE)
- mPropertySetId = EaxCallPropertySetId::fx_slot_effect;
- }
- }
- [[noreturn]] void EaxCall::fail(const char* message)
- {
- throw EaxCallException{message};
- }
- [[noreturn]] void EaxCall::fail_too_small()
- {
- fail("Property buffer too small.");
- }
- EaxCall create_eax_call(
- EaxCallType type,
- const GUID* property_set_id,
- ALuint property_id,
- ALuint property_source_id,
- ALvoid* property_buffer,
- ALuint property_size)
- {
- if(!property_set_id)
- throw EaxCallException{"Null property set ID."};
- return EaxCall{
- type,
- *property_set_id,
- property_id,
- property_source_id,
- property_buffer,
- property_size
- };
- }
|