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