File: fix-alignment.diff

package info (click to toggle)
rust-gstreamer-audio 0.23.5-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, trixie
  • size: 704 kB
  • sloc: makefile: 2
file content (58 lines) | stat: -rw-r--r-- 1,609 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
Description: Fix aligment on armhf
 Otherwise, the test fail with SIGBUS
Author: Sebastian Dröge <slomo@coaxion.net> 
Forwarded:  https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/issues/550
Last-Update: 2025-04-06
---
This patch header follows DEP-3: http://dep.debian.net/deps/dep3/

--- a/Cargo.toml
+++ b/Cargo.toml
@@ -89,6 +89,9 @@
 [dependencies.smallvec]
 version = "1.0"
 
+[dependencies.byte-slice-cast]
+version = "1.0"
+
 [dev-dependencies.gir-format-check]
 version = "0.1"
 
--- a/src/audio_format_info.rs
+++ b/src/audio_format_info.rs
@@ -450,6 +450,7 @@
 
     #[test]
     fn pack_unpack() {
+        use byte_slice_cast::*;
         gst::init().unwrap();
 
         let info = AudioFormatInfo::from_format(crate::AudioFormat::S16le);
@@ -457,12 +458,20 @@
 
         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];
-
-        info.unpack(crate::AudioPackFlags::empty(), &mut unpacked, &input);
-        info.pack(crate::AudioPackFlags::empty(), &mut output, &unpacked);
+        let input = [0i16, i16::MAX, i16::MIN, 0i16];
+        let mut unpacked = [0i32; 4];
+        let mut output = [0i16; 4];
+
+        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);
     }