解决YX Audio 卡死的问题

Change-Id: I3b26fd9f8b7bf0200ba1fcf41e4dcf9a46145b6e
diff --git a/mbtk/test/asr1803/audio_test_yx.c b/mbtk/test/asr1803/audio_test_yx.c
index 53a7c01..dd9aec5 100755
--- a/mbtk/test/asr1803/audio_test_yx.c
+++ b/mbtk/test/asr1803/audio_test_yx.c
@@ -8,6 +8,7 @@
 #include <sys/time.h>
 #include <pthread.h>
 #include <signal.h>
+#include <sys/stat.h>
 
 #include "ql/ql_audio.h"
 
@@ -97,6 +98,7 @@
 	close(s_play_fd);
 	mbtk_audio_path_enable(0);
 	Ql_AudPlayer_Close(s_play_hdl);
+    s_play_hdl = -1;
 
 	printf("aplay End...\n");
     return 0;
@@ -149,6 +151,7 @@
 
     signal(SIGINT, sig_handler);
     signal(SIGTERM, sig_handler);
+    signal(SIGTSTP, sig_handler);
 
     mbtk_audio_ubus_client_init(&handler, dtmf_cb1);
     mbtk_audio_switch_pcm(1);
diff --git a/mbtk/test/ubus_demo.c b/mbtk/test/ubus_demo.c
new file mode 100755
index 0000000..4806be3
--- /dev/null
+++ b/mbtk/test/ubus_demo.c
@@ -0,0 +1,79 @@
+#include <unistd.h>
+
+#include <libubox/blobmsg_json.h>
+#include "libubus.h"
+#include "mbtk_audio.h"
+
+void receive_call_result_data(struct ubus_request *req, int type, struct blob_attr *msg)
+{
+    printf("receive_call_result_data()\n");
+	if (!msg)
+		return;
+
+	printf("len - %d,data - %s\n", msg->id_len, msg->data);
+}
+
+
+int main(int argc, char *argv[])
+{
+#if 1
+    if(argc != 3) {
+        printf("ubus_demo switch/mode 0/1/-2/2\n");
+        return -1;
+    }
+    char *type = NULL;
+    int value = atoi(argv[2]);
+    if(!strcmp(argv[1], "switch")) {
+        type = "switch_pcm";
+        if(value != 0 && value != 1) {
+            printf("ubus_demo switch/mode 0/1/-2/2\n");
+            return -1;
+        }
+    } else if(!strcmp(argv[1], "mode")) {
+        type = "audio_mode_set";
+        if(value != -2 && value != 2) {
+            printf("ubus_demo switch/mode 0/1/-2/2\n");
+            return -1;
+        }
+    } else {
+        printf("ubus_demo switch/mode 0/1/-2/2\n");
+        return -1;
+    }
+
+    static struct ubus_context *ctx;
+    ctx = ubus_connect(NULL);
+	if (!ctx) {
+		printf("Failed to connect to ubus\n");
+		return -1;
+	}
+
+    static struct blob_buf b;
+    uint32_t id;
+	int ret;
+    ret = ubus_lookup_id(ctx, "audio_if", &id);
+	if (ret) {
+        printf("ubus_lookup_id() fail.\n");
+		return ret;
+	}
+
+
+
+    blob_buf_init(&b, 0);
+    blobmsg_add_u32(&b, "param0", value);
+	if((ret = ubus_invoke(ctx, id, type, b.head, NULL/*receive_call_result_data*/, NULL, 0)) != UBUS_STATUS_OK) {
+        printf("ubus_invoke fail:%d.\n", ret);
+	} else {
+        printf("ubus_invoke success.\n");
+	}
+#else
+
+    int handler = 0;
+    mbtk_audio_ubus_client_init(&handler, NULL);
+
+    mbtk_audio_switch_pcm(1);
+    mbtk_audio_mode_set(2);
+
+#endif
+
+    return 0;
+}