-
Notifications
You must be signed in to change notification settings - Fork 89
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Handle paNoDevice #150
Closed
Closed
Handle paNoDevice #150
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,17 @@ | ||
//! | ||
//! A module for implementing the Portaudio Error type and | ||
//! implementing the std Error trait. | ||
//! | ||
|
||
use ffi; | ||
|
||
/// Error codes returned by PortAudio functions. | ||
#[derive(Copy, Clone, PartialEq, PartialOrd, Debug)] | ||
#[repr(C)] | ||
pub enum Error { | ||
/// No Error | ||
NoError = 0, | ||
/// No device available | ||
NoDevice = ffi::PA_NO_DEVICE as isize, | ||
/// Portaudio not initialized | ||
NotInitialized = -10000, | ||
/// Unanticipated error from the host | ||
|
@@ -79,6 +82,7 @@ impl ::std::error::Error for Error { | |
fn description(&self) -> &str { | ||
match *self { | ||
Error::NoError => "No Error", | ||
Error::NoDevice => "No device available", | ||
Error::NotInitialized => "PortAudio not initialized", | ||
Error::UnanticipatedHostError => "Unanticipated error from the host", | ||
Error::InvalidChannelCount => "Invalid number of channels", | ||
|
@@ -95,64 +99,69 @@ impl ::std::error::Error for Error { | |
Error::TimedOut => "Time out", | ||
Error::InternalError => "Portaudio internal error", | ||
Error::DeviceUnavailable => "Device unavailable", | ||
Error::IncompatibleHostApiSpecificStreamInfo => "Stream info not compatible with the host", | ||
Error::IncompatibleHostApiSpecificStreamInfo => { | ||
"Stream info not compatible with the host" | ||
} | ||
Error::StreamIsStopped => "The stream is stopped", | ||
Error::StreamIsNotStopped => "The stream is not stopped", | ||
Error::InputOverflowed => "The input stream has overflowed", | ||
Error::OutputUnderflowed => "The output stream has underflowed", | ||
Error::HostApiNotFound => "The host api is not found by Portaudio", | ||
Error::InvalidHostApi => "The host API is invalid", | ||
Error::CanNotReadFromACallbackStream => "Portaudio cannot read from the callback stream", | ||
Error::CanNotReadFromACallbackStream => { | ||
"Portaudio cannot read from the callback stream" | ||
} | ||
Error::CanNotWriteToACallbackStream => "Portaudio cannot write to the callback stream", | ||
Error::CanNotReadFromAnOutputOnlyStream => "Portaudio cannot read from an output only stream", | ||
Error::CanNotWriteToAnInputOnlyStream => "Portaudio cannot write to an input only stream", | ||
Error::CanNotReadFromAnOutputOnlyStream => { | ||
"Portaudio cannot read from an output only stream" | ||
} | ||
Error::CanNotWriteToAnInputOnlyStream => { | ||
"Portaudio cannot write to an input only stream" | ||
} | ||
Error::IncompatibleStreamHostApi => "The stream is not compatible with the host API", | ||
Error::BadBufferPtr => "Invalid buffer", | ||
} | ||
} | ||
} | ||
|
||
impl ::num::FromPrimitive for Error { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Changed by rustfmt, revert? |
||
|
||
fn from_i64(n: i64) -> Option<Error> { | ||
match n { | ||
0 => Some(Error::NoError), | ||
0 => Some(Error::NoError), | ||
-10_000 => Some(Error::NotInitialized), | ||
-9_999 => Some(Error::UnanticipatedHostError), | ||
-9_998 => Some(Error::InvalidChannelCount), | ||
-9_997 => Some(Error::InvalidSampleRate), | ||
-9_996 => Some(Error::InvalidDevice), | ||
-9_995 => Some(Error::InvalidFlag), | ||
-9_994 => Some(Error::SampleFormatNotSupported), | ||
-9_993 => Some(Error::BadIODeviceCombination), | ||
-9_992 => Some(Error::InsufficientMemory), | ||
-9_991 => Some(Error::BufferTooBig), | ||
-9_990 => Some(Error::BufferTooSmall), | ||
-9_989 => Some(Error::NullCallback), | ||
-9_988 => Some(Error::BadStreamPtr), | ||
-9_987 => Some(Error::TimedOut), | ||
-9_986 => Some(Error::InternalError), | ||
-9_985 => Some(Error::DeviceUnavailable), | ||
-9_984 => Some(Error::IncompatibleHostApiSpecificStreamInfo), | ||
-9_983 => Some(Error::StreamIsStopped), | ||
-9_982 => Some(Error::StreamIsNotStopped), | ||
-9_981 => Some(Error::InputOverflowed), | ||
-9_980 => Some(Error::OutputUnderflowed), | ||
-9_979 => Some(Error::HostApiNotFound), | ||
-9_978 => Some(Error::InvalidHostApi), | ||
-9_977 => Some(Error::CanNotReadFromACallbackStream), | ||
-9_976 => Some(Error::CanNotWriteToACallbackStream), | ||
-9_975 => Some(Error::CanNotReadFromAnOutputOnlyStream), | ||
-9_974 => Some(Error::CanNotWriteToAnInputOnlyStream), | ||
-9_973 => Some(Error::IncompatibleStreamHostApi), | ||
-9_972 => Some(Error::BadBufferPtr), | ||
_ => None, | ||
-9_999 => Some(Error::UnanticipatedHostError), | ||
-9_998 => Some(Error::InvalidChannelCount), | ||
-9_997 => Some(Error::InvalidSampleRate), | ||
-9_996 => Some(Error::InvalidDevice), | ||
-9_995 => Some(Error::InvalidFlag), | ||
-9_994 => Some(Error::SampleFormatNotSupported), | ||
-9_993 => Some(Error::BadIODeviceCombination), | ||
-9_992 => Some(Error::InsufficientMemory), | ||
-9_991 => Some(Error::BufferTooBig), | ||
-9_990 => Some(Error::BufferTooSmall), | ||
-9_989 => Some(Error::NullCallback), | ||
-9_988 => Some(Error::BadStreamPtr), | ||
-9_987 => Some(Error::TimedOut), | ||
-9_986 => Some(Error::InternalError), | ||
-9_985 => Some(Error::DeviceUnavailable), | ||
-9_984 => Some(Error::IncompatibleHostApiSpecificStreamInfo), | ||
-9_983 => Some(Error::StreamIsStopped), | ||
-9_982 => Some(Error::StreamIsNotStopped), | ||
-9_981 => Some(Error::InputOverflowed), | ||
-9_980 => Some(Error::OutputUnderflowed), | ||
-9_979 => Some(Error::HostApiNotFound), | ||
-9_978 => Some(Error::InvalidHostApi), | ||
-9_977 => Some(Error::CanNotReadFromACallbackStream), | ||
-9_976 => Some(Error::CanNotWriteToACallbackStream), | ||
-9_975 => Some(Error::CanNotReadFromAnOutputOnlyStream), | ||
-9_974 => Some(Error::CanNotWriteToAnInputOnlyStream), | ||
-9_973 => Some(Error::IncompatibleStreamHostApi), | ||
-9_972 => Some(Error::BadBufferPtr), | ||
_ => None, | ||
} | ||
} | ||
|
||
fn from_u64(n: u64) -> Option<Error> { | ||
::num::FromPrimitive::from_i64(n as i64) | ||
} | ||
|
||
} | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed by rustfmt, revert?