Chris@55: #ifndef INCLUDED_PORTAUDIO_STREAM_HXX Chris@55: #define INCLUDED_PORTAUDIO_STREAM_HXX Chris@55: Chris@55: #include "portaudio.h" Chris@55: Chris@55: // --------------------------------------------------------------------------------------- Chris@55: Chris@55: // Forward declaration(s): Chris@55: namespace portaudio Chris@55: { Chris@55: class StreamParameters; Chris@55: } Chris@55: Chris@55: // --------------------------------------------------------------------------------------- Chris@55: Chris@55: // Declaration(s): Chris@55: namespace portaudio Chris@55: { Chris@55: Chris@55: Chris@55: ////// Chris@55: /// @brief A Stream represents an active or inactive input and/or output data Chris@55: /// stream in the System. Chris@55: /// Chris@55: /// Concrete Stream classes should ensure themselves being in a closed state at Chris@55: /// destruction (i.e. by calling their own close() method in their deconstructor). Chris@55: /// Following good C++ programming practices, care must be taken to ensure no Chris@55: /// exceptions are thrown by the deconstructor of these classes. As a consequence, Chris@55: /// clients need to explicitly call close() to ensure the stream closed successfully. Chris@55: /// Chris@55: /// The Stream object can be used to manipulate the Stream's state. Also, time-constant Chris@55: /// and time-varying information about the Stream can be retreived. Chris@55: ////// Chris@55: class Stream Chris@55: { Chris@55: public: Chris@55: // Opening/closing: Chris@55: virtual ~Stream(); Chris@55: Chris@55: virtual void close(); Chris@55: bool isOpen() const; Chris@55: Chris@55: // Additional set up: Chris@55: void setStreamFinishedCallback(PaStreamFinishedCallback *callback); Chris@55: Chris@55: // State management: Chris@55: void start(); Chris@55: void stop(); Chris@55: void abort(); Chris@55: Chris@55: bool isStopped() const; Chris@55: bool isActive() const; Chris@55: Chris@55: // Stream info (time-constant, but might become time-variant soon): Chris@55: PaTime inputLatency() const; Chris@55: PaTime outputLatency() const; Chris@55: double sampleRate() const; Chris@55: Chris@55: // Stream info (time-varying): Chris@55: PaTime time() const; Chris@55: Chris@55: // Accessors for PortAudio PaStream, useful for interfacing Chris@55: // with PortAudio add-ons (such as PortMixer) for instance: Chris@55: const PaStream *paStream() const; Chris@55: PaStream *paStream(); Chris@55: Chris@55: protected: Chris@55: Stream(); // abstract class Chris@55: Chris@55: PaStream *stream_; Chris@55: Chris@55: private: Chris@55: Stream(const Stream &); // non-copyable Chris@55: Stream &operator=(const Stream &); // non-copyable Chris@55: }; Chris@55: Chris@55: Chris@55: } // namespace portaudio Chris@55: Chris@55: Chris@55: #endif // INCLUDED_PORTAUDIO_STREAM_HXX Chris@55: