diff --git a/src/rust/src/decoder/mod.rs b/src/rust/src/decoder/mod.rs index a12024b15..638e8e902 100644 --- a/src/rust/src/decoder/mod.rs +++ b/src/rust/src/decoder/mod.rs @@ -94,7 +94,7 @@ impl<'a> Dtvcc<'a> { w.memory_reserved = 0; }); - unsafe { dtvcc_windows_reset(decoder.as_mut()) }; + decoder.handle_reset(); *d = Some(decoder); }); @@ -334,8 +334,8 @@ mod test { false, )) .ok(); - let mut dtvcc_ctx = get_zero_allocated_obj::(); - let mut decoder = Dtvcc::new(&mut dtvcc_ctx); + let mut dtvcc_settings = get_zero_allocated_obj::(); + let mut decoder = Dtvcc::new(&mut dtvcc_settings); // Case 1: cc_type = 2 let mut dtvcc_report = ccx_decoder_dtvcc_report::default(); @@ -383,8 +383,8 @@ mod test { false, )) .ok(); - let mut dtvcc_ctx = get_zero_allocated_obj::(); - let mut decoder = Dtvcc::new(&mut dtvcc_ctx); + let mut dtvcc_settings = get_zero_allocated_obj::(); + let mut decoder = Dtvcc::new(&mut dtvcc_settings); // Case 1: Without providing last_sequence let mut dtvcc_report = ccx_decoder_dtvcc_report::default(); diff --git a/src/rust/src/lib.rs b/src/rust/src/lib.rs index eaede9add..37de14d00 100644 --- a/src/rust/src/lib.rs +++ b/src/rust/src/lib.rs @@ -350,6 +350,10 @@ pub unsafe extern "C" fn ccxr_parse_parameters(argc: c_int, argv: *mut *mut c_ch #[cfg(test)] mod test { + use std::ffi::c_void; + + use utils::get_zero_allocated_obj; + use super::*; #[test] @@ -384,13 +388,18 @@ mod test { #[test] fn test_do_cb() { - let mut dtvcc_ctx = utils::get_zero_allocated_obj::(); - let mut dtvcc = Dtvcc::new(&mut dtvcc_ctx); + // Setting up `Dtvcc` & `lib_cc_decode` + let mut dtvcc_settings = get_zero_allocated_obj::(); + dtvcc_settings.report = Box::into_raw(Box::new(ccx_decoder_dtvcc_report::default())); + println!("THK"); + let dtvcc = Dtvcc::new(&mut dtvcc_settings); + println!("THK"); let mut decoder_ctx = lib_cc_decode::default(); + decoder_ctx.dtvcc_rust = Box::into_raw(Box::new(dtvcc)) as *mut c_void; let cc_block = [0x97, 0x1F, 0x3C]; - assert!(do_cb(&mut decoder_ctx, &mut dtvcc, &cc_block)); + assert!(do_cb(&mut decoder_ctx, &cc_block)); assert_eq!(decoder_ctx.current_field, 3); assert_eq!(decoder_ctx.cc_stats[3], 1); assert_eq!(decoder_ctx.processed_enough, 0);