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
 xxxx-xx-xx : Version -next
1
 xxxx-xx-xx : Version -next
2
  * Fix EMM/ECM parsing (this fixes ORF1 decoding on Astra 19.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
 2011-09-30 : Version 3.0
6
 2011-09-30 : Version 3.0
5
  * Add man page.
7
  * Add man page.

+ 20
- 6
camd.c View File

333
 static void *camd_thread(void *in_ts) {
333
 static void *camd_thread(void *in_ts) {
334
 	struct ts *ts = in_ts;
334
 	struct ts *ts = in_ts;
335
 	while (1) {
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
 			break;
344
 			break;
339
 		camd_do_msg(msg);
345
 		camd_do_msg(msg);
340
 	}
346
 	}
344
 void camd_msg_process(struct ts *ts, struct camd_msg *msg) {
350
 void camd_msg_process(struct ts *ts, struct camd_msg *msg) {
345
 	msg->ts = ts;
351
 	msg->ts = ts;
346
 	if (ts->camd35.thread) {
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
 	} else {
358
 	} else {
349
 		camd_do_msg(msg);
359
 		camd_do_msg(msg);
350
 	}
360
 	}
354
 	camd35_connect(ts);
364
 	camd35_connect(ts);
355
 	// The input is not file, process messages using async thread
365
 	// The input is not file, process messages using async thread
356
 	if (!(ts->input.type == FILE_IO && ts->input.fd != 0)) {
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
 		pthread_create(&ts->camd35.thread, NULL , &camd_thread, ts);
370
 		pthread_create(&ts->camd35.thread, NULL , &camd_thread, ts);
359
 	}
371
 	}
360
 }
372
 }
362
 void camd_stop(struct ts *ts) {
374
 void camd_stop(struct ts *ts) {
363
 	ts->camd_stop = 1;
375
 	ts->camd_stop = 1;
364
 	if (ts->camd35.thread) {
376
 	if (ts->camd35.thread) {
365
-		queue_wakeup(ts->camd35.queue);
377
+		queue_wakeup(ts->camd35.req_queue);
366
 		pthread_join(ts->camd35.thread, NULL);
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
 		ts->camd35.thread = 0;
382
 		ts->camd35.thread = 0;
369
 	}
383
 	}
370
 	camd35_disconnect(ts);
384
 	camd35_disconnect(ts);

+ 3
- 1
data.h View File

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

Loading…
Cancel
Save