3 #include "al/eax_eax_call.h"
5 #include "al/eax_exception.h"
10 constexpr auto deferred_flag
= 0x80000000U
;
12 class EaxEaxCallException
:
16 explicit EaxEaxCallException(
19 EaxException
{"EAX_EAX_CALL", message
}
22 }; // EaxEaxCallException
27 EaxEaxCall::EaxEaxCall(
29 const GUID
& property_set_guid
,
31 ALuint property_source_id
,
32 ALvoid
* property_buffer
,
34 : is_get_
{is_get
}, is_deferred_
{(property_id
&deferred_flag
) != 0}, version_
{0}
35 , property_set_id_
{EaxEaxCallPropertySetId::none
}, property_id_
{property_id
& ~deferred_flag
}
36 , property_source_id_
{property_source_id
}, property_buffer_
{property_buffer
}
37 , property_size_
{property_size
}
42 else if (property_set_guid
== EAXPROPERTYID_EAX40_Context
)
45 property_set_id_
= EaxEaxCallPropertySetId::context
;
47 else if (property_set_guid
== EAXPROPERTYID_EAX50_Context
)
50 property_set_id_
= EaxEaxCallPropertySetId::context
;
52 else if (property_set_guid
== DSPROPSETID_EAX20_ListenerProperties
)
56 property_set_id_
= EaxEaxCallPropertySetId::fx_slot_effect
;
57 property_id_
= convert_eax_v2_0_listener_property_id(property_id_
);
59 else if (property_set_guid
== DSPROPSETID_EAX30_ListenerProperties
)
63 property_set_id_
= EaxEaxCallPropertySetId::fx_slot_effect
;
65 else if (property_set_guid
== EAXPROPERTYID_EAX40_FXSlot0
)
69 property_set_id_
= EaxEaxCallPropertySetId::fx_slot
;
71 else if (property_set_guid
== EAXPROPERTYID_EAX50_FXSlot0
)
75 property_set_id_
= EaxEaxCallPropertySetId::fx_slot
;
77 else if (property_set_guid
== EAXPROPERTYID_EAX40_FXSlot1
)
81 property_set_id_
= EaxEaxCallPropertySetId::fx_slot
;
83 else if (property_set_guid
== EAXPROPERTYID_EAX50_FXSlot1
)
87 property_set_id_
= EaxEaxCallPropertySetId::fx_slot
;
89 else if (property_set_guid
== EAXPROPERTYID_EAX40_FXSlot2
)
93 property_set_id_
= EaxEaxCallPropertySetId::fx_slot
;
95 else if (property_set_guid
== EAXPROPERTYID_EAX50_FXSlot2
)
99 property_set_id_
= EaxEaxCallPropertySetId::fx_slot
;
101 else if (property_set_guid
== EAXPROPERTYID_EAX40_FXSlot3
)
105 property_set_id_
= EaxEaxCallPropertySetId::fx_slot
;
107 else if (property_set_guid
== EAXPROPERTYID_EAX50_FXSlot3
)
111 property_set_id_
= EaxEaxCallPropertySetId::fx_slot
;
113 else if (property_set_guid
== DSPROPSETID_EAX20_BufferProperties
)
116 property_set_id_
= EaxEaxCallPropertySetId::source
;
117 property_id_
= convert_eax_v2_0_buffer_property_id(property_id_
);
119 else if (property_set_guid
== DSPROPSETID_EAX30_BufferProperties
)
122 property_set_id_
= EaxEaxCallPropertySetId::source
;
124 else if (property_set_guid
== EAXPROPERTYID_EAX40_Source
)
127 property_set_id_
= EaxEaxCallPropertySetId::source
;
129 else if (property_set_guid
== EAXPROPERTYID_EAX50_Source
)
132 property_set_id_
= EaxEaxCallPropertySetId::source
;
134 else if (property_set_guid
== DSPROPSETID_EAX_ReverbProperties
)
138 property_set_id_
= EaxEaxCallPropertySetId::fx_slot_effect
;
140 else if (property_set_guid
== DSPROPSETID_EAXBUFFER_ReverbProperties
)
143 property_set_id_
= EaxEaxCallPropertySetId::source
;
147 fail("Unsupported property set id.");
150 if (version_
< 1 || version_
> 5)
152 fail("EAX version out of range.");
159 fail("EAX1 does not support deferring.");
164 if (property_set_id_
!= EaxEaxCallPropertySetId::fx_slot
&&
167 if (!property_buffer
)
169 fail("Null property buffer.");
172 if (property_size
== 0)
174 fail("Empty property.");
179 if (property_set_id_
== EaxEaxCallPropertySetId::source
&&
180 property_source_id_
== 0)
182 fail("Null AL source id.");
185 if (property_set_id_
== EaxEaxCallPropertySetId::fx_slot
)
187 if (property_id_
< EAXFXSLOT_NONE
)
189 property_set_id_
= EaxEaxCallPropertySetId::fx_slot_effect
;
195 void EaxEaxCall::fail(
198 throw EaxEaxCallException
{message
};
201 ALuint
EaxEaxCall::convert_eax_v2_0_listener_property_id(
206 case DSPROPERTY_EAX20LISTENER_NONE
:
207 return EAXREVERB_NONE
;
209 case DSPROPERTY_EAX20LISTENER_ALLPARAMETERS
:
210 return EAXREVERB_ALLPARAMETERS
;
212 case DSPROPERTY_EAX20LISTENER_ROOM
:
213 return EAXREVERB_ROOM
;
215 case DSPROPERTY_EAX20LISTENER_ROOMHF
:
216 return EAXREVERB_ROOMHF
;
218 case DSPROPERTY_EAX20LISTENER_ROOMROLLOFFFACTOR
:
219 return EAXREVERB_ROOMROLLOFFFACTOR
;
221 case DSPROPERTY_EAX20LISTENER_DECAYTIME
:
222 return EAXREVERB_DECAYTIME
;
224 case DSPROPERTY_EAX20LISTENER_DECAYHFRATIO
:
225 return EAXREVERB_DECAYHFRATIO
;
227 case DSPROPERTY_EAX20LISTENER_REFLECTIONS
:
228 return EAXREVERB_REFLECTIONS
;
230 case DSPROPERTY_EAX20LISTENER_REFLECTIONSDELAY
:
231 return EAXREVERB_REFLECTIONSDELAY
;
233 case DSPROPERTY_EAX20LISTENER_REVERB
:
234 return EAXREVERB_REVERB
;
236 case DSPROPERTY_EAX20LISTENER_REVERBDELAY
:
237 return EAXREVERB_REVERBDELAY
;
239 case DSPROPERTY_EAX20LISTENER_ENVIRONMENT
:
240 return EAXREVERB_ENVIRONMENT
;
242 case DSPROPERTY_EAX20LISTENER_ENVIRONMENTSIZE
:
243 return EAXREVERB_ENVIRONMENTSIZE
;
245 case DSPROPERTY_EAX20LISTENER_ENVIRONMENTDIFFUSION
:
246 return EAXREVERB_ENVIRONMENTDIFFUSION
;
248 case DSPROPERTY_EAX20LISTENER_AIRABSORPTIONHF
:
249 return EAXREVERB_AIRABSORPTIONHF
;
251 case DSPROPERTY_EAX20LISTENER_FLAGS
:
252 return EAXREVERB_FLAGS
;
255 fail("Unsupported EAX 2.0 listener property id.");
259 ALuint
EaxEaxCall::convert_eax_v2_0_buffer_property_id(
264 case DSPROPERTY_EAX20BUFFER_NONE
:
265 return EAXSOURCE_NONE
;
267 case DSPROPERTY_EAX20BUFFER_ALLPARAMETERS
:
268 return EAXSOURCE_ALLPARAMETERS
;
270 case DSPROPERTY_EAX20BUFFER_DIRECT
:
271 return EAXSOURCE_DIRECT
;
273 case DSPROPERTY_EAX20BUFFER_DIRECTHF
:
274 return EAXSOURCE_DIRECTHF
;
276 case DSPROPERTY_EAX20BUFFER_ROOM
:
277 return EAXSOURCE_ROOM
;
279 case DSPROPERTY_EAX20BUFFER_ROOMHF
:
280 return EAXSOURCE_ROOMHF
;
282 case DSPROPERTY_EAX20BUFFER_ROOMROLLOFFFACTOR
:
283 return EAXSOURCE_ROOMROLLOFFFACTOR
;
285 case DSPROPERTY_EAX20BUFFER_OBSTRUCTION
:
286 return EAXSOURCE_OBSTRUCTION
;
288 case DSPROPERTY_EAX20BUFFER_OBSTRUCTIONLFRATIO
:
289 return EAXSOURCE_OBSTRUCTIONLFRATIO
;
291 case DSPROPERTY_EAX20BUFFER_OCCLUSION
:
292 return EAXSOURCE_OCCLUSION
;
294 case DSPROPERTY_EAX20BUFFER_OCCLUSIONLFRATIO
:
295 return EAXSOURCE_OCCLUSIONLFRATIO
;
297 case DSPROPERTY_EAX20BUFFER_OCCLUSIONROOMRATIO
:
298 return EAXSOURCE_OCCLUSIONROOMRATIO
;
300 case DSPROPERTY_EAX20BUFFER_OUTSIDEVOLUMEHF
:
301 return EAXSOURCE_OUTSIDEVOLUMEHF
;
303 case DSPROPERTY_EAX20BUFFER_AIRABSORPTIONFACTOR
:
304 return EAXSOURCE_AIRABSORPTIONFACTOR
;
306 case DSPROPERTY_EAX20BUFFER_FLAGS
:
307 return EAXSOURCE_FLAGS
;
310 fail("Unsupported EAX 2.0 buffer property id.");
315 EaxEaxCall
create_eax_call(
317 const GUID
* property_set_id
,
319 ALuint property_source_id
,
320 ALvoid
* property_buffer
,
321 ALuint property_size
)
324 throw EaxEaxCallException
{"Null property set ID."};