Skip to content

Commit e1ca3a6

Browse files
refactor: Convert some portion of code to rust
Code contains flushing the active decoders of `dtvcc_rust`
1 parent 3f2d2f2 commit e1ca3a6

File tree

1 file changed

+26
-2
lines changed

1 file changed

+26
-2
lines changed

src/rust/src/decoder/mod.rs

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@ mod timing;
1010
mod tv_screen;
1111
mod window;
1212

13+
use crate::{bindings::*, utils::*};
1314
use lib_ccxr::{
1415
debug, fatal,
1516
util::log::{DebugMessageFlag, ExitCause},
1617
};
17-
18-
use crate::{bindings::*, utils::*};
18+
use service_decoder::ccxr_flush_decoder;
1919

2020
const CCX_DTVCC_MAX_PACKET_LENGTH: u8 = 128;
2121
const CCX_DTVCC_NO_LAST_SEQUENCE: i32 = -1;
@@ -261,6 +261,30 @@ impl<'a> Dtvcc<'a> {
261261
}
262262
}
263263

264+
#[no_mangle]
265+
extern "C" fn ccxr_flush_active_decoders(ctx_ptr: *mut lib_cc_decode) {
266+
let ctx = unsafe { &mut *ctx_ptr };
267+
let dtvcc_rust = unsafe { &mut *(ctx.dtvcc_rust as *mut Dtvcc) };
268+
269+
if dtvcc_rust.is_active {
270+
for i in 0..CCX_DTVCC_MAX_SERVICES {
271+
let decoder_opt = &dtvcc_rust.decoders[i];
272+
if decoder_opt.is_none() {
273+
continue;
274+
}
275+
let decoder = decoder_opt.to_owned().unwrap();
276+
277+
if is_true(!dtvcc_rust.services_active[i]) {
278+
continue;
279+
}
280+
if decoder.cc_count > 0 {
281+
ctx.current_field = 3;
282+
ccxr_flush_decoder(ctx.dtvcc_rust as *mut Dtvcc, Box::into_raw(decoder));
283+
}
284+
}
285+
}
286+
}
287+
264288
/// A single character symbol
265289
///
266290
/// sym stores the symbol

0 commit comments

Comments
 (0)