1 #ifndef INCLUDED_PORTAUDIO_STREAMPARAMETERS_HXX
2 #define INCLUDED_PORTAUDIO_STREAMPARAMETERS_HXX
3 
4 // ---------------------------------------------------------------------------------------
5 
6 #include "portaudio.h"
7 
8 #include "portaudiocpp/DirectionSpecificStreamParameters.hxx"
9 
10 // ---------------------------------------------------------------------------------------
11 
12 // Declaration(s):
13 namespace portaudio
14 {
15 
16 	//////
17 	/// @brief The entire set of parameters needed to configure and open
18 	/// a Stream.
19 	///
20 	/// It contains parameters of input, output and shared parameters.
21 	/// Using the isSupported() method, the StreamParameters can be
22 	/// checked if opening a Stream using this StreamParameters would
23 	/// succeed or not. Accessors are provided to higher-level parameters
24 	/// aswell as the lower-level parameters which are mainly intended for
25 	/// internal use.
26 	//////
27 	class StreamParameters
28 	{
29 	public:
30 		StreamParameters();
31 		StreamParameters(const DirectionSpecificStreamParameters &inputParameters,
32 			const DirectionSpecificStreamParameters &outputParameters, double sampleRate,
33 			unsigned long framesPerBuffer, PaStreamFlags flags);
34 
35 		// Set up for direction-specific:
36 		void setInputParameters(const DirectionSpecificStreamParameters &parameters);
37 		void setOutputParameters(const DirectionSpecificStreamParameters &parameters);
38 
39 		// Set up for common parameters:
40 		void setSampleRate(double sampleRate);
41 		void setFramesPerBuffer(unsigned long framesPerBuffer);
42 		void setFlag(PaStreamFlags flag);
43 		void unsetFlag(PaStreamFlags flag);
44 		void clearFlags();
45 
46 		// Validation:
47 		bool isSupported() const;
48 
49 		// Accessors (direction-specific):
50 		DirectionSpecificStreamParameters &inputParameters();
51 		const DirectionSpecificStreamParameters &inputParameters() const;
52 		DirectionSpecificStreamParameters &outputParameters();
53 		const DirectionSpecificStreamParameters &outputParameters() const;
54 
55 		// Accessors (common):
56 		double sampleRate() const;
57 		unsigned long framesPerBuffer() const;
58 		PaStreamFlags flags() const;
59 		bool isFlagSet(PaStreamFlags flag) const;
60 
61 	private:
62 		// Half-duplex specific parameters:
63 		DirectionSpecificStreamParameters inputParameters_;
64 		DirectionSpecificStreamParameters outputParameters_;
65 
66 		// Common parameters:
67 		double sampleRate_;
68 		unsigned long framesPerBuffer_;
69 		PaStreamFlags flags_;
70 	};
71 
72 
73 } // namespace portaudio
74 
75 // ---------------------------------------------------------------------------------------
76 
77 #endif // INCLUDED_PORTAUDIO_STREAMPARAMETERS_HXX
78