mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer-rs.git
synced 2024-12-23 08:36:31 +00:00
audio: Use new 1.63 std::array::from_fn
instead of the external array-init
crate
This commit is contained in:
parent
099ffdc4b4
commit
879d6a4548
3 changed files with 13 additions and 14 deletions
|
@ -21,7 +21,6 @@ ffi = { package = "gstreamer-audio-sys", path = "sys" }
|
|||
glib = { git = "https://github.com/gtk-rs/gtk-rs-core" }
|
||||
gst = { package = "gstreamer", path = "../gstreamer" }
|
||||
gst-base = { package = "gstreamer-base", path = "../gstreamer-base" }
|
||||
array-init = "2.0"
|
||||
once_cell = "1.0"
|
||||
serde = { version = "1.0", optional = true }
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@ impl AudioChannelPosition {
|
|||
return Err(glib::bool_error!("Invalid number of channels"));
|
||||
}
|
||||
|
||||
let positions_raw: [ffi::GstAudioChannelPosition; 64] = array_init::array_init(|i| {
|
||||
let positions_raw: [ffi::GstAudioChannelPosition; 64] = std::array::from_fn(|i| {
|
||||
if i >= len as usize {
|
||||
ffi::GST_AUDIO_CHANNEL_POSITION_INVALID
|
||||
} else {
|
||||
|
@ -94,7 +94,7 @@ impl AudioChannelPosition {
|
|||
}
|
||||
|
||||
let len = positions.len();
|
||||
let mut positions_raw: [ffi::GstAudioChannelPosition; 64] = array_init::array_init(|i| {
|
||||
let mut positions_raw: [ffi::GstAudioChannelPosition; 64] = std::array::from_fn(|i| {
|
||||
if i >= len as usize {
|
||||
ffi::GST_AUDIO_CHANNEL_POSITION_INVALID
|
||||
} else {
|
||||
|
@ -138,7 +138,7 @@ impl AudioChannelPosition {
|
|||
}
|
||||
|
||||
let len = positions.len();
|
||||
let positions_raw: [ffi::GstAudioChannelPosition; 64] = array_init::array_init(|i| {
|
||||
let positions_raw: [ffi::GstAudioChannelPosition; 64] = std::array::from_fn(|i| {
|
||||
if i >= len as usize {
|
||||
ffi::GST_AUDIO_CHANNEL_POSITION_INVALID
|
||||
} else {
|
||||
|
@ -173,7 +173,7 @@ pub fn buffer_reorder_channels(
|
|||
let from_len = from.len();
|
||||
let to_len = to.len();
|
||||
|
||||
let from_raw: [ffi::GstAudioChannelPosition; 64] = array_init::array_init(|i| {
|
||||
let from_raw: [ffi::GstAudioChannelPosition; 64] = std::array::from_fn(|i| {
|
||||
if i >= from_len as usize {
|
||||
ffi::GST_AUDIO_CHANNEL_POSITION_INVALID
|
||||
} else {
|
||||
|
@ -181,7 +181,7 @@ pub fn buffer_reorder_channels(
|
|||
}
|
||||
});
|
||||
|
||||
let to_raw: [ffi::GstAudioChannelPosition; 64] = array_init::array_init(|i| {
|
||||
let to_raw: [ffi::GstAudioChannelPosition; 64] = std::array::from_fn(|i| {
|
||||
if i >= to_len as usize {
|
||||
ffi::GST_AUDIO_CHANNEL_POSITION_INVALID
|
||||
} else {
|
||||
|
@ -223,7 +223,7 @@ pub fn reorder_channels(
|
|||
let from_len = from.len();
|
||||
let to_len = to.len();
|
||||
|
||||
let from_raw: [ffi::GstAudioChannelPosition; 64] = array_init::array_init(|i| {
|
||||
let from_raw: [ffi::GstAudioChannelPosition; 64] = std::array::from_fn(|i| {
|
||||
if i >= from_len as usize {
|
||||
ffi::GST_AUDIO_CHANNEL_POSITION_INVALID
|
||||
} else {
|
||||
|
@ -231,7 +231,7 @@ pub fn reorder_channels(
|
|||
}
|
||||
});
|
||||
|
||||
let to_raw: [ffi::GstAudioChannelPosition; 64] = array_init::array_init(|i| {
|
||||
let to_raw: [ffi::GstAudioChannelPosition; 64] = std::array::from_fn(|i| {
|
||||
if i >= to_len as usize {
|
||||
ffi::GST_AUDIO_CHANNEL_POSITION_INVALID
|
||||
} else {
|
||||
|
@ -273,7 +273,7 @@ pub fn channel_reorder_map(
|
|||
let from_len = from.len();
|
||||
let to_len = to.len();
|
||||
|
||||
let from_raw: [ffi::GstAudioChannelPosition; 64] = array_init::array_init(|i| {
|
||||
let from_raw: [ffi::GstAudioChannelPosition; 64] = std::array::from_fn(|i| {
|
||||
if i >= from_len as usize {
|
||||
ffi::GST_AUDIO_CHANNEL_POSITION_INVALID
|
||||
} else {
|
||||
|
@ -281,7 +281,7 @@ pub fn channel_reorder_map(
|
|||
}
|
||||
});
|
||||
|
||||
let to_raw: [ffi::GstAudioChannelPosition; 64] = array_init::array_init(|i| {
|
||||
let to_raw: [ffi::GstAudioChannelPosition; 64] = std::array::from_fn(|i| {
|
||||
if i >= to_len as usize {
|
||||
ffi::GST_AUDIO_CHANNEL_POSITION_INVALID
|
||||
} else {
|
||||
|
|
|
@ -47,7 +47,7 @@ impl<'a> AudioInfoBuilder<'a> {
|
|||
return Err(glib::bool_error!("Invalid positions length"));
|
||||
}
|
||||
|
||||
let positions: [ffi::GstAudioChannelPosition; 64] = array_init::array_init(|i| {
|
||||
let positions: [ffi::GstAudioChannelPosition; 64] = std::array::from_fn(|i| {
|
||||
if i >= self.channels as usize {
|
||||
ffi::GST_AUDIO_CHANNEL_POSITION_INVALID
|
||||
} else {
|
||||
|
@ -96,7 +96,7 @@ impl<'a> AudioInfoBuilder<'a> {
|
|||
info.layout = layout.into_glib();
|
||||
}
|
||||
|
||||
let positions = array_init::array_init(|i| from_glib(info.position[i]));
|
||||
let positions = std::array::from_fn(|i| from_glib(info.position[i]));
|
||||
Ok(AudioInfo(info, positions))
|
||||
}
|
||||
}
|
||||
|
@ -156,7 +156,7 @@ impl AudioInfo {
|
|||
caps.as_ptr(),
|
||||
)) {
|
||||
let info = info.assume_init();
|
||||
let positions = array_init::array_init(|i| from_glib(info.position[i]));
|
||||
let positions = std::array::from_fn(|i| from_glib(info.position[i]));
|
||||
Ok(Self(info, positions))
|
||||
} else {
|
||||
Err(glib::bool_error!("Failed to create AudioInfo from caps"))
|
||||
|
@ -407,7 +407,7 @@ impl glib::translate::FromGlibPtrNone<*mut ffi::GstAudioInfo> for AudioInfo {
|
|||
unsafe fn from_glib_none(ptr: *mut ffi::GstAudioInfo) -> Self {
|
||||
Self(
|
||||
ptr::read(ptr),
|
||||
array_init::array_init(|i| from_glib((*ptr).position[i])),
|
||||
std::array::from_fn(|i| from_glib((*ptr).position[i])),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue