diff --git a/src/lib_ccx/ccx_decoders_common.c b/src/lib_ccx/ccx_decoders_common.c index 9f94435eb..d22304aff 100644 --- a/src/lib_ccx/ccx_decoders_common.c +++ b/src/lib_ccx/ccx_decoders_common.c @@ -17,7 +17,6 @@ made to reuse, not duplicate, as many functions as possible */ #ifndef DISABLE_RUST extern int ccxr_process_cc_data(struct lib_cc_decode *dec_ctx, unsigned char *cc_data, int cc_count); -extern void ccxr_flush_decoder(void *dtvcc_rust, struct dtvcc_service_decoder *decoder); #endif uint64_t utc_refvalue = UINT64_MAX; /* _UI64_MAX/UINT64_MAX means don't use UNIX, 0 = use current system time as reference, +1 use a specific reference */ diff --git a/src/lib_ccx/general_loop.c b/src/lib_ccx/general_loop.c index 8ab5f94da..b32f8b73a 100644 --- a/src/lib_ccx/general_loop.c +++ b/src/lib_ccx/general_loop.c @@ -1282,7 +1282,7 @@ int rcwt_loop(struct lib_ccx_ctx *ctx) #ifndef DISABLE_RUST ccxr_dtvcc_set_encoder(dec_ctx->dtvcc_rust, enc_ctx); #else - dec_ctx->dtvcc->encoder = (void *)enc_ctx; // WARN: otherwise cea-708 will not work + dec_ctx->dtvcc->encoder = (void *)enc_ctx; // WARN: otherwise cea-708 will not work #endif if (parsebuf[6] == 0 && parsebuf[7] == 2) diff --git a/src/rust/src/decoder/mod.rs b/src/rust/src/decoder/mod.rs index 0708ef90d..f8ab4fcf4 100644 --- a/src/rust/src/decoder/mod.rs +++ b/src/rust/src/decoder/mod.rs @@ -279,7 +279,7 @@ extern "C" fn ccxr_flush_active_decoders(ctx_ptr: *mut lib_cc_decode) { } if decoder.cc_count > 0 { ctx.current_field = 3; - ccxr_flush_decoder(ctx.dtvcc_rust as *mut Dtvcc, Box::into_raw(decoder)); + ccxr_flush_decoder(dtvcc_rust, decoder); } } } diff --git a/src/rust/src/decoder/service_decoder.rs b/src/rust/src/decoder/service_decoder.rs index 963eccef7..4228c42e0 100644 --- a/src/rust/src/decoder/service_decoder.rs +++ b/src/rust/src/decoder/service_decoder.rs @@ -1200,12 +1200,10 @@ impl dtvcc_service_decoder { } /// Flush service decoder -#[no_mangle] -pub extern "C" fn ccxr_flush_decoder(dtvcc_rust: *mut Dtvcc, decoder: *mut dtvcc_service_decoder) { +pub fn ccxr_flush_decoder(dtvcc_rust: &mut Dtvcc, mut decoder: Box) { debug!("dtvcc_decoder_flush: Flushing decoder"); - let timing = unsafe { &mut *((*dtvcc_rust).timing) }; - let encoder = unsafe { &mut *((*dtvcc_rust).encoder) }; - let decoder = unsafe { &mut *decoder }; + let timing = &mut dtvcc_rust.timing; + let encoder = unsafe { &mut *(dtvcc_rust.encoder) }; let mut screen_content_changed = false; for i in 0..CCX_DTVCC_MAX_WINDOWS { diff --git a/src/rust/src/lib.rs b/src/rust/src/lib.rs index 0ddd14229..db0f7f344 100644 --- a/src/rust/src/lib.rs +++ b/src/rust/src/lib.rs @@ -118,14 +118,20 @@ extern "C" fn ccxr_dtvcc_free(dtvcc_rust: *mut Dtvcc) { // Drop all windows row window.rows.iter().for_each(|symbol_ptr| unsafe { - symbol_ptr.drop_in_place(); + drop(Box::from_raw(*symbol_ptr)); }); window.memory_reserved = 0; }); - unsafe { decoder.tv.drop_in_place() }; + unsafe { + drop(Box::from_raw(decoder.tv)); + }; } + + unsafe { + drop(Box::from_raw(dtvcc)); + }; } #[no_mangle]