1 #ifndef XT_API_DEVICE_HPP
2 #define XT_API_DEVICE_HPP
6 #include <xt/cpp/Core.hpp>
7 #include <xt/cpp/Error.hpp>
26 Device(XtDevice* d): _d(d) { }
29 void ShowControlPanel();
30 void* GetHandle()
const;
31 std::optional<Mix> GetMix()
const;
32 int32_t GetChannelCount(
bool output)
const;
33 bool SupportsAccess(
bool interleaved)
const;
34 bool SupportsFormat(
Format const& format)
const;
36 std::string GetChannelName(
bool output, int32_t index)
const;
42 { Detail::HandleDestroy(XtDeviceDestroy, _d); }
45 { Detail::HandleError(XtDeviceShowControlPanel(_d)); }
48 {
return Detail::HandleAssert(XtDeviceGetHandle(_d)); }
54 Detail::HandleError(XtDeviceGetChannelCount(_d, output, &count));
62 auto coreSize =
reinterpret_cast<XtBufferSize*
>(&result);
63 auto coreFormat =
reinterpret_cast<XtFormat const*
>(&format);
64 Detail::HandleError(XtDeviceGetBufferSize(_d, coreFormat, coreSize));
72 auto coreFormat =
reinterpret_cast<XtFormat const*
>(&format);
73 Detail::HandleError(XtDeviceSupportsFormat(_d, coreFormat, &supports));
74 return supports != XtFalse;
81 Detail::HandleError(XtDeviceSupportsAccess(_d, interleaved, &supports));
82 return supports != XtFalse;
85 inline std::optional<Mix>
90 auto coreMix =
reinterpret_cast<XtMix*
>(&mix);
91 Detail::HandleError(XtDeviceGetMix(_d, &valid, coreMix));
92 return valid? std::optional<Mix>(mix): std::optional<Mix>(std::nullopt);
99 Detail::HandleError(XtDeviceGetChannelName(_d, output, index,
nullptr, &size));
100 std::vector<char> buffer(static_cast<size_t>(size));
101 Detail::HandleError(XtDeviceGetChannelName(_d, output, index, buffer.data(), &size));
102 return std::string(buffer.data());
105 inline std::unique_ptr<Stream>
109 XtDeviceStreamParams coreParams = { 0 };
111 coreParams.stream.onBuffer = &Detail::ForwardOnBuffer;
113 coreParams.format = *
reinterpret_cast<XtFormat const*
>(¶ms.
format);
114 coreParams.stream.onXRun = params.
stream.
onXRun ==
nullptr?
nullptr: &Detail::ForwardOnXRun;
115 coreParams.stream.onRunning = params.
stream.
onRunning ==
nullptr?
nullptr: &Detail::ForwardOnRunning;
116 std::unique_ptr<Stream> result(
new Stream(params.
stream, user));
117 Detail::HandleError(XtDeviceOpenStream(_d, &coreParams, result.get(), &stream));
123 #endif // XT_API_DEVICE_HPP
int32_t GetChannelCount(bool output) const
Definition: XtDevice.hpp:51
void ShowControlPanel()
Definition: XtDevice.hpp:44
bool SupportsFormat(Format const &format) const
Definition: XtDevice.hpp:69
~Device()
Definition: XtDevice.hpp:41
Definition: Structs.hpp:50
Format format
Definition: Structs.hpp:108
Definition: Structs.hpp:105
OnXRun onXRun
Definition: Structs.hpp:98
std::unique_ptr< Stream > OpenStream(DeviceStreamParams const ¶ms, void *user)
Definition: XtDevice.hpp:106
Definition: XtService.hpp:23
BufferSize GetBufferSize(Format const &format) const
Definition: XtDevice.hpp:59
std::optional< Mix > GetMix() const
Definition: XtDevice.hpp:86
StreamParams stream
Definition: Structs.hpp:107
bool interleaved
Definition: Structs.hpp:96
void * GetHandle() const
Definition: XtDevice.hpp:47
double bufferSize
Definition: Structs.hpp:109
bool SupportsAccess(bool interleaved) const
Definition: XtDevice.hpp:78
Definition: Callbacks.hpp:10
OnRunning onRunning
Definition: Structs.hpp:99
Definition: XtStream.hpp:18
Definition: XtDevice.hpp:20
Definition: Structs.hpp:65
std::string GetChannelName(bool output, int32_t index) const
Definition: XtDevice.hpp:96