summaryrefslogtreecommitdiff
path: root/portaudio/bindings/cpp/include/portaudiocpp/Device.hxx
diff options
context:
space:
mode:
authorsanine <sanine.not@pm.me>2022-08-25 14:54:53 -0500
committersanine <sanine.not@pm.me>2022-08-25 14:54:53 -0500
commit37c97e345d12f95dde44e1d1a4c2f2aadd4615bc (patch)
treee1bb25bc855883062bdd7847ff2c04290f71c840 /portaudio/bindings/cpp/include/portaudiocpp/Device.hxx
parent5634c7b04da619669f2f29f6798c03982be05180 (diff)
add initial structure
Diffstat (limited to 'portaudio/bindings/cpp/include/portaudiocpp/Device.hxx')
-rw-r--r--portaudio/bindings/cpp/include/portaudiocpp/Device.hxx91
1 files changed, 91 insertions, 0 deletions
diff --git a/portaudio/bindings/cpp/include/portaudiocpp/Device.hxx b/portaudio/bindings/cpp/include/portaudiocpp/Device.hxx
new file mode 100644
index 0000000..0599582
--- /dev/null
+++ b/portaudio/bindings/cpp/include/portaudiocpp/Device.hxx
@@ -0,0 +1,91 @@
+#ifndef INCLUDED_PORTAUDIO_DEVICE_HXX
+#define INCLUDED_PORTAUDIO_DEVICE_HXX
+
+// ---------------------------------------------------------------------------------------
+
+#include <iterator>
+
+#include "portaudio.h"
+
+#include "portaudiocpp/SampleDataFormat.hxx"
+
+// ---------------------------------------------------------------------------------------
+
+// Forward declaration(s):
+namespace portaudio
+{
+ class System;
+ class HostApi;
+}
+
+// ---------------------------------------------------------------------------------------
+
+// Declaration(s):
+namespace portaudio
+{
+
+ //////
+ /// @brief Class which represents a PortAudio device in the System.
+ ///
+ /// A single physical device in the system may have multiple PortAudio
+ /// Device representations using different HostApi 's though. A Device
+ /// can be half-duplex or full-duplex. A half-duplex Device can be used
+ /// to create a half-duplex Stream. A full-duplex Device can be used to
+ /// create a full-duplex Stream. If supported by the HostApi, two
+ /// half-duplex Devices can even be used to create a full-duplex Stream.
+ ///
+ /// Note that Device objects are very light-weight and can be passed around
+ /// by-value.
+ //////
+ class Device
+ {
+ public:
+ // query info: name, max in channels, max out channels,
+ // default low/high input/output latency, default sample rate
+ PaDeviceIndex index() const;
+ const char *name() const;
+ int maxInputChannels() const;
+ int maxOutputChannels() const;
+ PaTime defaultLowInputLatency() const;
+ PaTime defaultHighInputLatency() const;
+ PaTime defaultLowOutputLatency() const;
+ PaTime defaultHighOutputLatency() const;
+ double defaultSampleRate() const;
+
+ bool isInputOnlyDevice() const; // extended
+ bool isOutputOnlyDevice() const; // extended
+ bool isFullDuplexDevice() const; // extended
+ bool isSystemDefaultInputDevice() const; // extended
+ bool isSystemDefaultOutputDevice() const; // extended
+ bool isHostApiDefaultInputDevice() const; // extended
+ bool isHostApiDefaultOutputDevice() const; // extended
+
+ bool operator==(const Device &rhs) const;
+ bool operator!=(const Device &rhs) const;
+
+ // host api reference
+ HostApi &hostApi();
+ const HostApi &hostApi() const;
+
+ private:
+ PaDeviceIndex index_;
+ const PaDeviceInfo *info_;
+
+ private:
+ friend class System;
+
+ explicit Device(PaDeviceIndex index);
+ ~Device();
+
+ Device(const Device &); // non-copyable
+ Device &operator=(const Device &); // non-copyable
+ };
+
+ // -----------------------------------------------------------------------------------
+
+} // namespace portaudio
+
+// ---------------------------------------------------------------------------------------
+
+#endif // INCLUDED_PORTAUDIO_DEVICE_HXX
+