1 #ifndef XT_API_SERVICE_HPP
2 #define XT_API_SERVICE_HPP
6 #include <xt/cpp/Core.hpp>
7 #include <xt/cpp/Error.hpp>
8 #include <xt/cpp/Forward.hpp>
28 XtService
const*
const _s;
29 Service(XtService
const* s): _s(s) { }
32 std::unique_ptr<Device> OpenDevice(std::string
const&
id)
const;
33 std::optional<std::string> GetDefaultDeviceId(
bool output)
const;
34 std::unique_ptr<DeviceList> OpenDeviceList(
EnumFlags flags)
const;
38 inline std::unique_ptr<Device>
42 Detail::HandleError(XtServiceOpenDevice(_s,
id.c_str(), &device));
43 return std::unique_ptr<Device>(
new Device(device));
46 inline std::unique_ptr<DeviceList>
50 auto coreFlags =
static_cast<XtEnumFlags
>(flags);
51 Detail::HandleError(XtServiceOpenDeviceList(_s, coreFlags, &list));
52 return std::unique_ptr<DeviceList>(
new DeviceList(list));
58 auto coreCapabilities = Detail::HandleAssert(XtServiceGetCapabilities(_s));
62 inline std::optional<std::string>
67 Detail::HandleError(XtServiceGetDefaultDeviceId(_s, output, &valid,
nullptr, &size));
68 if(!valid)
return std::optional<std::string>(std::nullopt);
69 std::vector<char> buffer(static_cast<size_t>(size));
70 Detail::HandleError(XtServiceGetDefaultDeviceId(_s, output, &valid, buffer.data(), &size));
71 if(!valid)
return std::optional<std::string>(std::nullopt);
72 return std::optional<std::string>(std::string(buffer.data()));
75 inline std::unique_ptr<Stream>
78 XtStream* stream =
nullptr;
79 std::vector<XtAggregateDeviceParams> ds(params.
count);
80 for(int32_t i = 0; i < params.
count; i++)
84 ds[i].channels = *
reinterpret_cast<XtChannels const*
>(¶ms.
devices[i].
channels);
86 XtAggregateStreamParams coreParams = { 0 };
87 coreParams.devices = ds.data();
88 coreParams.count = params.
count;
89 coreParams.master = params.
master->_d;
90 coreParams.stream.onBuffer = Detail::ForwardOnBuffer;
92 coreParams.mix = *
reinterpret_cast<XtMix const*
>(¶ms.
mix);
93 coreParams.stream.onXRun = params.
stream.
onXRun ==
nullptr?
nullptr: Detail::ForwardOnXRun;
94 coreParams.stream.onRunning = params.
stream.
onRunning ==
nullptr?
nullptr: Detail::ForwardOnRunning;
95 std::unique_ptr<Stream> result(
new Stream(params.
stream, user));
96 Detail::HandleError(XtServiceAggregateStream(_s, &coreParams, result.get(), &stream));
102 #endif // XT_API_SERVICE_HPP
Mix mix
Definition: Structs.hpp:130
Definition: Structs.hpp:125
EnumFlags
Definition: Enums.hpp:13
std::unique_ptr< DeviceList > OpenDeviceList(EnumFlags flags) const
Definition: XtService.hpp:47
ServiceCaps GetCapabilities() const
Definition: XtService.hpp:56
class Device * device
Definition: Structs.hpp:117
std::unique_ptr< Device > OpenDevice(std::string const &id) const
Definition: XtService.hpp:39
Channels channels
Definition: Structs.hpp:118
StreamParams stream
Definition: Structs.hpp:127
std::unique_ptr< Stream > AggregateStream(AggregateStreamParams const ¶ms, void *user)
Definition: XtService.hpp:76
AggregateDeviceParams * devices
Definition: Structs.hpp:128
OnXRun onXRun
Definition: Structs.hpp:98
double bufferSize
Definition: Structs.hpp:119
std::optional< std::string > GetDefaultDeviceId(bool output) const
Definition: XtService.hpp:63
Definition: XtDeviceList.hpp:17
Definition: XtService.hpp:23
int32_t count
Definition: Structs.hpp:129
bool interleaved
Definition: Structs.hpp:96
Device const * master
Definition: Structs.hpp:131
ServiceCaps
Definition: Enums.hpp:14
Definition: Callbacks.hpp:10
OnRunning onRunning
Definition: Structs.hpp:99
Definition: XtStream.hpp:18
Definition: XtDevice.hpp:20