11 #define WIN32_LEAN_AND_MEAN
16 #include "core/logging.h"
17 #include "aloptional.h"
21 #include "core/devformat.h"
24 bool BackendBase::reset()
25 { throw al::backend_exception
{al::backend_error::DeviceError
, "Invalid BackendBase call"}; }
27 void BackendBase::captureSamples(al::byte
*, uint
)
30 uint
BackendBase::availableSamples()
33 ClockLatency
BackendBase::getClockLatency()
39 refcount
= mDevice
->waitForMix();
40 ret
.ClockTime
= GetDeviceClockTime(mDevice
);
41 std::atomic_thread_fence(std::memory_order_acquire
);
42 } while(refcount
!= ReadRef(mDevice
->MixCount
));
44 /* NOTE: The device will generally have about all but one periods filled at
45 * any given time during playback. Without a more accurate measurement from
46 * the output, this is an okay approximation.
48 ret
.Latency
= std::max(std::chrono::seconds
{mDevice
->BufferSize
-mDevice
->UpdateSize
},
49 std::chrono::seconds::zero());
50 ret
.Latency
/= mDevice
->Frequency
;
55 void BackendBase::setDefaultWFXChannelOrder()
57 mDevice
->RealOut
.ChannelIndex
.fill(INVALID_CHANNEL_INDEX
);
59 switch(mDevice
->FmtChans
)
62 mDevice
->RealOut
.ChannelIndex
[FrontCenter
] = 0;
65 mDevice
->RealOut
.ChannelIndex
[FrontLeft
] = 0;
66 mDevice
->RealOut
.ChannelIndex
[FrontRight
] = 1;
69 mDevice
->RealOut
.ChannelIndex
[FrontLeft
] = 0;
70 mDevice
->RealOut
.ChannelIndex
[FrontRight
] = 1;
71 mDevice
->RealOut
.ChannelIndex
[BackLeft
] = 2;
72 mDevice
->RealOut
.ChannelIndex
[BackRight
] = 3;
75 mDevice
->RealOut
.ChannelIndex
[FrontLeft
] = 0;
76 mDevice
->RealOut
.ChannelIndex
[FrontRight
] = 1;
77 mDevice
->RealOut
.ChannelIndex
[FrontCenter
] = 2;
78 mDevice
->RealOut
.ChannelIndex
[LFE
] = 3;
79 mDevice
->RealOut
.ChannelIndex
[SideLeft
] = 4;
80 mDevice
->RealOut
.ChannelIndex
[SideRight
] = 5;
83 mDevice
->RealOut
.ChannelIndex
[FrontLeft
] = 0;
84 mDevice
->RealOut
.ChannelIndex
[FrontRight
] = 1;
85 mDevice
->RealOut
.ChannelIndex
[FrontCenter
] = 2;
86 mDevice
->RealOut
.ChannelIndex
[LFE
] = 3;
87 mDevice
->RealOut
.ChannelIndex
[BackCenter
] = 4;
88 mDevice
->RealOut
.ChannelIndex
[SideLeft
] = 5;
89 mDevice
->RealOut
.ChannelIndex
[SideRight
] = 6;
92 mDevice
->RealOut
.ChannelIndex
[FrontLeft
] = 0;
93 mDevice
->RealOut
.ChannelIndex
[FrontRight
] = 1;
94 mDevice
->RealOut
.ChannelIndex
[FrontCenter
] = 2;
95 mDevice
->RealOut
.ChannelIndex
[LFE
] = 3;
96 mDevice
->RealOut
.ChannelIndex
[BackLeft
] = 4;
97 mDevice
->RealOut
.ChannelIndex
[BackRight
] = 5;
98 mDevice
->RealOut
.ChannelIndex
[SideLeft
] = 6;
99 mDevice
->RealOut
.ChannelIndex
[SideRight
] = 7;
102 mDevice
->RealOut
.ChannelIndex
[FrontLeft
] = 0;
103 mDevice
->RealOut
.ChannelIndex
[FrontRight
] = 1;
104 mDevice
->RealOut
.ChannelIndex
[FrontCenter
] = 2;
105 mDevice
->RealOut
.ChannelIndex
[LFE
] = 3;
106 mDevice
->RealOut
.ChannelIndex
[Aux0
] = 4;
107 mDevice
->RealOut
.ChannelIndex
[Aux1
] = 5;
108 mDevice
->RealOut
.ChannelIndex
[SideLeft
] = 6;
109 mDevice
->RealOut
.ChannelIndex
[SideRight
] = 7;
116 void BackendBase::setDefaultChannelOrder()
118 mDevice
->RealOut
.ChannelIndex
.fill(INVALID_CHANNEL_INDEX
);
120 switch(mDevice
->FmtChans
)
123 mDevice
->RealOut
.ChannelIndex
[FrontLeft
] = 0;
124 mDevice
->RealOut
.ChannelIndex
[FrontRight
] = 1;
125 mDevice
->RealOut
.ChannelIndex
[SideLeft
] = 2;
126 mDevice
->RealOut
.ChannelIndex
[SideRight
] = 3;
127 mDevice
->RealOut
.ChannelIndex
[FrontCenter
] = 4;
128 mDevice
->RealOut
.ChannelIndex
[LFE
] = 5;
131 mDevice
->RealOut
.ChannelIndex
[FrontLeft
] = 0;
132 mDevice
->RealOut
.ChannelIndex
[FrontRight
] = 1;
133 mDevice
->RealOut
.ChannelIndex
[BackLeft
] = 2;
134 mDevice
->RealOut
.ChannelIndex
[BackRight
] = 3;
135 mDevice
->RealOut
.ChannelIndex
[FrontCenter
] = 4;
136 mDevice
->RealOut
.ChannelIndex
[LFE
] = 5;
137 mDevice
->RealOut
.ChannelIndex
[SideLeft
] = 6;
138 mDevice
->RealOut
.ChannelIndex
[SideRight
] = 7;
141 mDevice
->RealOut
.ChannelIndex
[FrontLeft
] = 0;
142 mDevice
->RealOut
.ChannelIndex
[FrontRight
] = 1;
143 mDevice
->RealOut
.ChannelIndex
[Aux0
] = 2;
144 mDevice
->RealOut
.ChannelIndex
[Aux1
] = 3;
145 mDevice
->RealOut
.ChannelIndex
[FrontCenter
] = 4;
146 mDevice
->RealOut
.ChannelIndex
[LFE
] = 5;
147 mDevice
->RealOut
.ChannelIndex
[SideLeft
] = 6;
148 mDevice
->RealOut
.ChannelIndex
[SideRight
] = 7;
151 /* Same as WFX order */
157 setDefaultWFXChannelOrder();