Skip to content

Commit 47a83a2

Browse files
refactor: Convert some portion of code to rust
Code contains flushing the active decoders of `dtvcc_rust`
1 parent e582499 commit 47a83a2

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

src/rust/src/decoder/mod.rs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ use crate::{
1616
};
1717

1818
use log::{debug, warn};
19+
use service_decoder::ccxr_flush_decoder;
1920

2021
const CCX_DTVCC_MAX_PACKET_LENGTH: u8 = 128;
2122
const CCX_DTVCC_NO_LAST_SEQUENCE: i32 = -1;
@@ -260,6 +261,30 @@ impl<'a> Dtvcc<'a> {
260261
}
261262
}
262263

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+
263288
/// A single character symbol
264289
///
265290
/// sym stores the symbol

0 commit comments

Comments
 (0)