Rename FormatsEnumerationError to SupportedFormatsError
This more tightly associates the error with the device method on which this might occur.
This commit is contained in:
parent
1275db805b
commit
0f27c1e0bb
7 changed files with 39 additions and 39 deletions
|
|
@ -7,7 +7,7 @@ use ChannelCount;
|
|||
use CreationError;
|
||||
use DefaultFormatError;
|
||||
use Format;
|
||||
use FormatsEnumerationError;
|
||||
use SupportedFormatsError;
|
||||
use SampleFormat;
|
||||
use SampleRate;
|
||||
use StreamData;
|
||||
|
|
@ -80,7 +80,7 @@ impl Device {
|
|||
unsafe fn supported_formats(
|
||||
&self,
|
||||
stream_t: alsa::snd_pcm_stream_t,
|
||||
) -> Result<VecIntoIter<SupportedFormat>, FormatsEnumerationError>
|
||||
) -> Result<VecIntoIter<SupportedFormat>, SupportedFormatsError>
|
||||
{
|
||||
let mut handle = mem::uninitialized();
|
||||
let device_name = ffi::CString::new(&self.0[..]).expect("Unable to get device name");
|
||||
|
|
@ -92,10 +92,10 @@ impl Device {
|
|||
alsa::SND_PCM_NONBLOCK,
|
||||
) {
|
||||
-2 |
|
||||
-16 /* determined empirically */ => return Err(FormatsEnumerationError::DeviceNotAvailable),
|
||||
-22 => return Err(FormatsEnumerationError::InvalidArgument),
|
||||
-16 /* determined empirically */ => return Err(SupportedFormatsError::DeviceNotAvailable),
|
||||
-22 => return Err(SupportedFormatsError::InvalidArgument),
|
||||
e => if check_errors(e).is_err() {
|
||||
return Err(FormatsEnumerationError::Unknown)
|
||||
return Err(SupportedFormatsError::Unknown)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -251,13 +251,13 @@ impl Device {
|
|||
Ok(output.into_iter())
|
||||
}
|
||||
|
||||
pub fn supported_input_formats(&self) -> Result<SupportedInputFormats, FormatsEnumerationError> {
|
||||
pub fn supported_input_formats(&self) -> Result<SupportedInputFormats, SupportedFormatsError> {
|
||||
unsafe {
|
||||
self.supported_formats(alsa::SND_PCM_STREAM_CAPTURE)
|
||||
}
|
||||
}
|
||||
|
||||
pub fn supported_output_formats(&self) -> Result<SupportedOutputFormats, FormatsEnumerationError> {
|
||||
pub fn supported_output_formats(&self) -> Result<SupportedOutputFormats, SupportedFormatsError> {
|
||||
unsafe {
|
||||
self.supported_formats(alsa::SND_PCM_STREAM_PLAYBACK)
|
||||
}
|
||||
|
|
@ -272,15 +272,15 @@ impl Device {
|
|||
{
|
||||
let mut formats: Vec<_> = unsafe {
|
||||
match self.supported_formats(stream_t) {
|
||||
Err(FormatsEnumerationError::DeviceNotAvailable) => {
|
||||
Err(SupportedFormatsError::DeviceNotAvailable) => {
|
||||
return Err(DefaultFormatError::DeviceNotAvailable);
|
||||
},
|
||||
Err(FormatsEnumerationError::InvalidArgument) => {
|
||||
Err(SupportedFormatsError::InvalidArgument) => {
|
||||
// this happens sometimes when querying for input and output capabilities but
|
||||
// the device supports only one
|
||||
return Err(DefaultFormatError::StreamTypeNotSupported);
|
||||
}
|
||||
Err(FormatsEnumerationError::Unknown) => {
|
||||
Err(SupportedFormatsError::Unknown) => {
|
||||
return Err(DefaultFormatError::DeviceNotAvailable);
|
||||
}
|
||||
Ok(fmts) => fmts.collect(),
|
||||
|
|
@ -940,4 +940,4 @@ unsafe fn cast_input_buffer<T>(v: &[u8]) -> &[T] {
|
|||
unsafe fn cast_output_buffer<T>(v: &mut [u8]) -> &mut [T] {
|
||||
debug_assert!(v.len() % std::mem::size_of::<T>() == 0);
|
||||
std::slice::from_raw_parts_mut(v.as_mut_ptr() as *mut T, v.len() / std::mem::size_of::<T>())
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue