--- /dev/null
+#ifndef INCLUDED_PORTAUDIO_ASIODEVICEADAPTER_HXX
+#define INCLUDED_PORTAUDIO_ASIODEVICEADAPTER_HXX
+
+namespace portaudio
+{
+
+ // Forward declaration(s):
+ class Device;
+
+ // Declaration(s):
+ //////
+ /// @brief Adapts the given Device to an ASIO specific extension.
+ ///
+ /// Deleting the AsioDeviceAdapter does not affect the underlaying
+ /// Device.
+ //////
+ class AsioDeviceAdapter
+ {
+ public:
+ AsioDeviceAdapter(Device &device);
+
+ Device &device();
+
+ long minBufferSize() const;
+ long maxBufferSize() const;
+ long preferredBufferSize() const;
+ long granularity() const;
+
+ void showControlPanel(void *systemSpecific);
+
+ const char *inputChannelName(int channelIndex) const;\r
+ const char *outputChannelName(int channelIndex) const;
+
+ private:
+ Device *device_;
+
+ long minBufferSize_;
+ long maxBufferSize_;
+ long preferredBufferSize_;
+ long granularity_;
+ };
+}
+
+#endif // INCLUDED_PORTAUDIO_ASIODEVICEADAPTER_HXX
--- /dev/null
+#ifndef INCLUDED_PORTAUDIO_AUTOSYSTEM_HXX\r
+#define INCLUDED_PORTAUDIO_AUTOSYSTEM_HXX\r
+\r
+// ---------------------------------------------------------------------------------------\r
+\r
+#include "portaudiocpp/System.hxx"\r
+\r
+// ---------------------------------------------------------------------------------------\r
+\r
+namespace portaudio\r
+{\r
+\r
+\r
+ //////\r
+ /// @brief A RAII idiom class to ensure automatic clean-up when an exception is \r
+ /// raised.\r
+ ///\r
+ /// A simple helper class which uses the 'Resource Acquisition is Initialization' \r
+ /// idiom (RAII). Use this class to initialize/terminate the System rather than \r
+ /// using System directly. AutoSystem must be created on stack and must be valid \r
+ /// throughout the time you wish to use PortAudioCpp. Your 'main' function might be \r
+ /// a good place for it.\r
+ ///\r
+ /// To avoid having to type portaudio::System::instance().xyz() all the time, it's usually \r
+ /// a good idea to make a reference to the System which can be accessed directly.\r
+ /// @verbatim\r
+ /// portaudio::AutoSys autoSys;\r
+ /// portaudio::System &sys = portaudio::System::instance();\r
+ /// @endverbatim\r
+ //////\r
+ class AutoSystem\r
+ {\r
+ public:\r
+ AutoSystem(bool initialize = true)\r
+ {\r
+ if (initialize)\r
+ System::initialize();\r
+ }\r
+\r
+ ~AutoSystem()\r
+ {\r
+ if (System::exists())\r
+ System::terminate();\r
+ }\r
+\r
+ void initialize()\r
+ {\r
+ System::initialize();\r
+ }\r
+\r
+ void terminate()\r
+ {\r
+ System::terminate();\r
+ }\r
+ };\r
+\r
+\r
+} // namespace portaudio\r
+\r
+// ---------------------------------------------------------------------------------------\r
+\r
+#endif // INCLUDED_PORTAUDIO_AUTOSYSTEM_HXX\r
--- /dev/null
+#ifndef INCLUDED_PORTAUDIO_BLOCKINGSTREAM_HXX\r
+#define INCLUDED_PORTAUDIO_BLOCKINGSTREAM_HXX\r
+\r
+// ---------------------------------------------------------------------------------------\r
+\r
+#include "portaudiocpp/Stream.hxx"\r
+\r
+// ---------------------------------------------------------------------------------------\r
+\r
+namespace portaudio\r
+{\r
+\r
+\r
+\r
+ //////\r
+ /// @brief Stream class for blocking read/write-style input and output.\r
+ //////\r
+ class BlockingStream : public Stream\r
+ {\r
+ public:\r
+ BlockingStream();\r
+ BlockingStream(const StreamParameters ¶meters);\r
+ ~BlockingStream();\r
+\r
+ void open(const StreamParameters ¶meters);\r
+\r
+ void read(void *buffer, unsigned long numFrames);\r
+ void write(const void *buffer, unsigned long numFrames);\r
+\r
+ signed long availableReadSize() const;\r
+ signed long availableWriteSize() const;\r
+\r
+ private:\r
+ BlockingStream(const BlockingStream &); // non-copyable\r
+ BlockingStream &operator=(const BlockingStream &); // non-copyable\r
+ };\r
+\r
+\r
+\r
+} // portaudio\r
+\r
+// ---------------------------------------------------------------------------------------\r
+\r
+#endif // INCLUDED_PORTAUDIO_BLOCKINGSTREAM_HXX\r
+\r
--- /dev/null
+#ifndef INCLUDED_PORTAUDIO_CFUNCALLBACKSTREAM_HXX\r
+#define INCLUDED_PORTAUDIO_CFUNCALLBACKSTREAM_HXX\r
+\r
+// ---------------------------------------------------------------------------------------\r
+\r
+#include "portaudio.h"\r
+\r
+#include "portaudiocpp/CallbackStream.hxx"\r
+\r
+// ---------------------------------------------------------------------------------------\r
+\r
+// Forward declaration(s)\r
+namespace portaudio\r
+{\r
+ class StreamParameters;\r
+}\r
+\r
+// ---------------------------------------------------------------------------------------\r
+\r
+// Declaration(s):\r
+namespace portaudio\r
+{\r
+ // -----------------------------------------------------------------------------------\r
+\r
+ //////\r
+ /// @brief Callback stream using a free function with C linkage. It's important that the function \r
+ /// the passed function pointer points to is declared ``extern "C"''.\r
+ //////\r
+ class CFunCallbackStream : public CallbackStream\r
+ {\r
+ public:\r
+ CFunCallbackStream();\r
+ CFunCallbackStream(const StreamParameters ¶meters, PaStreamCallback *funPtr, void *userData);\r
+ ~CFunCallbackStream();\r
+ \r
+ void open(const StreamParameters ¶meters, PaStreamCallback *funPtr, void *userData);\r
+\r
+ private:\r
+ CFunCallbackStream(const CFunCallbackStream &); // non-copyable\r
+ CFunCallbackStream &operator=(const CFunCallbackStream &); // non-copyable\r
+ };\r
+\r
+ // -----------------------------------------------------------------------------------\r
+} // portaudio\r
+\r
+// ---------------------------------------------------------------------------------------\r
+\r
+#endif // INCLUDED_PORTAUDIO_MEMFUNCALLBACKSTREAM_HXX\r
+\r
--- /dev/null
+#ifndef INCLUDED_PORTAUDIO_CALLBACKINTERFACE_HXX\r
+#define INCLUDED_PORTAUDIO_CALLBACKINTERFACE_HXX\r
+\r
+// ---------------------------------------------------------------------------------------\r
+\r
+#include "portaudio.h"\r
+\r
+// ---------------------------------------------------------------------------------------\r
+\r
+namespace portaudio\r
+{\r
+ // -----------------------------------------------------------------------------------\r
+\r
+ //////\r
+ /// @brief Interface for an object that's callable as a PortAudioCpp callback object (ie that implements the \r
+ /// paCallbackFun method).\r
+ //////\r
+ class CallbackInterface\r
+ {\r
+ public:\r
+ virtual ~CallbackInterface() {}\r
+\r
+ virtual int paCallbackFun(const void *inputBuffer, void *outputBuffer, unsigned long numFrames, \r
+ const PaStreamCallbackTimeInfo *timeInfo, PaStreamCallbackFlags statusFlags) = 0;\r
+ };\r
+\r
+ // -----------------------------------------------------------------------------------\r
+\r
+ namespace impl\r
+ {\r
+ extern "C"\r
+ {\r
+ int callbackInterfaceToPaCallbackAdapter(const void *inputBuffer, void *outputBuffer, unsigned long numFrames, \r
+ const PaStreamCallbackTimeInfo *timeInfo, PaStreamCallbackFlags statusFlags, \r
+ void *userData);\r
+ } // extern "C"\r
+ }\r
+\r
+ // -----------------------------------------------------------------------------------\r
+\r
+} // namespace portaudio\r
+\r
+// ---------------------------------------------------------------------------------------\r
+\r
+#endif // INCLUDED_PORTAUDIO_CALLBACKINTERFACE_HXX\r
--- /dev/null
+#ifndef INCLUDED_PORTAUDIO_CALLBACKSTREAM_HXX\r
+#define INCLUDED_PORTAUDIO_CALLBACKSTREAM_HXX\r
+\r
+// ---------------------------------------------------------------------------------------\r
+\r
+#include "portaudio.h"\r
+\r
+#include "portaudiocpp/Stream.hxx"\r
+\r
+// ---------------------------------------------------------------------------------------\r
+\r
+// Declaration(s):\r
+namespace portaudio\r
+{\r
+\r
+\r
+ //////\r
+ /// @brief Base class for all Streams which use a callback-based mechanism.\r
+ //////\r
+ class CallbackStream : public Stream\r
+ {\r
+ protected:\r
+ CallbackStream();\r
+ virtual ~CallbackStream();\r
+\r
+ public:\r
+ // stream info (time-varying)\r
+ double cpuLoad() const;\r
+\r
+ private:\r
+ CallbackStream(const CallbackStream &); // non-copyable\r
+ CallbackStream &operator=(const CallbackStream &); // non-copyable\r
+ };\r
+\r
+\r
+} // namespace portaudio\r
+\r
+// ---------------------------------------------------------------------------------------\r
+\r
+#endif // INCLUDED_PORTAUDIO_CALLBACKSTREAM_HXX\r
--- /dev/null
+#ifndef INCLUDED_PORTAUDIO_CPPFUNCALLBACKSTREAM_HXX\r
+#define INCLUDED_PORTAUDIO_CPPFUNCALLBACKSTREAM_HXX\r
+\r
+// ---------------------------------------------------------------------------------------\r
+\r
+#include "portaudio.h"\r
+\r
+#include "portaudiocpp/CallbackStream.hxx"\r
+\r
+// ---------------------------------------------------------------------------------------\r
+\r
+// Forward declaration(s):\r
+namespace portaudio\r
+{\r
+ class StreamParameters;\r
+}\r
+\r
+// ---------------------------------------------------------------------------------------\r
+\r
+// Declaration(s):\r
+namespace portaudio\r
+{\r
+\r
+\r
+ namespace impl\r
+ {\r
+ extern "C"\r
+ {\r
+ int cppCallbackToPaCallbackAdapter(const void *inputBuffer, void *outputBuffer, unsigned long numFrames, \r
+ const PaStreamCallbackTimeInfo *timeInfo, PaStreamCallbackFlags statusFlags, \r
+ void *userData);\r
+ } // extern "C"\r
+ }\r
+\r
+ // -----------------------------------------------------------------------------------\r
+\r
+ //////\r
+ /// @brief Callback stream using a C++ function (either a free function or a static function) \r
+ /// callback.\r
+ //////\r
+ class FunCallbackStream : public CallbackStream\r
+ {\r
+ public:\r
+ typedef int (*CallbackFunPtr)(const void *inputBuffer, void *outputBuffer, unsigned long numFrames, \r
+ const PaStreamCallbackTimeInfo *timeInfo, PaStreamCallbackFlags statusFlags, \r
+ void *userData);\r
+\r
+ // -------------------------------------------------------------------------------\r
+\r
+ //////\r
+ /// @brief Simple structure containing a function pointer to the C++ callback function and a \r
+ /// (void) pointer to the user supplied data.\r
+ //////\r
+ struct CppToCCallbackData\r
+ {\r
+ CppToCCallbackData();\r
+ CppToCCallbackData(CallbackFunPtr funPtr, void *userData);\r
+ void init(CallbackFunPtr funPtr, void *userData);\r
+\r
+ CallbackFunPtr funPtr;\r
+ void *userData;\r
+ };\r
+\r
+ // -------------------------------------------------------------------------------\r
+\r
+ FunCallbackStream();\r
+ FunCallbackStream(const StreamParameters ¶meters, CallbackFunPtr funPtr, void *userData);\r
+ ~FunCallbackStream();\r
+\r
+ void open(const StreamParameters ¶meters, CallbackFunPtr funPtr, void *userData);\r
+\r
+ private:\r
+ FunCallbackStream(const FunCallbackStream &); // non-copyable\r
+ FunCallbackStream &operator=(const FunCallbackStream &); // non-copyable\r
+\r
+ CppToCCallbackData adapterData_;\r
+\r
+ void open(const StreamParameters ¶meters);\r
+ };\r
+\r
+\r
+} // portaudio\r
+\r
+// ---------------------------------------------------------------------------------------\r
+\r
+#endif // INCLUDED_PORTAUDIO_CPPFUNCALLBACKSTREAM_HXX\r
--- /dev/null
+#ifndef INCLUDED_PORTAUDIO_DEVICE_HXX\r
+#define INCLUDED_PORTAUDIO_DEVICE_HXX\r
+\r
+// ---------------------------------------------------------------------------------------\r
+\r
+#include <iterator>\r
+\r
+#include "portaudio.h"\r
+\r
+#include "portaudiocpp/SampleDataFormat.hxx"\r
+\r
+// ---------------------------------------------------------------------------------------\r
+\r
+// Forward declaration(s):\r
+namespace portaudio\r
+{\r
+ class System;\r
+ class HostApi;\r
+}\r
+\r
+// ---------------------------------------------------------------------------------------\r
+\r
+// Declaration(s):\r
+namespace portaudio\r
+{\r
+\r
+ //////\r
+ /// @brief Class which represents a PortAudio device in the System.\r
+ ///\r
+ /// A single physical device in the system may have multiple PortAudio \r
+ /// Device representations using different HostApi 's though. A Device \r
+ /// can be half-duplex or full-duplex. A half-duplex Device can be used \r
+ /// to create a half-duplex Stream. A full-duplex Device can be used to \r
+ /// create a full-duplex Stream. If supported by the HostApi, two \r
+ /// half-duplex Devices can even be used to create a full-duplex Stream.\r
+ ///\r
+ /// Note that Device objects are very light-weight and can be passed around \r
+ /// by-value.\r
+ //////\r
+ class Device\r
+ {\r
+ public:\r
+ // query info: name, max in channels, max out channels, \r
+ // default low/hight input/output latency, default sample rate\r
+ PaDeviceIndex index() const;\r
+ const char *name() const;\r
+ int maxInputChannels() const;\r
+ int maxOutputChannels() const;\r
+ PaTime defaultLowInputLatency() const;\r
+ PaTime defaultHighInputLatency() const;\r
+ PaTime defaultLowOutputLatency() const;\r
+ PaTime defaultHighOutputLatency() const;\r
+ double defaultSampleRate() const;\r
+\r
+ bool isInputOnlyDevice() const; // extended\r
+ bool isOutputOnlyDevice() const; // extended\r
+ bool isFullDuplexDevice() const; // extended\r
+ bool isSystemDefaultInputDevice() const; // extended\r
+ bool isSystemDefaultOutputDevice() const; // extended\r
+ bool isHostApiDefaultInputDevice() const; // extended\r
+ bool isHostApiDefaultOutputDevice() const; // extended\r
+\r
+ bool operator==(const Device &rhs);\r
+ bool operator!=(const Device &rhs);\r
+\r
+ // host api reference\r
+ HostApi &hostApi();\r
+ const HostApi &hostApi() const;\r
+\r
+ private:\r
+ PaDeviceIndex index_;\r
+ const PaDeviceInfo *info_;\r
+\r
+ private:\r
+ friend class System;\r
+ \r
+ explicit Device(PaDeviceIndex index);\r
+ ~Device();\r
+\r
+ Device(const Device &); // non-copyable\r
+ Device &operator=(const Device &); // non-copyable\r
+ };\r
+\r
+ // -----------------------------------------------------------------------------------\r
+\r
+} // namespace portaudio\r
+\r
+// ---------------------------------------------------------------------------------------\r
+\r
+#endif // INCLUDED_PORTAUDIO_DEVICE_HXX\r
+\r
--- /dev/null
+#ifndef INCLUDED_PORTAUDIO_SINGLEDIRECTIONSTREAMPARAMETERS_HXX\r
+#define INCLUDED_PORTAUDIO_SINGLEDIRECTIONSTREAMPARAMETERS_HXX\r
+\r
+// ---------------------------------------------------------------------------------------\r
+\r
+#include <cstddef>\r
+\r
+#include "portaudio.h"\r
+\r
+#include "portaudiocpp/System.hxx"\r
+#include "portaudiocpp/SampleDataFormat.hxx"\r
+\r
+// ---------------------------------------------------------------------------------------\r
+\r
+// Forward declaration(s):\r
+namespace portaudio\r
+{\r
+ class Device;\r
+}\r
+\r
+// ---------------------------------------------------------------------------------------\r
+\r
+// Declaration(s):\r
+namespace portaudio\r
+{\r
+\r
+ //////\r
+ /// @brief All parameters for one direction (either in or out) of a Stream. Together with \r
+ /// parameters common to both directions, two DirectionSpecificStreamParameters can make up \r
+ /// a StreamParameters object which contains all parameters for a Stream.\r
+ //////\r
+ class DirectionSpecificStreamParameters\r
+ {\r
+ public:\r
+ static DirectionSpecificStreamParameters null();\r
+\r
+ DirectionSpecificStreamParameters();\r
+ DirectionSpecificStreamParameters(const Device &device, int numChannels, SampleDataFormat format, \r
+ bool interleaved, PaTime suggestedLatency, void *hostApiSpecificStreamInfo);\r
+\r
+ // Set up methods:\r
+ void setDevice(const Device &device);\r
+ void setNumChannels(int numChannels);\r
+\r
+ void setSampleFormat(SampleDataFormat format, bool interleaved = true);\r
+ void setHostApiSpecificSampleFormat(PaSampleFormat format, bool interleaved = true);\r
+\r
+ void setSuggestedLatency(PaTime latency);\r
+\r
+ void setHostApiSpecificStreamInfo(void *streamInfo);\r
+\r
+ // Accessor methods:\r
+ PaStreamParameters *paStreamParameters();\r
+ const PaStreamParameters *paStreamParameters() const;\r
+\r
+ Device &device() const;\r
+ int numChannels() const;\r
+\r
+ SampleDataFormat sampleFormat() const;\r
+ bool isSampleFormatInterleaved() const;\r
+ bool isSampleFormatHostApiSpecific() const;\r
+ PaSampleFormat hostApiSpecificSampleFormat() const;\r
+\r
+ PaTime suggestedLatency() const;\r
+\r
+ void *hostApiSpecificStreamInfo() const;\r
+ \r
+ private:\r
+ PaStreamParameters paStreamParameters_;\r
+ };\r
+\r
+\r
+} // namespace portaudio\r
+\r
+// ---------------------------------------------------------------------------------------\r
+\r
+#endif // INCLUDED_PORTAUDIO_SINGLEDIRECTIONSTREAMPARAMETERS_HXX\r
--- /dev/null
+#ifndef INCLUDED_PORTAUDIO_EXCEPTION_HXX\r
+#define INCLUDED_PORTAUDIO_EXCEPTION_HXX\r
+\r
+// ---------------------------------------------------------------------------------------\r
+\r
+#include <exception>\r
+\r
+#include "portaudio.h"\r
+\r
+// ---------------------------------------------------------------------------------------\r
+\r
+namespace portaudio\r
+{\r
+\r
+ //////\r
+ /// @brief Base class for all exceptions PortAudioCpp can throw.\r
+ ///\r
+ /// Class is derived from std::exception.\r
+ //////\r
+ class Exception : public std::exception\r
+ {\r
+ public:\r
+ virtual ~Exception() throw() {}\r
+\r
+ virtual const char *what() const throw() = 0;\r
+ };\r
+ \r
+ // -----------------------------------------------------------------------------------\r
+\r
+ //////\r
+ /// @brief Wrapper for PortAudio error codes to C++ exceptions.\r
+ ///\r
+ /// It wraps up PortAudio's error handling mechanism using \r
+ /// C++ exceptions and is derived from std::exception for \r
+ /// easy exception handling and to ease integration with \r
+ /// other code.\r
+ ///\r
+ /// To know what exceptions each function may throw, look up \r
+ /// the errors that can occure in the PortAudio documentation \r
+ /// for the equivalent functions.\r
+ ///\r
+ /// Some functions are likely to throw an exception (such as \r
+ /// Stream::open(), etc) and these should always be called in \r
+ /// try{} catch{} blocks and the thrown exceptions should be \r
+ /// handled properly (ie. the application shouldn't just abort, \r
+ /// but merely display a warning dialog to the user or something).\r
+ /// However nearly all functions in PortAudioCpp are capable \r
+ /// of throwing exceptions. When a function like Stream::isStopped() \r
+ /// throws an exception, it's such an exceptional state that it's \r
+ /// not likely that it can be recovered. PaExceptions such as these \r
+ /// can ``safely'' be left to be handled by some outer catch-all-like \r
+ /// mechanism for unrecoverable errors.\r
+ //////\r
+ class PaException : public Exception\r
+ {\r
+ public:\r
+ explicit PaException(PaError error);\r
+\r
+ const char *what() const throw();\r
+\r
+ PaError paError() const;\r
+ const char *paErrorText() const;\r
+\r
+ bool isHostApiError() const; // extended\r
+ long lastHostApiError() const;\r
+ const char *lastHostApiErrorText() const;\r
+\r
+ bool operator==(const PaException &rhs) const;\r
+ bool operator!=(const PaException &rhs) const;\r
+\r
+ private:\r
+ PaError error_;\r
+ };\r
+\r
+ // -----------------------------------------------------------------------------------\r
+\r
+ //////\r
+ /// @brief Exceptions specific to PortAudioCpp (ie. exceptions which do not have an \r
+ /// equivalent PortAudio error code).\r
+ //////\r
+ class PaCppException : public Exception\r
+ {\r
+ public:\r
+ enum ExceptionSpecifier\r
+ {\r
+ UNABLE_TO_ADAPT_DEVICE\r
+ };\r
+\r
+ PaCppException(ExceptionSpecifier specifier);\r
+\r
+ const char *what() const throw();\r
+\r
+ ExceptionSpecifier specifier() const;\r
+\r
+ bool operator==(const PaCppException &rhs) const;\r
+ bool operator!=(const PaCppException &rhs) const;\r
+\r
+ private:\r
+ ExceptionSpecifier specifier_;\r
+ };\r
+\r
+\r
+} // namespace portaudio\r
+\r
+// ---------------------------------------------------------------------------------------\r
+\r
+#endif // INCLUDED_PORTAUDIO_EXCEPTION_HXX\r
+\r
--- /dev/null
+#ifndef INCLUDED_PORTAUDIO_HOSTAPI_HXX\r
+#define INCLUDED_PORTAUDIO_HOSTAPI_HXX\r
+\r
+// ---------------------------------------------------------------------------------------\r
+\r
+#include "portaudio.h"\r
+\r
+#include "portaudiocpp/System.hxx"\r
+\r
+// ---------------------------------------------------------------------------------------\r
+\r
+// Forward declaration(s):\r
+namespace portaudio\r
+{\r
+ class Device;\r
+}\r
+\r
+// ---------------------------------------------------------------------------------------\r
+\r
+// Declaration(s):\r
+namespace portaudio\r
+{\r
+\r
+\r
+ //////\r
+ /// @brief HostApi represents a host API (usually type of driver) in the System.\r
+ ///\r
+ /// A single System can support multiple HostApi's each one typically having \r
+ /// a set of Devices using that HostApi (usually driver type). All Devices in \r
+ /// the HostApi can be enumerated and the default input/output Device for this \r
+ /// HostApi can be retreived.\r
+ //////\r
+ class HostApi\r
+ {\r
+ public:\r
+ typedef System::DeviceIterator DeviceIterator;\r
+\r
+ // query info: id, name, numDevices\r
+ PaHostApiTypeId typeId() const;\r
+ PaHostApiIndex index() const;\r
+ const char *name() const;\r
+ int deviceCount() const;\r
+\r
+ // iterate devices\r
+ DeviceIterator devicesBegin();\r
+ DeviceIterator devicesEnd();\r
+\r
+ // default devices\r
+ Device &defaultInputDevice() const;\r
+ Device &defaultOutputDevice() const;\r
+\r
+ // comparison operators\r
+ bool operator==(const HostApi &rhs) const;\r
+ bool operator!=(const HostApi &rhs) const;\r
+\r
+ private:\r
+ const PaHostApiInfo *info_;\r
+ Device **devices_;\r
+\r
+ private:\r
+ friend class System;\r
+\r
+ explicit HostApi(PaHostApiIndex index);\r
+ ~HostApi();\r
+\r
+ HostApi(const HostApi &); // non-copyable\r
+ HostApi &operator=(const HostApi &); // non-copyable\r
+ };\r
+\r
+\r
+}\r
+\r
+// ---------------------------------------------------------------------------------------\r
+\r
+#endif // INCLUDED_PORTAUDIO_HOSTAPI_HXX\r
+\r
--- /dev/null
+#ifndef INCLUDED_PORTAUDIO_INTERFACECALLBACKSTREAM_HXX\r
+#define INCLUDED_PORTAUDIO_INTERFACECALLBACKSTREAM_HXX\r
+\r
+// ---------------------------------------------------------------------------------------\r
+\r
+#include "portaudio.h"\r
+\r
+#include "portaudiocpp/CallbackStream.hxx"\r
+\r
+// ---------------------------------------------------------------------------------------\r
+\r
+// Forward declaration(s)\r
+namespace portaudio\r
+{\r
+ class StreamParameters;\r
+ class CallbackInterface;\r
+}\r
+\r
+// ---------------------------------------------------------------------------------------\r
+\r
+// Declaration(s):\r
+namespace portaudio\r
+{\r
+\r
+\r
+ //////\r
+ /// @brief Callback stream using an instance of an object that's derived from the CallbackInterface \r
+ /// interface.\r
+ //////\r
+ class InterfaceCallbackStream : public CallbackStream\r
+ {\r
+ public:\r
+ InterfaceCallbackStream();\r
+ InterfaceCallbackStream(const StreamParameters ¶meters, CallbackInterface &instance);\r
+ ~InterfaceCallbackStream();\r
+ \r
+ void open(const StreamParameters ¶meters, CallbackInterface &instance);\r
+\r
+ private:\r
+ InterfaceCallbackStream(const InterfaceCallbackStream &); // non-copyable\r
+ InterfaceCallbackStream &operator=(const InterfaceCallbackStream &); // non-copyable\r
+ };\r
+\r
+\r
+} // portaudio\r
+\r
+// ---------------------------------------------------------------------------------------\r
+\r
+#endif // INCLUDED_PORTAUDIO_INTERFACECALLBACKSTREAM_HXX\r
--- /dev/null
+#ifndef INCLUDED_PORTAUDIO_MEMFUNCALLBACKSTREAM_HXX\r
+#define INCLUDED_PORTAUDIO_MEMFUNCALLBACKSTREAM_HXX\r
+\r
+// ---------------------------------------------------------------------------------------\r
+\r
+#include "portaudio.h"\r
+\r
+#include "portaudiocpp/CallbackStream.hxx"\r
+#include "portaudiocpp/CallbackInterface.hxx"\r
+#include "portaudiocpp/StreamParameters.hxx"\r
+#include "portaudiocpp/Exception.hxx"\r
+#include "portaudiocpp/InterfaceCallbackStream.hxx"\r
+\r
+// ---------------------------------------------------------------------------------------\r
+\r
+namespace portaudio\r
+{\r
+\r
+\r
+ //////\r
+ /// @brief Callback stream using a class's member function as a callback. Template argument T is the type of the \r
+ /// class of which a member function is going to be used.\r
+ ///\r
+ /// Example usage:\r
+ /// @verbatim MemFunCallback<MyClass> stream = MemFunCallbackStream(parameters, *this, &MyClass::myCallbackFunction); @endverbatim\r
+ //////\r
+ template<typename T>\r
+ class MemFunCallbackStream : public CallbackStream\r
+ {\r
+ public:\r
+ typedef int (T::*CallbackFunPtr)(const void *, void *, unsigned long, const PaStreamCallbackTimeInfo *, \r
+ PaStreamCallbackFlags);\r
+\r
+ // -------------------------------------------------------------------------------\r
+\r
+ MemFunCallbackStream()\r
+ {\r
+ }\r
+\r
+ MemFunCallbackStream(const StreamParameters ¶meters, T &instance, CallbackFunPtr memFun) : adapter_(instance, memFun)\r
+ {\r
+ open(parameters);\r
+ }\r
+\r
+ ~MemFunCallbackStream()\r
+ {\r
+ close();\r
+ }\r
+\r
+ void open(const StreamParameters ¶meters, T &instance, CallbackFunPtr memFun)\r
+ {\r
+ // XXX: need to check if already open?\r
+\r
+ adapter_.init(instance, memFun);\r
+ open(parameters);\r
+ }\r
+\r
+ private:\r
+ MemFunCallbackStream(const MemFunCallbackStream &); // non-copyable\r
+ MemFunCallbackStream &operator=(const MemFunCallbackStream &); // non-copyable\r
+\r
+ //////\r
+ /// @brief Inner class which adapts a member function callback to a CallbackInterface compliant \r
+ /// class (so it can be adapted using the paCallbackAdapter function).\r
+ //////\r
+ class MemFunToCallbackInterfaceAdapter : public CallbackInterface\r
+ {\r
+ public:\r
+ MemFunToCallbackInterfaceAdapter() {}\r
+ MemFunToCallbackInterfaceAdapter(T &instance, CallbackFunPtr memFun) : instance_(&instance), memFun_(memFun) {}\r
+\r
+ void init(T &instance, CallbackFunPtr memFun)\r
+ {\r
+ instance_ = &instance;\r
+ memFun_ = memFun;\r
+ }\r
+\r
+ int paCallbackFun(const void *inputBuffer, void *outputBuffer, unsigned long numFrames, \r
+ const PaStreamCallbackTimeInfo *timeInfo, PaStreamCallbackFlags statusFlags)\r
+ {\r
+ return (instance_->*memFun_)(inputBuffer, outputBuffer, numFrames, timeInfo, statusFlags);\r
+ }\r
+\r
+ private:\r
+ T *instance_;\r
+ CallbackFunPtr memFun_;\r
+ };\r
+\r
+ MemFunToCallbackInterfaceAdapter adapter_;\r
+\r
+ void open(const StreamParameters ¶meters)\r
+ {\r
+ PaError err = Pa_OpenStream(&stream_, parameters.inputParameters().paStreamParameters(), parameters.outputParameters().paStreamParameters(), \r
+ parameters.sampleRate(), parameters.framesPerBuffer(), parameters.flags(), &impl::callbackInterfaceToPaCallbackAdapter, \r
+ static_cast<void *>(&adapter_));\r
+\r
+ if (err != paNoError)\r
+ throw PaException(err);\r
+ }\r
+ };\r
+\r
+\r
+} // portaudio\r
+\r
+// ---------------------------------------------------------------------------------------\r
+\r
+#endif // INCLUDED_PORTAUDIO_MEMFUNCALLBACKSTREAM_HXX\r
--- /dev/null
+#ifndef INCLUDED_PORTAUDIO_PORTAUDIOCPP_HXX\r
+#define INCLUDED_PORTAUDIO_PORTAUDIOCPP_HXX\r
+\r
+// ---------------------------------------------------------------------------------------\r
+\r
+//////\r
+/// @mainpage PortAudioCpp\r
+///\r
+/// <h1>PortAudioCpp - A Native C++ Binding of PortAudio V19</h1>\r
+/// <h2>PortAudio</h2>\r
+/// <p>\r
+/// PortAudio is a portable and mature C API for accessing audio hardware. It offers both callback-based and blocking \r
+/// style input and output, deals with sample data format conversions, dithering and much more. There are a large number \r
+/// of implementations available for various platforms including Windows MME, Windows DirectX, Windows and MacOS (Classic) \r
+/// ASIO, MacOS Classic SoundManager, MacOS X CoreAudio, OSS (Linux), Linux ALSA, JACK (MacOS X and Linux) and SGI Irix \r
+/// AL. Note that, currently not all of these implementations are equally complete or up-to-date (as PortAudio V19 is \r
+/// still in development). Because PortAudio has a C API, it can easily be called from a variety of other programming \r
+/// languages.\r
+/// </p>\r
+/// <h2>PortAudioCpp</h2>\r
+/// <p>\r
+/// Although, it is possible to use PortAudio's C API from within a C++ program, this is usually a little awkward \r
+/// as procedural and object-oriented paradigms need to be mixed. PortAudioCpp aims to resolve this by encapsulating \r
+/// PortAudio's C API to form an equivalent object-oriented C++ API. It provides a more natural integration of PortAudio \r
+/// into C++ programs as well as a more structured interface. PortAudio's concepts were preserved as much as possible and \r
+/// no additional features were added except for some `convenience methods'.\r
+/// </p>\r
+/// <p>\r
+/// PortAudioCpp's main features are:\r
+/// <ul>\r
+/// <li>Structured object model.</li>\r
+/// <li>C++ exception handling instead of C-style error return codes.</li>\r
+/// <li>Handling of callbacks using free functions (C and C++), static functions, member functions or instances of classes \r
+/// derived from a given interface.</li>\r
+/// <li>STL compliant iterators to host APIs and devices.</li>\r
+/// <li>Some additional convenience functions to more easily set up and use PortAudio.</li>\r
+/// </ul>\r
+/// </p>\r
+/// <p>\r
+/// PortAudioCpp requires a recent version of the PortAudio V19 source code. This can be obtained from CVS or as a snapshot \r
+/// from the website. The examples also require the ASIO 2 SDK which can be obtained from the Steinberg website. Alternatively, the \r
+/// examples can easily be modified to compile without needing ASIO.\r
+/// </p>\r
+/// <p>\r
+/// Supported platforms:\r
+/// <ul>\r
+/// <li>Microsoft Visual C++ 6.0, 7.0 (.NET 2002) and 7.1 (.NET 2003).</li>\r
+/// <li>GNU G++ 2.95 and G++ 3.3.</li>\r
+/// </ul>\r
+/// Other platforms should be easily supported as PortAudioCpp is platform-independent and (reasonably) C++ standard compliant.\r
+/// </p>\r
+/// <p>\r
+/// This documentation mainly provides information specific to PortAudioCpp. For a more complete explaination of all of the \r
+/// concepts used, please consult the PortAudio documentation.\r
+/// </p>\r
+/// <p>\r
+/// PortAudioCpp was developed by Merlijn Blaauw with many great suggestions and help from Ross Bencina. Ludwig Schwardt provided \r
+/// GNU/Linux build files and checked G++ compatibility. PortAudioCpp may be used under the same licensing, conditions and \r
+/// warranty as PortAudio. See <a href="http://www.portaudio.com/license.html">the PortAudio license</a> for more details.\r
+/// </p>\r
+/// <h2>Links</h2>\r
+/// <p>\r
+/// <a href="http://www.portaudio.com/">Official PortAudio site.</a><br>\r
+/// </p>\r
+//////\r
+\r
+// ---------------------------------------------------------------------------------------\r
+\r
+//////\r
+/// @namespace portaudio\r
+///\r
+/// To avoid name collision, everything in PortAudioCpp is in the portaudio \r
+/// namespace. If this name is too long it's usually pretty safe to use an \r
+/// alias like ``namespace pa = portaudio;''.\r
+//////\r
+\r
+// ---------------------------------------------------------------------------------------\r
+\r
+//////\r
+/// @file PortAudioCpp.hxx\r
+/// An include-all header file (for lazy programmers and using pre-compiled headers).\r
+//////\r
+\r
+// ---------------------------------------------------------------------------------------\r
+\r
+#include "portaudio.h"\r
+\r
+#include "portaudiocpp/AutoSystem.hxx"\r
+#include "portaudiocpp/BlockingStream.hxx"\r
+#include "portaudiocpp/CallbackInterface.hxx"\r
+#include "portaudiocpp/CallbackStream.hxx"\r
+#include "portaudiocpp/CFunCallbackStream.hxx"\r
+#include "portaudiocpp/CppFunCallbackStream.hxx"\r
+#include "portaudiocpp/Device.hxx"\r
+#include "portaudiocpp/Exception.hxx"\r
+#include "portaudiocpp/HostApi.hxx"\r
+#include "portaudiocpp/InterfaceCallbackStream.hxx"\r
+#include "portaudiocpp/MemFunCallbackStream.hxx"\r
+#include "portaudiocpp/SampleDataFormat.hxx"\r
+#include "portaudiocpp/DirectionSpecificStreamParameters.hxx"\r
+#include "portaudiocpp/Stream.hxx"\r
+#include "portaudiocpp/StreamParameters.hxx"\r
+#include "portaudiocpp/System.hxx"\r
+#include "portaudiocpp/SystemDeviceIterator.hxx"\r
+#include "portaudiocpp/SystemHostApiIterator.hxx"\r
+\r
+// ---------------------------------------------------------------------------------------\r
+\r
+#endif // INCLUDED_PORTAUDIO_PORTAUDIOCPP_HXX\r
--- /dev/null
+#ifndef INCLUDED_PORTAUDIO_SAMPLEDATAFORMAT_HXX\r
+#define INCLUDED_PORTAUDIO_SAMPLEDATAFORMAT_HXX\r
+\r
+// ---------------------------------------------------------------------------------------\r
+\r
+#include "portaudio.h"\r
+\r
+// ---------------------------------------------------------------------------------------\r
+\r
+namespace portaudio\r
+{\r
+\r
+\r
+ //////\r
+ /// @brief PortAudio sample data formats.\r
+ ///\r
+ /// Small helper enum to wrap the PortAudio defines.\r
+ //////\r
+ enum SampleDataFormat\r
+ {\r
+ INVALID_FORMAT = 0,\r
+ FLOAT32 = paFloat32,\r
+ INT32 = paInt32,\r
+ INT24 = paInt24,\r
+ INT16 = paInt16,\r
+ INT8 = paInt8,\r
+ UINT8 = paUInt8\r
+ };\r
+\r
+\r
+} // namespace portaudio\r
+\r
+// ---------------------------------------------------------------------------------------\r
+\r
+#endif // INCLUDED_PORTAUDIO_SAMPLEDATAFORMAT_HXX\r
--- /dev/null
+#ifndef INCLUDED_PORTAUDIO_STREAM_HXX\r
+#define INCLUDED_PORTAUDIO_STREAM_HXX\r
+\r
+#include "portaudio.h"\r
+\r
+// ---------------------------------------------------------------------------------------\r
+\r
+// Forward declaration(s):\r
+namespace portaudio\r
+{\r
+ class StreamParameters;\r
+}\r
+\r
+// ---------------------------------------------------------------------------------------\r
+\r
+// Declaration(s):\r
+namespace portaudio\r
+{\r
+\r
+\r
+ //////\r
+ /// @brief A Stream represents an active or inactive input and/or output data \r
+ /// stream in the System.\r
+ /// \r
+ /// Concrete Stream classes should ensure themselves being in a closed state at \r
+ /// destruction (i.e. by calling their own close() method in their deconstructor). \r
+ /// Following good C++ programming practices, care must be taken to ensure no \r
+ /// exceptions are thrown by the deconstructor of these classes. As a consequence, \r
+ /// clients need to explicitly call close() to ensure the stream closed successfully.\r
+ ///\r
+ /// The Stream object can be used to manipulate the Stream's state. Also, time-constant \r
+ /// and time-varying information about the Stream can be retreived.\r
+ //////\r
+ class Stream\r
+ {\r
+ public:\r
+ // Opening/closing:\r
+ virtual ~Stream();\r
+\r
+ virtual void close();\r
+ bool isOpen() const;\r
+\r
+ // Additional set up:\r
+ void setStreamFinishedCallback(PaStreamFinishedCallback *callback);\r
+\r
+ // State management:\r
+ void start();\r
+ void stop();\r
+ void abort();\r
+\r
+ bool isStopped() const;\r
+ bool isActive() const;\r
+\r
+ // Stream info (time-constant, but might become time-variant soon):\r
+ PaTime inputLatency() const;\r
+ PaTime outputLatency() const;\r
+ double sampleRate() const;\r
+\r
+ // Stream info (time-varying):\r
+ PaTime time() const;\r
+\r
+ // Accessors for PortAudio PaStream, useful for interfacing \r
+ // with PortAudio add-ons (such as PortMixer) for instance:\r
+ const PaStream *paStream() const;\r
+ PaStream *paStream();\r
+\r
+ protected:\r
+ Stream(); // abstract class\r
+\r
+ PaStream *stream_;\r
+\r
+ private:\r
+ Stream(const Stream &); // non-copyable\r
+ Stream &operator=(const Stream &); // non-copyable\r
+ };\r
+\r
+\r
+} // namespace portaudio\r
+\r
+\r
+#endif // INCLUDED_PORTAUDIO_STREAM_HXX\r
+\r
--- /dev/null
+#ifndef INCLUDED_PORTAUDIO_STREAMPARAMETERS_HXX\r
+#define INCLUDED_PORTAUDIO_STREAMPARAMETERS_HXX\r
+\r
+// ---------------------------------------------------------------------------------------\r
+\r
+#include "portaudio.h"\r
+\r
+#include "portaudiocpp/DirectionSpecificStreamParameters.hxx"\r
+\r
+// ---------------------------------------------------------------------------------------\r
+\r
+// Declaration(s):\r
+namespace portaudio\r
+{\r
+\r
+ //////\r
+ /// @brief The entire set of parameters needed to configure and open \r
+ /// a Stream.\r
+ ///\r
+ /// It contains parameters of input, output and shared parameters. \r
+ /// Using the isSupported() method, the StreamParameters can be \r
+ /// checked if opening a Stream using this StreamParameters would \r
+ /// succeed or not. Accessors are provided to higher-level parameters \r
+ /// aswell as the lower-level parameters which are mainly intended for \r
+ /// internal use.\r
+ //////\r
+ class StreamParameters\r
+ {\r
+ public:\r
+ StreamParameters();\r
+ StreamParameters(const DirectionSpecificStreamParameters &inputParameters, \r
+ const DirectionSpecificStreamParameters &outputParameters, double sampleRate, \r
+ unsigned long framesPerBuffer, PaStreamFlags flags);\r
+\r
+ // Set up for direction-specific:\r
+ void setInputParameters(const DirectionSpecificStreamParameters ¶meters);\r
+ void setOutputParameters(const DirectionSpecificStreamParameters ¶meters);\r
+\r
+ // Set up for common parameters:\r
+ void setSampleRate(double sampleRate);\r
+ void setFramesPerBuffer(unsigned long framesPerBuffer);\r
+ void setFlag(PaStreamFlags flag);\r
+ void unsetFlag(PaStreamFlags flag);\r
+ void clearFlags();\r
+\r
+ // Validation:\r
+ bool isSupported() const;\r
+\r
+ // Accessors (direction-specific):\r
+ DirectionSpecificStreamParameters &inputParameters();\r
+ const DirectionSpecificStreamParameters &inputParameters() const;\r
+ DirectionSpecificStreamParameters &outputParameters();\r
+ const DirectionSpecificStreamParameters &outputParameters() const;\r
+\r
+ // Accessors (common):\r
+ double sampleRate() const;\r
+ unsigned long framesPerBuffer() const;\r
+ PaStreamFlags flags() const;\r
+ bool isFlagSet(PaStreamFlags flag) const;\r
+\r
+ private:\r
+ // Half-duplex specific parameters:\r
+ DirectionSpecificStreamParameters inputParameters_;\r
+ DirectionSpecificStreamParameters outputParameters_;\r
+\r
+ // Common parameters:\r
+ double sampleRate_;\r
+ unsigned long framesPerBuffer_;\r
+ PaStreamFlags flags_;\r
+ };\r
+\r
+\r
+} // namespace portaudio\r
+\r
+// ---------------------------------------------------------------------------------------\r
+\r
+#endif // INCLUDED_PORTAUDIO_STREAMPARAMETERS_HXX\r
--- /dev/null
+#ifndef INCLUDED_PORTAUDIO_SYSTEM_HXX\r
+#define INCLUDED_PORTAUDIO_SYSTEM_HXX\r
+\r
+// ---------------------------------------------------------------------------------------\r
+\r
+#include "portaudio.h"\r
+\r
+// ---------------------------------------------------------------------------------------\r
+\r
+// Forward declaration(s):\r
+namespace portaudio\r
+{\r
+ class Device;\r
+ class Stream;\r
+ class HostApi;\r
+}\r
+\r
+// ---------------------------------------------------------------------------------------\r
+\r
+// Declaration(s):\r
+namespace portaudio\r
+{\r
+\r
+\r
+ //////\r
+ /// @brief System singleton which represents the PortAudio system.\r
+ ///\r
+ /// The System is used to initialize/terminate PortAudio and provide \r
+ /// a single acccess point to the PortAudio System (instance()).\r
+ /// It can be used to iterate through all HostApi 's in the System as \r
+ /// well as all devices in the System. It also provides some utility \r
+ /// functionality of PortAudio.\r
+ ///\r
+ /// Terminating the System will also abort and close the open streams. \r
+ /// The Stream objects will need to be deallocated by the client though \r
+ /// (it's usually a good idea to have them cleaned up automatically).\r
+ //////\r
+ class System\r
+ {\r
+ public:\r
+ class HostApiIterator; // forward declaration\r
+ class DeviceIterator; // forward declaration\r
+\r
+ // -------------------------------------------------------------------------------\r
+\r
+ static int version();\r
+ static const char *versionText();\r
+\r
+ static void initialize();\r
+ static void terminate();\r
+\r
+ static System &instance();\r
+ static bool exists();\r
+\r
+ // -------------------------------------------------------------------------------\r
+\r
+ // host apis:\r
+ HostApiIterator hostApisBegin();\r
+ HostApiIterator hostApisEnd();\r
+\r
+ HostApi &defaultHostApi();\r
+\r
+ HostApi &hostApiByTypeId(PaHostApiTypeId type);\r
+ HostApi &hostApiByIndex(PaHostApiIndex index);\r
+\r
+ int hostApiCount();\r
+\r
+ // -------------------------------------------------------------------------------\r
+\r
+ // devices:\r
+ DeviceIterator devicesBegin();\r
+ DeviceIterator devicesEnd();\r
+\r
+ Device &defaultInputDevice();\r
+ Device &defaultOutputDevice();\r
+\r
+ Device &deviceByIndex(PaDeviceIndex index);\r
+\r
+ int deviceCount();\r
+\r
+ static Device &nullDevice();\r
+\r
+ // -------------------------------------------------------------------------------\r
+\r
+ // misc:\r
+ void sleep(long msec);\r
+ int sizeOfSample(PaSampleFormat format);\r
+\r
+ private:\r
+ System();\r
+ ~System();\r
+\r
+ static System *instance_;\r
+ static int initCount_;\r
+\r
+ static HostApi **hostApis_;\r
+ static Device **devices_;\r
+\r
+ static Device *nullDevice_;\r
+ };\r
+\r
+\r
+} // namespace portaudio\r
+\r
+\r
+#endif // INCLUDED_PORTAUDIO_SYSTEM_HXX\r
+\r
--- /dev/null
+#ifndef INCLUDED_PORTAUDIO_SYSTEMDEVICEITERATOR_HXX\r
+#define INCLUDED_PORTAUDIO_SYSTEMDEVICEITERATOR_HXX\r
+\r
+// ---------------------------------------------------------------------------------------\r
+\r
+#include <iterator>\r
+#include <cstddef>\r
+\r
+#include "portaudiocpp/System.hxx"\r
+\r
+// ---------------------------------------------------------------------------------------\r
+\r
+// Forward declaration(s):\r
+namespace portaudio\r
+{\r
+ class Device;\r
+ class HostApi;\r
+}\r
+\r
+// ---------------------------------------------------------------------------------------\r
+\r
+// Declaration(s):\r
+namespace portaudio\r
+{\r
+\r
+ \r
+ //////\r
+ /// @brief Iterator class for iterating through all Devices in a System.\r
+ ///\r
+ /// Devices will be iterated by iterating all Devices in each \r
+ /// HostApi in the System. Compliant with the STL bidirectional \r
+ /// iterator concept.\r
+ //////\r
+ class System::DeviceIterator\r
+ {\r
+ public:\r
+ typedef std::bidirectional_iterator_tag iterator_category;\r
+ typedef Device value_type;\r
+ typedef ptrdiff_t difference_type;\r
+ typedef Device * pointer;\r
+ typedef Device & reference;\r
+\r
+ Device &operator*() const;\r
+ Device *operator->() const;\r
+\r
+ DeviceIterator &operator++();\r
+ DeviceIterator operator++(int);\r
+ DeviceIterator &operator--();\r
+ DeviceIterator operator--(int);\r
+\r
+ bool operator==(const DeviceIterator &rhs);\r
+ bool operator!=(const DeviceIterator &rhs);\r
+\r
+ private:\r
+ friend class System;\r
+ friend class HostApi;\r
+ Device **ptr_;\r
+ };\r
+\r
+\r
+} // namespace portaudio\r
+\r
+// ---------------------------------------------------------------------------------------\r
+\r
+#endif // INCLUDED_PORTAUDIO_SYSTEMDEVICEITERATOR_HXX\r
+\r
--- /dev/null
+#ifndef INCLUDED_PORTAUDIO_SYSTEMHOSTAPIITERATOR_HXX\r
+#define INCLUDED_PORTAUDIO_SYSTEMHOSTAPIITERATOR_HXX\r
+\r
+// ---------------------------------------------------------------------------------------\r
+\r
+#include <iterator>\r
+#include <cstddef>\r
+\r
+#include "portaudiocpp/System.hxx"\r
+\r
+// ---------------------------------------------------------------------------------------\r
+\r
+// Forward declaration(s):\r
+namespace portaudio\r
+{\r
+ class HostApi;\r
+}\r
+\r
+// ---------------------------------------------------------------------------------------\r
+\r
+// Declaration(s):\r
+namespace portaudio\r
+{\r
+\r
+\r
+ //////\r
+ /// @brief Iterator class for iterating through all HostApis in a System.\r
+ ///\r
+ /// Compliant with the STL bidirectional iterator concept.\r
+ //////\r
+ class System::HostApiIterator\r
+ {\r
+ public:\r
+ typedef std::bidirectional_iterator_tag iterator_category;\r
+ typedef Device value_type;\r
+ typedef ptrdiff_t difference_type;\r
+ typedef HostApi * pointer;\r
+ typedef HostApi & reference;\r
+\r
+ HostApi &operator*() const;\r
+ HostApi *operator->() const;\r
+\r
+ HostApiIterator &operator++();\r
+ HostApiIterator operator++(int);\r
+ HostApiIterator &operator--();\r
+ HostApiIterator operator--(int);\r
+\r
+ bool operator==(const HostApiIterator &rhs);\r
+ bool operator!=(const HostApiIterator &rhs);\r
+\r
+ private:\r
+ friend class System;\r
+ HostApi **ptr_;\r
+ };\r
+\r
+\r
+} // namespace portaudio\r
+\r
+// ---------------------------------------------------------------------------------------\r
+\r
+#endif // INCLUDED_PORTAUDIO_SYSTEMHOSTAPIITERATOR_HXX\r