|
@@ -333,8 +333,14 @@ void camd_msg_free(struct camd_msg **pmsg) {
|
333
|
333
|
static void *camd_thread(void *in_ts) {
|
334
|
334
|
struct ts *ts = in_ts;
|
335
|
335
|
while (1) {
|
336
|
|
- struct camd_msg *msg = queue_get(ts->camd35.queue); // Waits...
|
337
|
|
- if (!msg || ts->camd_stop)
|
|
336
|
+ struct camd_msg *msg;
|
|
337
|
+ void *req = queue_get(ts->camd35.req_queue); // Waits...
|
|
338
|
+ if (!req || ts->camd_stop)
|
|
339
|
+ break;
|
|
340
|
+ msg = queue_get_nowait(ts->camd35.ecm_queue);
|
|
341
|
+ if (!msg)
|
|
342
|
+ msg = queue_get_nowait(ts->camd35.emm_queue);
|
|
343
|
+ if (!msg)
|
338
|
344
|
break;
|
339
|
345
|
camd_do_msg(msg);
|
340
|
346
|
}
|
|
@@ -344,7 +350,11 @@ static void *camd_thread(void *in_ts) {
|
344
|
350
|
void camd_msg_process(struct ts *ts, struct camd_msg *msg) {
|
345
|
351
|
msg->ts = ts;
|
346
|
352
|
if (ts->camd35.thread) {
|
347
|
|
- queue_add(ts->camd35.queue, msg);
|
|
353
|
+ if (msg->type == EMM_MSG)
|
|
354
|
+ queue_add(ts->camd35.emm_queue, msg);
|
|
355
|
+ if (msg->type == ECM_MSG)
|
|
356
|
+ queue_add(ts->camd35.ecm_queue, msg);
|
|
357
|
+ queue_add(ts->camd35.req_queue, msg);
|
348
|
358
|
} else {
|
349
|
359
|
camd_do_msg(msg);
|
350
|
360
|
}
|
|
@@ -354,7 +364,9 @@ void camd_start(struct ts *ts) {
|
354
|
364
|
camd35_connect(ts);
|
355
|
365
|
// The input is not file, process messages using async thread
|
356
|
366
|
if (!(ts->input.type == FILE_IO && ts->input.fd != 0)) {
|
357
|
|
- ts->camd35.queue = queue_new();
|
|
367
|
+ ts->camd35.req_queue = queue_new();
|
|
368
|
+ ts->camd35.ecm_queue = queue_new();
|
|
369
|
+ ts->camd35.emm_queue = queue_new();
|
358
|
370
|
pthread_create(&ts->camd35.thread, NULL , &camd_thread, ts);
|
359
|
371
|
}
|
360
|
372
|
}
|
|
@@ -362,9 +374,11 @@ void camd_start(struct ts *ts) {
|
362
|
374
|
void camd_stop(struct ts *ts) {
|
363
|
375
|
ts->camd_stop = 1;
|
364
|
376
|
if (ts->camd35.thread) {
|
365
|
|
- queue_wakeup(ts->camd35.queue);
|
|
377
|
+ queue_wakeup(ts->camd35.req_queue);
|
366
|
378
|
pthread_join(ts->camd35.thread, NULL);
|
367
|
|
- queue_free(&ts->camd35.queue);
|
|
379
|
+ queue_free(&ts->camd35.req_queue);
|
|
380
|
+ queue_free(&ts->camd35.ecm_queue);
|
|
381
|
+ queue_free(&ts->camd35.emm_queue);
|
368
|
382
|
ts->camd35.thread = 0;
|
369
|
383
|
}
|
370
|
384
|
camd35_disconnect(ts);
|