summaryrefslogtreecommitdiff
path: root/3rdparty/portaudio/bindings/cpp/include/portaudiocpp/StreamParameters.hxx
blob: c0ec9a9aeb0ed7dfade682d0b46f162b2a175c1e (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
#ifndef INCLUDED_PORTAUDIO_STREAMPARAMETERS_HXX
#define INCLUDED_PORTAUDIO_STREAMPARAMETERS_HXX

// ---------------------------------------------------------------------------------------

#include "portaudio.h"

#include "portaudiocpp/DirectionSpecificStreamParameters.hxx"

// ---------------------------------------------------------------------------------------

// Declaration(s):
namespace portaudio
{

	//////
	/// @brief The entire set of parameters needed to configure and open 
	/// a Stream.
	///
	/// It contains parameters of input, output and shared parameters. 
	/// Using the isSupported() method, the StreamParameters can be 
	/// checked if opening a Stream using this StreamParameters would 
	/// succeed or not. Accessors are provided to higher-level parameters 
	/// aswell as the lower-level parameters which are mainly intended for 
	/// internal use.
	//////
	class StreamParameters
	{
	public:
		StreamParameters();
		StreamParameters(const DirectionSpecificStreamParameters &inputParameters, 
			const DirectionSpecificStreamParameters &outputParameters, double sampleRate, 
			unsigned long framesPerBuffer, PaStreamFlags flags);

		// Set up for direction-specific:
		void setInputParameters(const DirectionSpecificStreamParameters &parameters);
		void setOutputParameters(const DirectionSpecificStreamParameters &parameters);

		// Set up for common parameters:
		void setSampleRate(double sampleRate);
		void setFramesPerBuffer(unsigned long framesPerBuffer);
		void setFlag(PaStreamFlags flag);
		void unsetFlag(PaStreamFlags flag);
		void clearFlags();

		// Validation:
		bool isSupported() const;

		// Accessors (direction-specific):
		DirectionSpecificStreamParameters &inputParameters();
		const DirectionSpecificStreamParameters &inputParameters() const;
		DirectionSpecificStreamParameters &outputParameters();
		const DirectionSpecificStreamParameters &outputParameters() const;

		// Accessors (common):
		double sampleRate() const;
		unsigned long framesPerBuffer() const;
		PaStreamFlags flags() const;
		bool isFlagSet(PaStreamFlags flag) const;

	private:
		// Half-duplex specific parameters:
		DirectionSpecificStreamParameters inputParameters_;
		DirectionSpecificStreamParameters outputParameters_;

		// Common parameters:
		double sampleRate_;
		unsigned long framesPerBuffer_;
		PaStreamFlags flags_;
	};


} // namespace portaudio

// ---------------------------------------------------------------------------------------

#endif // INCLUDED_PORTAUDIO_STREAMPARAMETERS_HXX