forked from mirrors/gstreamer-rs
gstreamer-audio/audio_channel_position: Change function from returning Option to Result
Partial work for: https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/issues/216
This commit is contained in:
parent
e4adef3ba7
commit
1f7bd78bb2
1 changed files with 9 additions and 4 deletions
|
@ -30,12 +30,15 @@ impl AudioChannelPosition {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn positions_to_mask(positions: &[AudioChannelPosition], force_order: bool) -> Option<u64> {
|
pub fn positions_to_mask(
|
||||||
|
positions: &[AudioChannelPosition],
|
||||||
|
force_order: bool,
|
||||||
|
) -> Result<u64, glib::error::BoolError> {
|
||||||
assert_initialized_main_thread!();
|
assert_initialized_main_thread!();
|
||||||
|
|
||||||
let len = positions.len();
|
let len = positions.len();
|
||||||
if len > 64 {
|
if len > 64 {
|
||||||
return None;
|
return Err(glib_bool_error!("Invalid number of channels"));
|
||||||
}
|
}
|
||||||
|
|
||||||
let positions_raw: [gst_audio_sys::GstAudioChannelPosition; 64] =
|
let positions_raw: [gst_audio_sys::GstAudioChannelPosition; 64] =
|
||||||
|
@ -56,9 +59,11 @@ impl AudioChannelPosition {
|
||||||
mask.as_mut_ptr(),
|
mask.as_mut_ptr(),
|
||||||
));
|
));
|
||||||
if valid {
|
if valid {
|
||||||
Some(mask.assume_init())
|
Ok(mask.assume_init())
|
||||||
} else {
|
} else {
|
||||||
None
|
Err(glib_bool_error!(
|
||||||
|
"Couldn't convert channel positions to mask"
|
||||||
|
))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue