summaryrefslogtreecommitdiffstatshomepage
path: root/3rdparty/portaudio/bindings/cpp/include/portaudiocpp/System.hxx
blob: bdd966ebfa249309fb0890541869387918b1e414 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
#ifndef INCLUDED_PORTAUDIO_SYSTEM_HXX
#define INCLUDED_PORTAUDIO_SYSTEM_HXX

// ---------------------------------------------------------------------------------------

#include "portaudio.h"

// ---------------------------------------------------------------------------------------

// Forward declaration(s):
namespace portaudio
{
    class Device;
    class Stream;
    class HostApi;
}

// ---------------------------------------------------------------------------------------

// Declaration(s):
namespace portaudio
{


    //////
    /// @brief System singleton which represents the PortAudio system.
    ///
    /// The System is used to initialize/terminate PortAudio and provide
    /// a single access point to the PortAudio System (instance()).
    /// It can be used to iterate through all HostApi 's in the System as
    /// well as all devices in the System. It also provides some utility
    /// functionality of PortAudio.
    ///
    /// Terminating the System will also abort and close the open streams.
    /// The Stream objects will need to be deallocated by the client though
    /// (it's usually a good idea to have them cleaned up automatically).
    //////
    class System
    {
    public:
        class HostApiIterator; // forward declaration
        class DeviceIterator; // forward declaration

        // -------------------------------------------------------------------------------

        static int version();
        static const char *versionText();

        static void initialize();
        static void terminate();

        static System &instance();
        static bool exists();

        // -------------------------------------------------------------------------------

        // host apis:
        HostApiIterator hostApisBegin();
        HostApiIterator hostApisEnd();

        HostApi &defaultHostApi();

        HostApi &hostApiByTypeId(PaHostApiTypeId type);
        HostApi &hostApiByIndex(PaHostApiIndex index);

        int hostApiCount();

        // -------------------------------------------------------------------------------

        // devices:
        DeviceIterator devicesBegin();
        DeviceIterator devicesEnd();

        Device &defaultInputDevice();
        Device &defaultOutputDevice();

        Device &deviceByIndex(PaDeviceIndex index);

        int deviceCount();

        static Device &nullDevice();

        // -------------------------------------------------------------------------------

        // misc:
        void sleep(long msec);
        int sizeOfSample(PaSampleFormat format);

    private:
        System();
        ~System();

        static System *instance_;
        static int initCount_;

        static HostApi **hostApis_;
        static Device **devices_;

        static Device *nullDevice_;
    };


} // namespace portaudio


#endif // INCLUDED_PORTAUDIO_SYSTEM_HXX