Add asr1806 Audio API.
Change-Id: I0cefc67d0825e2bf4476fd0a07cb0d1fc5971457
diff --git a/mbtk/mbtk_lib/src/mbtk_audio.c b/mbtk/mbtk_lib/src/mbtk_audio.c
index f026769..f22120b 100755
--- a/mbtk/mbtk_lib/src/mbtk_audio.c
+++ b/mbtk/mbtk_lib/src/mbtk_audio.c
@@ -322,36 +322,25 @@
void mbtk_audio_mode_set(int mode)
{
int rc = 0;
- struct ubus_request *req = NULL;
if(NULL == mbtk_audio_ubus_db)
{
printf("mbtk_dtmf_ubus not init!\n");
return;
}
- req = (struct ubus_request *)malloc(sizeof(struct ubus_request));
- if (req == NULL)
- {
- printf("leave %s: lack of memory\n", __FUNCTION__);
- return;
- }
- memset(req, 0, sizeof(struct ubus_request));
blob_buf_init(&audio_cm_b, 0);
blobmsg_add_u32(&audio_cm_b, "param0", mode);
- if ((rc = ubus_invoke_async(mbtk_audio_ubus_db->ctx,
+ if ((rc = ubus_invoke(mbtk_audio_ubus_db->ctx,
mbtk_audio_ubus_db->audioif_request_id,
AUDIO_UBUS_MODE_SET,
- audio_cm_b.head, req)) != UBUS_STATUS_OK)
+ audio_cm_b.head, NULL, NULL, 0)) != UBUS_STATUS_OK)
{
- free(req);
printf("%s, ubus_invoke_async %s failed %s\n", __FUNCTION__, AUDIO_UBUS_MODE_SET, ubus_strerror(rc));
}
else
{
printf("%s: ubus_invoke_async success\n", __FUNCTION__);
mbtk_audio_ubus_db->work_state++;
- req->complete_cb = mbtk_ubus_complete_cb;
- ubus_complete_request_async(mbtk_audio_ubus_db->ctx, req);
}
}
@@ -359,36 +348,26 @@
void mbtk_audio_path_enable(int mode)
{
int rc = 0;
- struct ubus_request *req = NULL;
if(NULL == mbtk_audio_ubus_db)
{
printf("mbtk_dtmf_ubus not init!\n");
return;
}
- req = (struct ubus_request *)malloc(sizeof(struct ubus_request));
- if (req == NULL)
- {
- printf("leave %s: lack of memory\n", __FUNCTION__);
- return;
- }
- memset(req, 0, sizeof(struct ubus_request));
+
blob_buf_init(&audio_cm_b, 0);
blobmsg_add_u32(&audio_cm_b, "param0", mode);
- if ((rc = ubus_invoke_async(mbtk_audio_ubus_db->ctx,
+ if ((rc = ubus_invoke(mbtk_audio_ubus_db->ctx,
mbtk_audio_ubus_db->audioif_request_id,
AUDIO_UBUS_PATH_ENABLE,
- audio_cm_b.head, req)) != UBUS_STATUS_OK)
+ audio_cm_b.head, NULL, NULL, 0)) != UBUS_STATUS_OK)
{
- free(req);
printf("%s, ubus_invoke_async %s failed %s\n", __FUNCTION__, AUDIO_UBUS_PATH_ENABLE, ubus_strerror(rc));
}
else
{
printf("%s: ubus_invoke_async success\n", __FUNCTION__);
mbtk_audio_ubus_db->work_state++;
- req->complete_cb = mbtk_ubus_complete_cb;
- ubus_complete_request_async(mbtk_audio_ubus_db->ctx, req);
}
}
@@ -408,36 +387,25 @@
void mbtk_audio_switch_pcm(int mode)
{
int rc = 0;
- struct ubus_request *req = NULL;
if(NULL == mbtk_audio_ubus_db)
{
printf("mbtk_dtmf_ubus not init!\n");
return;
}
- req = (struct ubus_request *)malloc(sizeof(struct ubus_request));
- if (req == NULL)
- {
- printf("leave %s: lack of memory\n", __FUNCTION__);
- return;
- }
- memset(req, 0, sizeof(struct ubus_request));
blob_buf_init(&audio_cm_b, 0);
blobmsg_add_u32(&audio_cm_b, "param0", mode);
- if ((rc = ubus_invoke_async(mbtk_audio_ubus_db->ctx,
+ if ((rc = ubus_invoke(mbtk_audio_ubus_db->ctx,
mbtk_audio_ubus_db->audioif_request_id,
AUDIO_UBUS_SWITCH_PCM,
- audio_cm_b.head, req)) != UBUS_STATUS_OK)
+ audio_cm_b.head, NULL, NULL, 0)) != UBUS_STATUS_OK)
{
- free(req);
printf("%s, ubus_invoke_async %s failed %s\n", __FUNCTION__, AUDIO_UBUS_MODE_SET, ubus_strerror(rc));
}
else
{
printf("%s: ubus_invoke_async success\n", __FUNCTION__);
mbtk_audio_ubus_db->work_state++;
- req->complete_cb = mbtk_ubus_complete_cb;
- ubus_complete_request_async(mbtk_audio_ubus_db->ctx, req);
}
}