Browse Source

Process ECMs before EMMs.

Use different queues for ECMs and EMMs. This allows to process
ECMs before EMMs, preventing the case where too much incoming
EMMs slow down ECM processing and interfere with getting the code
words on time.
Georgi Chorbadzhiyski 13 years ago
parent
commit
cc756b5ca5
3 changed files with 25 additions and 7 deletions
  1. 2
    0
      ChangeLog
  2. 20
    6
      camd.c
  3. 3
    1
      data.h

+ 2
- 0
ChangeLog View File

@@ -1,5 +1,7 @@
1 1
 xxxx-xx-xx : Version -next
2 2
  * Fix EMM/ECM parsing (this fixes ORF1 decoding on Astra 19.2).
3
+ * Process ECMs before EMMs, preventing the case where too much
4
+   incoming EMMs to interfere with decryption.
3 5
 
4 6
 2011-09-30 : Version 3.0
5 7
  * Add man page.

+ 20
- 6
camd.c View File

@@ -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);

+ 3
- 1
data.h View File

@@ -64,7 +64,9 @@ struct camd35 {
64 64
 	struct key		*key;
65 65
 
66 66
 	pthread_t		thread;
67
-	QUEUE			*queue;
67
+	QUEUE			*req_queue;
68
+	QUEUE			*ecm_queue;
69
+	QUEUE			*emm_queue;
68 70
 };
69 71
 
70 72
 enum io_type {

Loading…
Cancel
Save