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