mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer-rs.git
synced 2025-04-15 04:14:07 +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"
|
||||
version = "0.24.0"
|
||||
dependencies = [
|
||||
"byte-slice-cast",
|
||||
"cfg-if",
|
||||
"gir-format-check",
|
||||
"glib",
|
||||
|
|
|
@ -27,6 +27,7 @@ smallvec = "1.0"
|
|||
itertools = "0.14"
|
||||
serde_json = "1.0"
|
||||
gir-format-check = "0.1"
|
||||
byte-slice-cast = "1.0"
|
||||
|
||||
[features]
|
||||
default = []
|
||||
|
|
|
@ -450,6 +450,8 @@ mod tests {
|
|||
|
||||
#[test]
|
||||
fn pack_unpack() {
|
||||
use byte_slice_cast::*;
|
||||
|
||||
gst::init().unwrap();
|
||||
|
||||
let info = AudioFormatInfo::from_format(crate::AudioFormat::S16le);
|
||||
|
@ -457,12 +459,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);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue