mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer-rs.git
synced 2024-12-23 00:26:31 +00:00
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!();
|
||||
|
||||
let len = positions.len();
|
||||
if len > 64 {
|
||||
return None;
|
||||
return Err(glib_bool_error!("Invalid number of channels"));
|
||||
}
|
||||
|
||||
let positions_raw: [gst_audio_sys::GstAudioChannelPosition; 64] =
|
||||
|
@ -56,9 +59,11 @@ impl AudioChannelPosition {
|
|||
mask.as_mut_ptr(),
|
||||
));
|
||||
if valid {
|
||||
Some(mask.assume_init())
|
||||
Ok(mask.assume_init())
|
||||
} else {
|
||||
None
|
||||
Err(glib_bool_error!(
|
||||
"Couldn't convert channel positions to mask"
|
||||
))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue