10 #include "core/devformat.h"
15 backend_exception::backend_exception(backend_error code
, const char *msg
, ...) : mErrorCode
{code
}
17 /* NOLINTBEGIN(*-array-to-pointer-decay) */
20 setMessage(msg
, args
);
22 /* NOLINTEND(*-array-to-pointer-decay) */
24 backend_exception::~backend_exception() = default;
29 bool BackendBase::reset()
30 { throw al::backend_exception
{al::backend_error::DeviceError
, "Invalid BackendBase call"}; }
32 void BackendBase::captureSamples(std::byte
*, uint
)
35 uint
BackendBase::availableSamples()
38 ClockLatency
BackendBase::getClockLatency()
44 refcount
= mDevice
->waitForMix();
45 ret
.ClockTime
= mDevice
->getClockTime();
46 std::atomic_thread_fence(std::memory_order_acquire
);
47 } while(refcount
!= mDevice
->mMixCount
.load(std::memory_order_relaxed
));
49 /* NOTE: The device will generally have about all but one periods filled at
50 * any given time during playback. Without a more accurate measurement from
51 * the output, this is an okay approximation.
53 ret
.Latency
= std::chrono::seconds
{mDevice
->BufferSize
- mDevice
->UpdateSize
};
54 ret
.Latency
/= mDevice
->Frequency
;
59 void BackendBase::setDefaultWFXChannelOrder() const
61 mDevice
->RealOut
.ChannelIndex
.fill(InvalidChannelIndex
);
63 switch(mDevice
->FmtChans
)
66 mDevice
->RealOut
.ChannelIndex
[FrontCenter
] = 0;
69 mDevice
->RealOut
.ChannelIndex
[FrontLeft
] = 0;
70 mDevice
->RealOut
.ChannelIndex
[FrontRight
] = 1;
73 mDevice
->RealOut
.ChannelIndex
[FrontLeft
] = 0;
74 mDevice
->RealOut
.ChannelIndex
[FrontRight
] = 1;
75 mDevice
->RealOut
.ChannelIndex
[BackLeft
] = 2;
76 mDevice
->RealOut
.ChannelIndex
[BackRight
] = 3;
79 mDevice
->RealOut
.ChannelIndex
[FrontLeft
] = 0;
80 mDevice
->RealOut
.ChannelIndex
[FrontRight
] = 1;
81 mDevice
->RealOut
.ChannelIndex
[FrontCenter
] = 2;
82 mDevice
->RealOut
.ChannelIndex
[LFE
] = 3;
83 mDevice
->RealOut
.ChannelIndex
[SideLeft
] = 4;
84 mDevice
->RealOut
.ChannelIndex
[SideRight
] = 5;
87 mDevice
->RealOut
.ChannelIndex
[FrontLeft
] = 0;
88 mDevice
->RealOut
.ChannelIndex
[FrontRight
] = 1;
89 mDevice
->RealOut
.ChannelIndex
[FrontCenter
] = 2;
90 mDevice
->RealOut
.ChannelIndex
[LFE
] = 3;
91 mDevice
->RealOut
.ChannelIndex
[BackCenter
] = 4;
92 mDevice
->RealOut
.ChannelIndex
[SideLeft
] = 5;
93 mDevice
->RealOut
.ChannelIndex
[SideRight
] = 6;
96 mDevice
->RealOut
.ChannelIndex
[FrontLeft
] = 0;
97 mDevice
->RealOut
.ChannelIndex
[FrontRight
] = 1;
98 mDevice
->RealOut
.ChannelIndex
[FrontCenter
] = 2;
99 mDevice
->RealOut
.ChannelIndex
[LFE
] = 3;
100 mDevice
->RealOut
.ChannelIndex
[BackLeft
] = 4;
101 mDevice
->RealOut
.ChannelIndex
[BackRight
] = 5;
102 mDevice
->RealOut
.ChannelIndex
[SideLeft
] = 6;
103 mDevice
->RealOut
.ChannelIndex
[SideRight
] = 7;
106 mDevice
->RealOut
.ChannelIndex
[FrontLeft
] = 0;
107 mDevice
->RealOut
.ChannelIndex
[FrontRight
] = 1;
108 mDevice
->RealOut
.ChannelIndex
[FrontCenter
] = 2;
109 mDevice
->RealOut
.ChannelIndex
[LFE
] = 3;
110 mDevice
->RealOut
.ChannelIndex
[BackLeft
] = 4;
111 mDevice
->RealOut
.ChannelIndex
[BackRight
] = 5;
112 mDevice
->RealOut
.ChannelIndex
[SideLeft
] = 6;
113 mDevice
->RealOut
.ChannelIndex
[SideRight
] = 7;
114 mDevice
->RealOut
.ChannelIndex
[TopFrontLeft
] = 8;
115 mDevice
->RealOut
.ChannelIndex
[TopFrontRight
] = 9;
116 mDevice
->RealOut
.ChannelIndex
[TopBackLeft
] = 10;
117 mDevice
->RealOut
.ChannelIndex
[TopBackRight
] = 11;
120 mDevice
->RealOut
.ChannelIndex
[FrontLeft
] = 0;
121 mDevice
->RealOut
.ChannelIndex
[FrontRight
] = 1;
122 mDevice
->RealOut
.ChannelIndex
[FrontCenter
] = 2;
123 mDevice
->RealOut
.ChannelIndex
[LFE
] = 3;
124 mDevice
->RealOut
.ChannelIndex
[BackLeft
] = 4;
125 mDevice
->RealOut
.ChannelIndex
[BackRight
] = 5;
126 mDevice
->RealOut
.ChannelIndex
[SideLeft
] = 6;
127 mDevice
->RealOut
.ChannelIndex
[SideRight
] = 7;
128 mDevice
->RealOut
.ChannelIndex
[TopFrontLeft
] = 8;
129 mDevice
->RealOut
.ChannelIndex
[TopFrontRight
] = 9;
130 mDevice
->RealOut
.ChannelIndex
[TopBackLeft
] = 10;
131 mDevice
->RealOut
.ChannelIndex
[TopBackRight
] = 11;
132 mDevice
->RealOut
.ChannelIndex
[BottomFrontLeft
] = 12;
133 mDevice
->RealOut
.ChannelIndex
[BottomFrontRight
] = 13;
134 mDevice
->RealOut
.ChannelIndex
[BottomBackLeft
] = 14;
135 mDevice
->RealOut
.ChannelIndex
[BottomBackRight
] = 15;
138 mDevice
->RealOut
.ChannelIndex
[FrontLeft
] = 0;
139 mDevice
->RealOut
.ChannelIndex
[FrontRight
] = 1;
140 mDevice
->RealOut
.ChannelIndex
[FrontCenter
] = 2;
141 mDevice
->RealOut
.ChannelIndex
[LFE
] = 3;
142 mDevice
->RealOut
.ChannelIndex
[Aux0
] = 4;
143 mDevice
->RealOut
.ChannelIndex
[Aux1
] = 5;
144 mDevice
->RealOut
.ChannelIndex
[SideLeft
] = 6;
145 mDevice
->RealOut
.ChannelIndex
[SideRight
] = 7;
152 void BackendBase::setDefaultChannelOrder() const
154 mDevice
->RealOut
.ChannelIndex
.fill(InvalidChannelIndex
);
156 switch(mDevice
->FmtChans
)
159 mDevice
->RealOut
.ChannelIndex
[FrontLeft
] = 0;
160 mDevice
->RealOut
.ChannelIndex
[FrontRight
] = 1;
161 mDevice
->RealOut
.ChannelIndex
[SideLeft
] = 2;
162 mDevice
->RealOut
.ChannelIndex
[SideRight
] = 3;
163 mDevice
->RealOut
.ChannelIndex
[FrontCenter
] = 4;
164 mDevice
->RealOut
.ChannelIndex
[LFE
] = 5;
167 mDevice
->RealOut
.ChannelIndex
[FrontLeft
] = 0;
168 mDevice
->RealOut
.ChannelIndex
[FrontRight
] = 1;
169 mDevice
->RealOut
.ChannelIndex
[BackLeft
] = 2;
170 mDevice
->RealOut
.ChannelIndex
[BackRight
] = 3;
171 mDevice
->RealOut
.ChannelIndex
[FrontCenter
] = 4;
172 mDevice
->RealOut
.ChannelIndex
[LFE
] = 5;
173 mDevice
->RealOut
.ChannelIndex
[SideLeft
] = 6;
174 mDevice
->RealOut
.ChannelIndex
[SideRight
] = 7;
177 mDevice
->RealOut
.ChannelIndex
[FrontLeft
] = 0;
178 mDevice
->RealOut
.ChannelIndex
[FrontRight
] = 1;
179 mDevice
->RealOut
.ChannelIndex
[BackLeft
] = 2;
180 mDevice
->RealOut
.ChannelIndex
[BackRight
] = 3;
181 mDevice
->RealOut
.ChannelIndex
[FrontCenter
] = 4;
182 mDevice
->RealOut
.ChannelIndex
[LFE
] = 5;
183 mDevice
->RealOut
.ChannelIndex
[SideLeft
] = 6;
184 mDevice
->RealOut
.ChannelIndex
[SideRight
] = 7;
185 mDevice
->RealOut
.ChannelIndex
[TopFrontLeft
] = 8;
186 mDevice
->RealOut
.ChannelIndex
[TopFrontRight
] = 9;
187 mDevice
->RealOut
.ChannelIndex
[TopBackLeft
] = 10;
188 mDevice
->RealOut
.ChannelIndex
[TopBackRight
] = 11;
191 mDevice
->RealOut
.ChannelIndex
[FrontLeft
] = 0;
192 mDevice
->RealOut
.ChannelIndex
[FrontRight
] = 1;
193 mDevice
->RealOut
.ChannelIndex
[BackLeft
] = 2;
194 mDevice
->RealOut
.ChannelIndex
[BackRight
] = 3;
195 mDevice
->RealOut
.ChannelIndex
[FrontCenter
] = 4;
196 mDevice
->RealOut
.ChannelIndex
[LFE
] = 5;
197 mDevice
->RealOut
.ChannelIndex
[SideLeft
] = 6;
198 mDevice
->RealOut
.ChannelIndex
[SideRight
] = 7;
199 mDevice
->RealOut
.ChannelIndex
[TopFrontLeft
] = 8;
200 mDevice
->RealOut
.ChannelIndex
[TopFrontRight
] = 9;
201 mDevice
->RealOut
.ChannelIndex
[TopBackLeft
] = 10;
202 mDevice
->RealOut
.ChannelIndex
[TopBackRight
] = 11;
203 mDevice
->RealOut
.ChannelIndex
[BottomFrontLeft
] = 12;
204 mDevice
->RealOut
.ChannelIndex
[BottomFrontRight
] = 13;
205 mDevice
->RealOut
.ChannelIndex
[BottomBackLeft
] = 14;
206 mDevice
->RealOut
.ChannelIndex
[BottomBackRight
] = 15;
209 mDevice
->RealOut
.ChannelIndex
[FrontLeft
] = 0;
210 mDevice
->RealOut
.ChannelIndex
[FrontRight
] = 1;
211 mDevice
->RealOut
.ChannelIndex
[Aux0
] = 2;
212 mDevice
->RealOut
.ChannelIndex
[Aux1
] = 3;
213 mDevice
->RealOut
.ChannelIndex
[FrontCenter
] = 4;
214 mDevice
->RealOut
.ChannelIndex
[LFE
] = 5;
215 mDevice
->RealOut
.ChannelIndex
[SideLeft
] = 6;
216 mDevice
->RealOut
.ChannelIndex
[SideRight
] = 7;
219 /* Same as WFX order */
225 setDefaultWFXChannelOrder();