]> git.tdb.fi Git - ext/openal.git/blob - al/eax/fx_slot_index.cpp
Import OpenAL Soft 1.23.1 sources
[ext/openal.git] / al / eax / fx_slot_index.cpp
1 #include "config.h"
2
3 #include "fx_slot_index.h"
4
5 #include "exception.h"
6
7
8 namespace
9 {
10
11
12 class EaxFxSlotIndexException :
13     public EaxException
14 {
15 public:
16     explicit EaxFxSlotIndexException(
17         const char* message)
18         :
19         EaxException{"EAX_FX_SLOT_INDEX", message}
20     {
21     }
22 }; // EaxFxSlotIndexException
23
24
25 } // namespace
26
27
28 void EaxFxSlotIndex::set(EaxFxSlotIndexValue index)
29 {
30     if(index >= EaxFxSlotIndexValue{EAX_MAX_FXSLOTS})
31         fail("Index out of range.");
32
33     emplace(index);
34 }
35
36 void EaxFxSlotIndex::set(const GUID &guid)
37 {
38     if (false)
39     {
40     }
41     else if (guid == EAX_NULL_GUID)
42     {
43         reset();
44     }
45     else if (guid == EAXPROPERTYID_EAX40_FXSlot0 || guid == EAXPROPERTYID_EAX50_FXSlot0)
46     {
47         emplace(0u);
48     }
49     else if (guid == EAXPROPERTYID_EAX40_FXSlot1 || guid == EAXPROPERTYID_EAX50_FXSlot1)
50     {
51         emplace(1u);
52     }
53     else if (guid == EAXPROPERTYID_EAX40_FXSlot2 || guid == EAXPROPERTYID_EAX50_FXSlot2)
54     {
55         emplace(2u);
56     }
57     else if (guid == EAXPROPERTYID_EAX40_FXSlot3 || guid == EAXPROPERTYID_EAX50_FXSlot3)
58     {
59         emplace(3u);
60     }
61     else
62     {
63         fail("Unsupported GUID.");
64     }
65 }
66
67 [[noreturn]]
68 void EaxFxSlotIndex::fail(const char* message)
69 {
70     throw EaxFxSlotIndexException{message};
71 }