| 1 | #ifndef INCLUDED_PORTAUDIO_SYSTEM_HXX |
| 2 | #define INCLUDED_PORTAUDIO_SYSTEM_HXX |
| 3 | |
| 4 | // --------------------------------------------------------------------------------------- |
| 5 | |
| 6 | #include "portaudio.h" |
| 7 | |
| 8 | // --------------------------------------------------------------------------------------- |
| 9 | |
| 10 | // Forward declaration(s): |
| 11 | namespace portaudio |
| 12 | { |
| 13 | class Device; |
| 14 | class Stream; |
| 15 | class HostApi; |
| 16 | } |
| 17 | |
| 18 | // --------------------------------------------------------------------------------------- |
| 19 | |
| 20 | // Declaration(s): |
| 21 | namespace portaudio |
| 22 | { |
| 23 | |
| 24 | |
| 25 | ////// |
| 26 | /// @brief System singleton which represents the PortAudio system. |
| 27 | /// |
| 28 | /// The System is used to initialize/terminate PortAudio and provide |
| 29 | /// a single acccess point to the PortAudio System (instance()). |
| 30 | /// It can be used to iterate through all HostApi 's in the System as |
| 31 | /// well as all devices in the System. It also provides some utility |
| 32 | /// functionality of PortAudio. |
| 33 | /// |
| 34 | /// Terminating the System will also abort and close the open streams. |
| 35 | /// The Stream objects will need to be deallocated by the client though |
| 36 | /// (it's usually a good idea to have them cleaned up automatically). |
| 37 | ////// |
| 38 | class System |
| 39 | { |
| 40 | public: |
| 41 | class HostApiIterator; // forward declaration |
| 42 | class DeviceIterator; // forward declaration |
| 43 | |
| 44 | // ------------------------------------------------------------------------------- |
| 45 | |
| 46 | static int version(); |
| 47 | static const char *versionText(); |
| 48 | |
| 49 | static void initialize(); |
| 50 | static void terminate(); |
| 51 | |
| 52 | static System &instance(); |
| 53 | static bool exists(); |
| 54 | |
| 55 | // ------------------------------------------------------------------------------- |
| 56 | |
| 57 | // host apis: |
| 58 | HostApiIterator hostApisBegin(); |
| 59 | HostApiIterator hostApisEnd(); |
| 60 | |
| 61 | HostApi &defaultHostApi(); |
| 62 | |
| 63 | HostApi &hostApiByTypeId(PaHostApiTypeId type); |
| 64 | HostApi &hostApiByIndex(PaHostApiIndex index); |
| 65 | |
| 66 | int hostApiCount(); |
| 67 | |
| 68 | // ------------------------------------------------------------------------------- |
| 69 | |
| 70 | // devices: |
| 71 | DeviceIterator devicesBegin(); |
| 72 | DeviceIterator devicesEnd(); |
| 73 | |
| 74 | Device &defaultInputDevice(); |
| 75 | Device &defaultOutputDevice(); |
| 76 | |
| 77 | Device &deviceByIndex(PaDeviceIndex index); |
| 78 | |
| 79 | int deviceCount(); |
| 80 | |
| 81 | static Device &nullDevice(); |
| 82 | |
| 83 | // ------------------------------------------------------------------------------- |
| 84 | |
| 85 | // misc: |
| 86 | void sleep(long msec); |
| 87 | int sizeOfSample(PaSampleFormat format); |
| 88 | |
| 89 | private: |
| 90 | System(); |
| 91 | ~System(); |
| 92 | |
| 93 | static System *instance_; |
| 94 | static int initCount_; |
| 95 | |
| 96 | static HostApi **hostApis_; |
| 97 | static Device **devices_; |
| 98 | |
| 99 | static Device *nullDevice_; |
| 100 | }; |
| 101 | |
| 102 | |
| 103 | } // namespace portaudio |
| 104 | |
| 105 | |
| 106 | #endif // INCLUDED_PORTAUDIO_SYSTEM_HXX |
| 107 |