weresocool_portaudio/
error.rs1use ffi;
7
8enum_from_primitive! {
9#[repr(i32)]
11#[derive(Copy, Clone, PartialEq, PartialOrd, Debug, Eq)]
12pub enum Error {
13 NoError =
15 ffi::PaErrorCode_paNoError,
16 NoDevice =
18 ffi::PA_NO_DEVICE,
19 NotInitialized =
21 ffi::PaErrorCode_paNotInitialized,
22 UnanticipatedHostError =
24 ffi::PaErrorCode_paUnanticipatedHostError,
25 InvalidChannelCount =
27 ffi::PaErrorCode_paInvalidChannelCount,
28 InvalidSampleRate =
30 ffi::PaErrorCode_paInvalidSampleRate,
31 InvalidDevice =
33 ffi::PaErrorCode_paInvalidDevice,
34 InvalidFlag =
36 ffi::PaErrorCode_paInvalidFlag,
37 SampleFormatNotSupported =
39 ffi::PaErrorCode_paSampleFormatNotSupported,
40 BadIODeviceCombination =
42 ffi::PaErrorCode_paBadIODeviceCombination,
43 InsufficientMemory =
45 ffi::PaErrorCode_paInsufficientMemory,
46 BufferTooBig =
48 ffi::PaErrorCode_paBufferTooBig,
49 BufferTooSmall =
51 ffi::PaErrorCode_paBufferTooSmall,
52 NullCallback =
54 ffi::PaErrorCode_paNullCallback,
55 BadStreamPtr =
57 ffi::PaErrorCode_paBadStreamPtr,
58 TimedOut =
60 ffi::PaErrorCode_paTimedOut,
61 InternalError =
63 ffi::PaErrorCode_paInternalError,
64 DeviceUnavailable =
66 ffi::PaErrorCode_paDeviceUnavailable,
67 IncompatibleHostApiSpecificStreamInfo =
69 ffi::PaErrorCode_paIncompatibleHostApiSpecificStreamInfo,
70 StreamIsStopped =
72 ffi::PaErrorCode_paStreamIsStopped,
73 StreamIsNotStopped =
75 ffi::PaErrorCode_paStreamIsNotStopped,
76 InputOverflowed =
78 ffi::PaErrorCode_paInputOverflowed,
79 OutputUnderflowed =
81 ffi::PaErrorCode_paOutputUnderflowed,
82 HostApiNotFound =
84 ffi::PaErrorCode_paHostApiNotFound,
85 InvalidHostApi =
87 ffi::PaErrorCode_paInvalidHostApi,
88 CanNotReadFromACallbackStream =
90 ffi::PaErrorCode_paCanNotReadFromACallbackStream,
91 CanNotWriteToACallbackStream =
93 ffi::PaErrorCode_paCanNotWriteToACallbackStream,
94 CanNotReadFromAnOutputOnlyStream =
96 ffi::PaErrorCode_paCanNotReadFromAnOutputOnlyStream,
97 CanNotWriteToAnInputOnlyStream =
99 ffi::PaErrorCode_paCanNotWriteToAnInputOnlyStream,
100 IncompatibleStreamHostApi =
102 ffi::PaErrorCode_paIncompatibleStreamHostApi,
103 BadBufferPtr =
105 ffi::PaErrorCode_paBadBufferPtr,
106}
107}
108
109impl ::std::fmt::Display for Error {
110 fn fmt(&self, f: &mut ::std::fmt::Formatter) -> Result<(), ::std::fmt::Error> {
111 write!(f, "{:?}", self)
112 }
113}
114
115impl ::std::error::Error for Error {
116 fn description(&self) -> &str {
117 match *self {
118 Error::NoError => "No Error",
119 Error::NoDevice => "No Device",
120 Error::NotInitialized => "PortAudio not initialized",
121 Error::UnanticipatedHostError => "Unanticipated error from the host",
122 Error::InvalidChannelCount => "Invalid number of channels",
123 Error::InvalidSampleRate => "Invalid sample rate",
124 Error::InvalidDevice => "Invalid device",
125 Error::InvalidFlag => "Invalid flag",
126 Error::SampleFormatNotSupported => "Sample format is not supported",
127 Error::BadIODeviceCombination => "Input device not compatible with output device",
128 Error::InsufficientMemory => "Memory insufficient",
129 Error::BufferTooBig => "The buffer is too big",
130 Error::BufferTooSmall => "The buffer is too small",
131 Error::NullCallback => "Invalid callback",
132 Error::BadStreamPtr => "Invalid stream",
133 Error::TimedOut => "Time out",
134 Error::InternalError => "Portaudio internal error",
135 Error::DeviceUnavailable => "Device unavailable",
136 Error::IncompatibleHostApiSpecificStreamInfo => {
137 "Stream info not compatible with the host"
138 }
139 Error::StreamIsStopped => "The stream is stopped",
140 Error::StreamIsNotStopped => "The stream is not stopped",
141 Error::InputOverflowed => "The input stream has overflowed",
142 Error::OutputUnderflowed => "The output stream has underflowed",
143 Error::HostApiNotFound => "The host api is not found by Portaudio",
144 Error::InvalidHostApi => "The host API is invalid",
145 Error::CanNotReadFromACallbackStream => {
146 "Portaudio cannot read from the callback stream"
147 }
148 Error::CanNotWriteToACallbackStream => "Portaudio cannot write to the callback stream",
149 Error::CanNotReadFromAnOutputOnlyStream => {
150 "Portaudio cannot read from an output only stream"
151 }
152 Error::CanNotWriteToAnInputOnlyStream => {
153 "Portaudio cannot write to an input only stream"
154 }
155 Error::IncompatibleStreamHostApi => "The stream is not compatible with the host API",
156 Error::BadBufferPtr => "Invalid buffer",
157 }
158 }
159}