XT-Audio
XtDeviceList.hpp
Go to the documentation of this file.
1 #ifndef XT_API_DEVICE_LIST_HPP
2 #define XT_API_DEVICE_LIST_HPP
3 
6 #include <xt/cpp/Core.hpp>
7 #include <xt/cpp/Error.hpp>
8 
9 #include <string>
10 #include <vector>
13 namespace Xt {
14 
15 using namespace Detail;
16 
17 class DeviceList final
18 {
20  friend class Service;
22  XtDeviceList* const _l;
23  DeviceList(XtDeviceList* l): _l(l) { }
24 public:
25  ~DeviceList();
26  int32_t GetCount() const;
27  std::string GetId(int32_t index) const;
28  std::string GetName(std::string const& id) const;
29  DeviceCaps GetCapabilities(std::string const& id) const;
30 };
31 
32 inline
34 { Detail::HandleDestroy(XtDeviceListDestroy, _l); }
35 
36 inline int32_t
38 {
39  int32_t count;
40  Detail::HandleError(XtDeviceListGetCount(_l, &count));
41  return count;
42 }
43 
44 inline std::string
45 DeviceList::GetId(int32_t index) const
46 {
47  int32_t size = 0;
48  Detail::HandleError(XtDeviceListGetId(_l, index, nullptr, &size));
49  std::vector<char> buffer(static_cast<size_t>(size));
50  Detail::HandleError(XtDeviceListGetId(_l, index, buffer.data(), &size));
51  return std::string(buffer.data());
52 }
53 
54 inline std::string
55 DeviceList::GetName(std::string const& id) const
56 {
57  int32_t size = 0;
58  Detail::HandleError(XtDeviceListGetName(_l, id.c_str(), nullptr, &size));
59  std::vector<char> buffer(static_cast<size_t>(size));
60  Detail::HandleError(XtDeviceListGetName(_l, id.c_str(), buffer.data(), &size));
61  return std::string(buffer.data());
62 }
63 
64 inline DeviceCaps
65 DeviceList::GetCapabilities(std::string const& id) const
66 {
67  XtDeviceCaps coreCapabilities;
68  Detail::HandleError(XtDeviceListGetCapabilities(_l, id.c_str(), &coreCapabilities));
69  return static_cast<DeviceCaps>(coreCapabilities);
70 }
71 
72 } // namespace Xt
73 #endif // XT_API_DEVICE_LIST_HPP
~DeviceList()
Definition: XtDeviceList.hpp:33
int32_t GetCount() const
Definition: XtDeviceList.hpp:37
std::string GetName(std::string const &id) const
Definition: XtDeviceList.hpp:55
DeviceCaps
Definition: Enums.hpp:16
std::string GetId(int32_t index) const
Definition: XtDeviceList.hpp:45
Definition: XtDeviceList.hpp:17
Definition: XtService.hpp:23
DeviceCaps GetCapabilities(std::string const &id) const
Definition: XtDeviceList.hpp:65
Definition: Callbacks.hpp:10