Merge branch 'mr-1701-backport-into-0.22-audio-pack-unpack-test-alignment' into '0.22'

Backport of "audio: Use correctly aligned arrays for audio pack/unpack test" into 0.22

See merge request gstreamer/gstreamer-rs!1703
This commit is contained in:
Backport Bot 2025-04-06 23:23:45 +00:00
commit 5054c7af07
3 changed files with 17 additions and 5 deletions

1
Cargo.lock generated
View file

@ -937,6 +937,7 @@ dependencies = [
name = "gstreamer-audio"
version = "0.22.8"
dependencies = [
"byte-slice-cast",
"cfg-if",
"gir-format-check",
"glib",

View file

@ -28,6 +28,7 @@ once_cell = "1"
itertools = "0.13"
serde_json = "1.0"
gir-format-check = "0.1"
byte-slice-cast = "1.0"
[features]
default = []

View file

@ -449,6 +449,8 @@ mod tests {
#[test]
fn pack_unpack() {
use byte_slice_cast::*;
gst::init().unwrap();
let info = AudioFormatInfo::from_format(crate::AudioFormat::S16le);
@ -456,12 +458,20 @@ mod tests {
assert!(unpack_info.width() > 0);
let input = [0, 0, 255, 255, 128, 128, 64, 64];
let mut unpacked = [0; 16];
let mut output = [0; 8];
let input = [0i16, i16::MAX, i16::MIN, 0i16];
let mut unpacked = [0i32; 4];
let mut output = [0i16; 4];
info.unpack(crate::AudioPackFlags::empty(), &mut unpacked, &input);
info.pack(crate::AudioPackFlags::empty(), &mut output, &unpacked);
info.unpack(
crate::AudioPackFlags::empty(),
unpacked.as_mut_byte_slice(),
input.as_byte_slice(),
);
info.pack(
crate::AudioPackFlags::empty(),
output.as_mut_byte_slice(),
unpacked.as_byte_slice(),
);
assert_eq!(input, output);
}