2022-04-25 12:02:45 +08:00
|
|
|
#include "config.h"
|
|
|
|
|
2022-07-14 23:17:11 +08:00
|
|
|
#include "fx_slots.h"
|
2022-04-25 12:02:45 +08:00
|
|
|
|
|
|
|
#include <array>
|
|
|
|
|
2022-07-14 23:17:11 +08:00
|
|
|
#include "api.h"
|
|
|
|
#include "exception.h"
|
2022-04-25 12:02:45 +08:00
|
|
|
|
|
|
|
|
|
|
|
namespace
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
class EaxFxSlotsException :
|
|
|
|
public EaxException
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
explicit EaxFxSlotsException(
|
|
|
|
const char* message)
|
|
|
|
:
|
|
|
|
EaxException{"EAX_FX_SLOTS", message}
|
|
|
|
{
|
|
|
|
}
|
|
|
|
}; // EaxFxSlotsException
|
|
|
|
|
|
|
|
|
|
|
|
} // namespace
|
|
|
|
|
|
|
|
|
|
|
|
void EaxFxSlots::initialize(
|
2022-07-14 23:17:11 +08:00
|
|
|
const EaxCall& call,
|
2022-04-25 12:02:45 +08:00
|
|
|
ALCcontext& al_context)
|
|
|
|
{
|
2022-07-14 23:17:11 +08:00
|
|
|
initialize_fx_slots(call, al_context);
|
2022-04-25 12:02:45 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void EaxFxSlots::uninitialize() noexcept
|
|
|
|
{
|
|
|
|
for (auto& fx_slot : fx_slots_)
|
|
|
|
{
|
|
|
|
fx_slot = nullptr;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
const ALeffectslot& EaxFxSlots::get(EaxFxSlotIndex index) const
|
|
|
|
{
|
|
|
|
if(!index.has_value())
|
|
|
|
fail("Empty index.");
|
|
|
|
return *fx_slots_[index.value()];
|
|
|
|
}
|
|
|
|
|
|
|
|
ALeffectslot& EaxFxSlots::get(EaxFxSlotIndex index)
|
|
|
|
{
|
|
|
|
if(!index.has_value())
|
|
|
|
fail("Empty index.");
|
|
|
|
return *fx_slots_[index.value()];
|
|
|
|
}
|
|
|
|
|
|
|
|
void EaxFxSlots::unlock_legacy() noexcept
|
|
|
|
{
|
|
|
|
fx_slots_[0]->eax_unlock_legacy();
|
|
|
|
fx_slots_[1]->eax_unlock_legacy();
|
|
|
|
}
|
|
|
|
|
|
|
|
[[noreturn]]
|
|
|
|
void EaxFxSlots::fail(
|
|
|
|
const char* message)
|
|
|
|
{
|
|
|
|
throw EaxFxSlotsException{message};
|
|
|
|
}
|
|
|
|
|
|
|
|
void EaxFxSlots::initialize_fx_slots(
|
2022-07-14 23:17:11 +08:00
|
|
|
const EaxCall& call,
|
2022-04-25 12:02:45 +08:00
|
|
|
ALCcontext& al_context)
|
|
|
|
{
|
|
|
|
auto fx_slot_index = EaxFxSlotIndexValue{};
|
|
|
|
|
|
|
|
for (auto& fx_slot : fx_slots_)
|
|
|
|
{
|
|
|
|
fx_slot = eax_create_al_effect_slot(al_context);
|
2022-07-14 23:17:11 +08:00
|
|
|
fx_slot->eax_initialize(call, al_context, fx_slot_index);
|
2022-04-25 12:02:45 +08:00
|
|
|
fx_slot_index += 1;
|
|
|
|
}
|
|
|
|
}
|