diff src/g23m-aci/aci/ati_audio.c @ 136:7d5b412ffb6c

aci: AT%VBAT and melody play enhancements from Magnetite
author Mychaela Falconia <falcon@freecalypso.org>
date Mon, 07 Jan 2019 18:47:52 +0000
parents d393cd9bb723
children 8c5d012b9c4d
line wrap: on
line diff
--- a/src/g23m-aci/aci/ati_audio.c	Thu Dec 20 04:24:06 2018 +0000
+++ b/src/g23m-aci/aci/ati_audio.c	Mon Jan 07 18:47:52 2019 +0000
@@ -214,45 +214,71 @@
 }
 #endif
 
+static char melody_E1_name[AUDIO_PATH_NAME_MAX_SIZE];
+
 /* AT@E1 - play an E1 format melody */
 GLOBAL T_ATI_RSLT atAtE1 ( char *cl, UBYTE srcId )
 {
 	T_AUDIO_MELODY_E1_PARAMETER e1_param;
+	int loopback = 0;
 	T_RV_RETURN return_path;
 
-	cl = parse(cl, "S", (LONG)(sizeof(e1_param.melody_name)),
-		   e1_param.melody_name);
+	cl = parse(cl, "Sd", (LONG)(sizeof(e1_param.melody_name)),
+		   e1_param.melody_name, &loopback);
 	if (!cl || !e1_param.melody_name[0])
 		return (ATI_FAIL);
-	e1_param.loopback = AUDIO_MELODY_NO_LOOPBACK;
+	e1_param.loopback = loopback;
 	e1_param.melody_mode = AUDIO_MELODY_NORMAL_MODE;
 
 	return_path.addr_id        = NULL;
 	return_path.callback_func  = audio_callback;
-	if (audio_melody_E1_start(&e1_param, return_path) == AUDIO_OK)
+	if (audio_melody_E1_start(&e1_param, return_path) == AUDIO_OK) {
+		strcpy(melody_E1_name, e1_param.melody_name);
+		return (ATI_CMPL);
+	} else
+		return (ATI_FAIL);
+}
+
+/* AT@E1STOP - stop melody started with AT@E1 */
+GLOBAL T_ATI_RSLT atAtE1STOP ( char *cl, UBYTE srcId )
+{
+	T_AUDIO_MELODY_E1_STOP_PARAMETER e1stop_param;
+	T_RV_RETURN return_path;
+
+	if (!melody_E1_name[0])
+		return (ATI_FAIL);
+	strcpy(e1stop_param.melody_name, melody_E1_name);
+
+	return_path.addr_id        = NULL;
+	return_path.callback_func  = audio_callback;
+	if (audio_melody_E1_stop(&e1stop_param, return_path) == AUDIO_OK)
 		return (ATI_CMPL);
 	else
 		return (ATI_FAIL);
 }
 
+static char melody_E2_name[AUDIO_PATH_NAME_MAX_SIZE];
+
 /* AT@E2 - play an E2 format melody */
 GLOBAL T_ATI_RSLT atAtE2 ( char *cl, UBYTE srcId )
 {
 	T_AUDIO_MELODY_E2_PARAMETER e2_param;
+	int loopback = 0;
 	T_RV_RETURN return_path;
 
-	cl = parse(cl, "S", (LONG)(sizeof(e2_param.melody_E2_name)),
-		   e2_param.melody_E2_name);
+	cl = parse(cl, "Sd", (LONG)(sizeof(e2_param.melody_E2_name)),
+		   e2_param.melody_E2_name, &loopback);
 	if (!cl || !e2_param.melody_E2_name[0])
 		return (ATI_FAIL);
-	e2_param.E2_loopback = AUDIO_MELODY_NO_LOOPBACK;
+	e2_param.E2_loopback = loopback;
 	e2_param.melody_E2_mode = AUDIO_MELODY_NORMAL_MODE;
 
 	return_path.addr_id        = NULL;
 	return_path.callback_func  = audio_callback;
-	if (audio_melody_E2_start(&e2_param, return_path) == AUDIO_OK)
+	if (audio_melody_E2_start(&e2_param, return_path) == AUDIO_OK) {
+		strcpy(melody_E2_name, e2_param.melody_E2_name);
 		return (ATI_CMPL);
-	else
+	} else
 		return (ATI_FAIL);
 }
 
@@ -272,6 +298,24 @@
 		return (ATI_FAIL);
 }
 
+/* AT@E2STOP - stop melody started with AT@E2 */
+GLOBAL T_ATI_RSLT atAtE2STOP ( char *cl, UBYTE srcId )
+{
+	T_AUDIO_MELODY_E2_STOP_PARAMETER e2stop_param;
+	T_RV_RETURN return_path;
+
+	if (!melody_E2_name[0])
+		return (ATI_FAIL);
+	strcpy(e2stop_param.melody_E2_name, melody_E2_name);
+
+	return_path.addr_id        = NULL;
+	return_path.callback_func  = audio_callback;
+	if (audio_melody_E2_stop(&e2stop_param, return_path) == AUDIO_OK)
+		return (ATI_CMPL);
+	else
+		return (ATI_FAIL);
+}
+
 /* AT@TONE - exercise TONES through RiViera Audio Service API */
 GLOBAL T_ATI_RSLT atAtTONE ( char *cl, UBYTE srcId )
 {