void run_loop() { while (1) { protocol_with_recv_frame(^uint8 (protocol_frame* frame) { switch (frame->id) { case TERMINATE_ID: _terminate(0); break; case CHECK_REQ_ID: handle_check(frame); break; case QUERY_REQ_ID: handle_query(); break; case DOUBLE_REQ_ID: handle_double(frame); break; default: handle_unrecognized_id(frame->id); return 0; }; return 1; }); }
/* Handle Command, special char or attribute and also check for * channel changes. * Returns 1 if something was written to screen, 0 otherwise */ int disCommand(unsigned char hi, unsigned char lo, ccx_decoder_608_context *context, struct cc_subtitle *sub) { int wrote_to_screen=0; /* Full channel changes are only allowed for "GLOBAL CODES", * "OTHER POSITIONING CODES", "BACKGROUND COLOR CODES", * "MID-ROW CODES". * "PREAMBLE ACCESS CODES", "BACKGROUND COLOR CODES" and * SPECIAL/SPECIAL CHARACTERS allow only switching * between 1&3 or 2&4. */ context->new_channel = check_channel(hi, context); //if (wb->data608->channel!=cc_channel) // continue; if (hi>=0x18 && hi<=0x1f) hi=hi-8; switch (hi) { case 0x10: if (lo>=0x40 && lo<=0x5f) handle_pac(hi, lo, context); break; case 0x11: if (lo>=0x20 && lo<=0x2f) handle_text_attr(hi, lo, context); if (lo>=0x30 && lo<=0x3f) { wrote_to_screen=1; handle_double(hi, lo, context); } if (lo>=0x40 && lo<=0x7f) handle_pac(hi, lo, context); break; case 0x12: case 0x13: if (lo>=0x20 && lo<=0x3f) { wrote_to_screen = handle_extended(hi, lo, context); } if (lo>=0x40 && lo<=0x7f) handle_pac(hi, lo, context); break; case 0x14: case 0x15: if (lo>=0x20 && lo<=0x2f) handle_command(hi, lo, context, sub); if (lo>=0x40 && lo<=0x7f) handle_pac(hi, lo, context); break; case 0x16: if (lo>=0x40 && lo<=0x7f) handle_pac(hi, lo, context); break; case 0x17: if (lo>=0x21 && lo<=0x23) handle_command(hi, lo, context, sub); if (lo>=0x2e && lo<=0x2f) handle_text_attr(hi, lo, context); if (lo>=0x40 && lo<=0x7f) handle_pac(hi, lo, context); break; } return wrote_to_screen; }