summaryrefslogtreecommitdiff
path: root/3rdparty/portaudio/bindings/cpp/include/portaudiocpp/Device.hxx
blob: 05995828e4a1a80ff3b4bd66cf4873700a5dbdc6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
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