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

#include "portaudio.h"

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

// Forward declaration(s):
namespace portaudio
{
	class StreamParameters;
}

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

// Declaration(s):
namespace portaudio
{


	//////
	/// @brief A Stream represents an active or inactive input and/or output data 
	/// stream in the System.
	/// 
	/// Concrete Stream classes should ensure themselves being in a closed state at 
	/// destruction (i.e. by calling their own close() method in their deconstructor). 
	/// Following good C++ programming practices, care must be taken to ensure no 
	/// exceptions are thrown by the deconstructor of these classes. As a consequence, 
	/// clients need to explicitly call close() to ensure the stream closed successfully.
	///
	/// The Stream object can be used to manipulate the Stream's state. Also, time-constant 
	/// and time-varying information about the Stream can be retrieved.
	//////
	class Stream
	{
	public:
		// Opening/closing:
		virtual ~Stream();

		virtual void close();
		bool isOpen() const;

		// Additional set up:
		void setStreamFinishedCallback(PaStreamFinishedCallback *callback);

		// State management:
		void start();
		void stop();
		void abort();

		bool isStopped() const;
		bool isActive() const;

		// Stream info (time-constant, but might become time-variant soon):
		PaTime inputLatency() const;
		PaTime outputLatency() const;
		double sampleRate() const;

		// Stream info (time-varying):
		PaTime time() const;

		// Accessors for PortAudio PaStream, useful for interfacing 
		// with PortAudio add-ons (such as PortMixer) for instance:
		const PaStream *paStream() const;
		PaStream *paStream();

	protected:
		Stream(); // abstract class

		PaStream *stream_;

	private:
		Stream(const Stream &); // non-copyable
		Stream &operator=(const Stream &); // non-copyable
	};


} // namespace portaudio


#endif // INCLUDED_PORTAUDIO_STREAM_HXX