Chris@4
|
1 #ifndef INCLUDED_PORTAUDIO_STREAM_HXX
|
Chris@4
|
2 #define INCLUDED_PORTAUDIO_STREAM_HXX
|
Chris@4
|
3
|
Chris@4
|
4 #include "portaudio.h"
|
Chris@4
|
5
|
Chris@4
|
6 // ---------------------------------------------------------------------------------------
|
Chris@4
|
7
|
Chris@4
|
8 // Forward declaration(s):
|
Chris@4
|
9 namespace portaudio
|
Chris@4
|
10 {
|
Chris@4
|
11 class StreamParameters;
|
Chris@4
|
12 }
|
Chris@4
|
13
|
Chris@4
|
14 // ---------------------------------------------------------------------------------------
|
Chris@4
|
15
|
Chris@4
|
16 // Declaration(s):
|
Chris@4
|
17 namespace portaudio
|
Chris@4
|
18 {
|
Chris@4
|
19
|
Chris@4
|
20
|
Chris@4
|
21 //////
|
Chris@4
|
22 /// @brief A Stream represents an active or inactive input and/or output data
|
Chris@4
|
23 /// stream in the System.
|
Chris@4
|
24 ///
|
Chris@4
|
25 /// Concrete Stream classes should ensure themselves being in a closed state at
|
Chris@4
|
26 /// destruction (i.e. by calling their own close() method in their deconstructor).
|
Chris@4
|
27 /// Following good C++ programming practices, care must be taken to ensure no
|
Chris@4
|
28 /// exceptions are thrown by the deconstructor of these classes. As a consequence,
|
Chris@4
|
29 /// clients need to explicitly call close() to ensure the stream closed successfully.
|
Chris@4
|
30 ///
|
Chris@4
|
31 /// The Stream object can be used to manipulate the Stream's state. Also, time-constant
|
Chris@4
|
32 /// and time-varying information about the Stream can be retreived.
|
Chris@4
|
33 //////
|
Chris@4
|
34 class Stream
|
Chris@4
|
35 {
|
Chris@4
|
36 public:
|
Chris@4
|
37 // Opening/closing:
|
Chris@4
|
38 virtual ~Stream();
|
Chris@4
|
39
|
Chris@4
|
40 virtual void close();
|
Chris@4
|
41 bool isOpen() const;
|
Chris@4
|
42
|
Chris@4
|
43 // Additional set up:
|
Chris@4
|
44 void setStreamFinishedCallback(PaStreamFinishedCallback *callback);
|
Chris@4
|
45
|
Chris@4
|
46 // State management:
|
Chris@4
|
47 void start();
|
Chris@4
|
48 void stop();
|
Chris@4
|
49 void abort();
|
Chris@4
|
50
|
Chris@4
|
51 bool isStopped() const;
|
Chris@4
|
52 bool isActive() const;
|
Chris@4
|
53
|
Chris@4
|
54 // Stream info (time-constant, but might become time-variant soon):
|
Chris@4
|
55 PaTime inputLatency() const;
|
Chris@4
|
56 PaTime outputLatency() const;
|
Chris@4
|
57 double sampleRate() const;
|
Chris@4
|
58
|
Chris@4
|
59 // Stream info (time-varying):
|
Chris@4
|
60 PaTime time() const;
|
Chris@4
|
61
|
Chris@4
|
62 // Accessors for PortAudio PaStream, useful for interfacing
|
Chris@4
|
63 // with PortAudio add-ons (such as PortMixer) for instance:
|
Chris@4
|
64 const PaStream *paStream() const;
|
Chris@4
|
65 PaStream *paStream();
|
Chris@4
|
66
|
Chris@4
|
67 protected:
|
Chris@4
|
68 Stream(); // abstract class
|
Chris@4
|
69
|
Chris@4
|
70 PaStream *stream_;
|
Chris@4
|
71
|
Chris@4
|
72 private:
|
Chris@4
|
73 Stream(const Stream &); // non-copyable
|
Chris@4
|
74 Stream &operator=(const Stream &); // non-copyable
|
Chris@4
|
75 };
|
Chris@4
|
76
|
Chris@4
|
77
|
Chris@4
|
78 } // namespace portaudio
|
Chris@4
|
79
|
Chris@4
|
80
|
Chris@4
|
81 #endif // INCLUDED_PORTAUDIO_STREAM_HXX
|
Chris@4
|
82
|