diff options
| author | Yuval Adam <_@yuv.al> | 2022-07-18 20:41:47 +0300 |
|---|---|---|
| committer | Yuval Adam <_@yuv.al> | 2022-07-18 20:41:47 +0300 |
| commit | 288b1b1ada886dd79f6b06bafa190f14bb2f370e (patch) | |
| tree | d29075eae52d9977f33adec0fcdbc5063449c010 | |
| parent | 937216b9d04f858674c01ba11eb9e0d6e2f5fbd9 (diff) | |
Got a first segfault nice
| -rw-r--r-- | c2enc/src/main.rs | 12 | ||||
| -rw-r--r-- | libcodec2/src/lib.rs | 2 |
2 files changed, 11 insertions, 3 deletions
diff --git a/c2enc/src/main.rs b/c2enc/src/main.rs index d8ee9c1..df3891e 100644 --- a/c2enc/src/main.rs +++ b/c2enc/src/main.rs @@ -12,8 +12,16 @@ fn main() { let mut file = File::open(&path).unwrap(); let mut buf = Vec::new(); file.read_to_end(&mut buf).unwrap(); + let mut rdr = Cursor::new(buf); - while let Ok(res) = rdr.read_i16::<LittleEndian>() { - println!("{}", res); + let mut speech = Vec::new(); + while let Ok(i) = rdr.read_i16::<LittleEndian>() { + speech.push(i); } + + let mut bits = Vec::new(); + let c = libcodec2::Codec2::new(); + c.encode(&speech, &mut bits); + + println!("{:?}", bits); } diff --git a/libcodec2/src/lib.rs b/libcodec2/src/lib.rs index 4a224e4..04c2717 100644 --- a/libcodec2/src/lib.rs +++ b/libcodec2/src/lib.rs @@ -21,7 +21,7 @@ impl Codec2 { } /// Encode an array of speech samples into an array of bits - pub fn encode(self, speech: &[i16], bits: &[u8]) { + pub fn encode(self, speech: &[i16], bits: &mut [u8]) { unsafe { ffi::codec2_encode(self.0, bits.as_ptr() as *mut _, speech.as_ptr() as *mut _); } |
