diff rvinterf/asyncshell/tchplay.c @ 1030:194967e11b2b

fc-shell: tch record and tch play reworked for libgsm-compatible file format
author Mychaela Falconia <falcon@freecalypso.org>
date Tue, 31 May 2016 18:39:06 +0000
parents 333015c662bc
children
line wrap: on
line diff
--- a/rvinterf/asyncshell/tchplay.c	Tue May 31 01:53:04 2016 +0000
+++ b/rvinterf/asyncshell/tchplay.c	Tue May 31 18:39:06 2016 +0000
@@ -31,13 +31,13 @@
 fill_uplink(msgout)
 	void (*msgout)();
 {
-	u_char sendpkt[35];
+	u_char readbytes[33], sendpkt[35];
 	int cc;
 
 	sendpkt[0] = RVT_TCH_HEADER;
 	sendpkt[1] = TCH_ULBITS_REQ;
 	while (queued_frames < QUEUE_LIMIT) {
-		cc = fread(sendpkt + 2, 1, 33, gsm_data_file);
+		cc = fread(readbytes, 1, 33, gsm_data_file);
 		if (cc < 33) {
 			if (cc)
 			  msgout("TCH UL: extra bytes at the end of the file");
@@ -45,6 +45,12 @@
 			gsm_data_file = 0;
 			return;
 		}
+		if ((readbytes[0] & 0xF0) != 0xD0) {
+			msgout("TCH UL: bad file input, play aborted");
+			gsm_data_file = 0;
+			return;
+		}
+		gsm0610_libgsm_to_tidsp(readbytes, sendpkt + 2);
 		send_pkt_to_target(sendpkt, 35);
 		queued_frames++;
 	}