mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer-rs.git
synced 2025-09-03 02:13:49 +00:00
audio: Use correctly aligned arrays for audio pack/unpack test
Fixes https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/issues/550 Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/merge_requests/1701>
This commit is contained in:
parent
f65d6f9c07
commit
521f0fe168
3 changed files with 17 additions and 5 deletions
1
Cargo.lock
generated
1
Cargo.lock
generated
|
@ -985,6 +985,7 @@ dependencies = [
|
||||||
name = "gstreamer-audio"
|
name = "gstreamer-audio"
|
||||||
version = "0.24.0"
|
version = "0.24.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
|
"byte-slice-cast",
|
||||||
"cfg-if",
|
"cfg-if",
|
||||||
"gir-format-check",
|
"gir-format-check",
|
||||||
"glib",
|
"glib",
|
||||||
|
|
|
@ -27,6 +27,7 @@ smallvec = "1.0"
|
||||||
itertools = "0.14"
|
itertools = "0.14"
|
||||||
serde_json = "1.0"
|
serde_json = "1.0"
|
||||||
gir-format-check = "0.1"
|
gir-format-check = "0.1"
|
||||||
|
byte-slice-cast = "1.0"
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
default = []
|
default = []
|
||||||
|
|
|
@ -450,6 +450,8 @@ mod tests {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn pack_unpack() {
|
fn pack_unpack() {
|
||||||
|
use byte_slice_cast::*;
|
||||||
|
|
||||||
gst::init().unwrap();
|
gst::init().unwrap();
|
||||||
|
|
||||||
let info = AudioFormatInfo::from_format(crate::AudioFormat::S16le);
|
let info = AudioFormatInfo::from_format(crate::AudioFormat::S16le);
|
||||||
|
@ -457,12 +459,20 @@ mod tests {
|
||||||
|
|
||||||
assert!(unpack_info.width() > 0);
|
assert!(unpack_info.width() > 0);
|
||||||
|
|
||||||
let input = [0, 0, 255, 255, 128, 128, 64, 64];
|
let input = [0i16, i16::MAX, i16::MIN, 0i16];
|
||||||
let mut unpacked = [0; 16];
|
let mut unpacked = [0i32; 4];
|
||||||
let mut output = [0; 8];
|
let mut output = [0i16; 4];
|
||||||
|
|
||||||
info.unpack(crate::AudioPackFlags::empty(), &mut unpacked, &input);
|
info.unpack(
|
||||||
info.pack(crate::AudioPackFlags::empty(), &mut output, &unpacked);
|
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);
|
assert_eq!(input, output);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue