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