1 #ifndef INCLUDED_PORTAUDIO_DEVICE_HXX
2 #define INCLUDED_PORTAUDIO_DEVICE_HXX
3 
4 // ---------------------------------------------------------------------------------------
5 
6 #include <iterator>
7 
8 #include "portaudio.h"
9 
10 #include "portaudiocpp/SampleDataFormat.hxx"
11 
12 // ---------------------------------------------------------------------------------------
13 
14 // Forward declaration(s):
15 namespace portaudio
16 {
17 	class System;
18 	class HostApi;
19 }
20 
21 // ---------------------------------------------------------------------------------------
22 
23 // Declaration(s):
24 namespace portaudio
25 {
26 
27 	//////
28 	/// @brief Class which represents a PortAudio device in the System.
29 	///
30 	/// A single physical device in the system may have multiple PortAudio
31 	/// Device representations using different HostApi 's though. A Device
32 	/// can be half-duplex or full-duplex. A half-duplex Device can be used
33 	/// to create a half-duplex Stream. A full-duplex Device can be used to
34 	/// create a full-duplex Stream. If supported by the HostApi, two
35 	/// half-duplex Devices can even be used to create a full-duplex Stream.
36 	///
37 	/// Note that Device objects are very light-weight and can be passed around
38 	/// by-value.
39 	//////
40 	class Device
41 	{
42 	public:
43 		// query info: name, max in channels, max out channels,
44 		// default low/hight input/output latency, default sample rate
45 		PaDeviceIndex index() const;
46 		const char *name() const;
47 		int maxInputChannels() const;
48 		int maxOutputChannels() const;
49 		PaTime defaultLowInputLatency() const;
50 		PaTime defaultHighInputLatency() const;
51 		PaTime defaultLowOutputLatency() const;
52 		PaTime defaultHighOutputLatency() const;
53 		double defaultSampleRate() const;
54 
55 		bool isInputOnlyDevice() const; // extended
56 		bool isOutputOnlyDevice() const; // extended
57 		bool isFullDuplexDevice() const; // extended
58 		bool isSystemDefaultInputDevice() const; // extended
59 		bool isSystemDefaultOutputDevice() const; // extended
60 		bool isHostApiDefaultInputDevice() const; // extended
61 		bool isHostApiDefaultOutputDevice() const; // extended
62 
63 		bool operator==(const Device &rhs) const;
64 		bool operator!=(const Device &rhs) const;
65 
66 		// host api reference
67 		HostApi &hostApi();
68 		const HostApi &hostApi() const;
69 
70 	private:
71 		PaDeviceIndex index_;
72 		const PaDeviceInfo *info_;
73 
74 	private:
75 		friend class System;
76 
77 		explicit Device(PaDeviceIndex index);
78 		~Device();
79 
80 		Device(const Device &); // non-copyable
81 		Device &operator=(const Device &); // non-copyable
82 	};
83 
84 	// -----------------------------------------------------------------------------------
85 
86 } // namespace portaudio
87 
88 // ---------------------------------------------------------------------------------------
89 
90 #endif // INCLUDED_PORTAUDIO_DEVICE_HXX
91 
92