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