To check out this repository please hg clone the following URL, or open the URL using EasyMercurial or your preferred Mercurial client.

The primary repository for this project is hosted at https://github.com/sonic-visualiser/sv-dependency-builds .
This repository is a read-only copy which is updated automatically every hour.

Statistics Download as Zip
| Branch: | Tag: | Revision:

root / src / portaudio_20161030_catalina_patch / bindings / cpp / source / portaudiocpp / Exception.cxx @ 162:d43aab368df9

History | View | Annotate | Download (2.9 KB)

1
#include "portaudiocpp/Exception.hxx"
2

    
3
namespace portaudio
4
{
5
        // -----------------------------------------------------------------------------------
6
        // PaException:
7
        // -----------------------------------------------------------------------------------
8

    
9
        //////
10
        ///  Wraps a PortAudio error into a PortAudioCpp PaException.
11
        //////
12
        PaException::PaException(PaError error) : error_(error)
13
        {
14
        }
15

    
16
        // -----------------------------------------------------------------------------------
17

    
18
        //////
19
        /// Alias for paErrorText(), to have std::exception compliance.
20
        //////
21
        const char *PaException::what() const throw()
22
        {
23
                return paErrorText();
24
        }
25

    
26
        // -----------------------------------------------------------------------------------
27

    
28
        //////
29
        /// Returns the PortAudio error code (PaError).
30
        //////
31
        PaError PaException::paError() const
32
        {
33
                return error_;
34
        }
35

    
36
        //////
37
        /// Returns the error as a (zero-terminated) text string.
38
        //////
39
        const char *PaException::paErrorText() const
40
        {
41
                return Pa_GetErrorText(error_);
42
        }
43

    
44
        //////
45
        /// Returns true is the error is a HostApi error.
46
        //////
47
        bool PaException::isHostApiError() const
48
        {
49
                return (error_ == paUnanticipatedHostError);
50
        }
51

    
52
        //////
53
        /// Returns the last HostApi error (which is the current one if 
54
        /// isHostApiError() returns true) as an error code.
55
        //////
56
        long PaException::lastHostApiError() const
57
        {
58
                return Pa_GetLastHostErrorInfo()->errorCode;
59
        }
60

    
61
        //////
62
        /// Returns the last HostApi error (which is the current one if 
63
        /// isHostApiError() returns true) as a (zero-terminated) text 
64
        /// string, if it's available.
65
        //////
66
        const char *PaException::lastHostApiErrorText() const
67
        {
68
                return Pa_GetLastHostErrorInfo()->errorText;
69
        }
70

    
71
        // -----------------------------------------------------------------------------------
72

    
73
        bool PaException::operator==(const PaException &rhs) const
74
        {
75
                return (error_ == rhs.error_);
76
        }
77

    
78
        bool PaException::operator!=(const PaException &rhs) const
79
        {
80
                return !(*this == rhs);
81
        }
82

    
83
        // -----------------------------------------------------------------------------------
84
        // PaCppException:
85
        // -----------------------------------------------------------------------------------
86
        
87
        PaCppException::PaCppException(ExceptionSpecifier specifier) : specifier_(specifier)
88
        {
89
        }
90

    
91
        const char *PaCppException::what() const throw()
92
        {
93
                switch (specifier_)
94
                {
95
                        case UNABLE_TO_ADAPT_DEVICE:
96
                        {
97
                                return "Unable to adapt the given device to the specified host api specific device extension";
98
                        }
99
                }
100

    
101
                return "Unknown exception";
102
        }
103

    
104
        PaCppException::ExceptionSpecifier PaCppException::specifier() const
105
        {
106
                return specifier_;
107
        }
108

    
109
        bool PaCppException::operator==(const PaCppException &rhs) const
110
        {
111
                return (specifier_ == rhs.specifier_);
112
        }
113

    
114
        bool PaCppException::operator!=(const PaCppException &rhs) const
115
        {
116
                return !(*this == rhs);
117
        }
118

    
119
        // -----------------------------------------------------------------------------------
120

    
121
} // namespace portaudio
122

    
123