add_af_ql_audio

Change-Id: I24a1fc20566049713e950f5f8e4cad6045c51723
diff --git a/mbtk/libql_lib/src/ql_audio.c b/mbtk/libql_lib/src/ql_audio.c
index 5ffee78..3bb4c1b 100755
--- a/mbtk/libql_lib/src/ql_audio.c
+++ b/mbtk/libql_lib/src/ql_audio.c
@@ -12,6 +12,12 @@
 #define AUDIO_HANDLE 1
 #define WAV_PLAY_BUFF 1024
 
+
+static mbtk_audio_handle player_hdl = NULL;
+static _cb_onRecorder record_cb_fun = NULL;
+static int Samprate = 8000;
+
+
 static int sample_rate = 8000;
 static int play_handle = AUDIO_HANDLE;
 static _cb_onPlayer play_cb_func = NULL;
@@ -173,6 +179,10 @@
 *****************************************************************/
 int Ql_AudPlayer_Open(char* device, _cb_onPlayer cb_func)
 {
+#ifdef MBTK_AF_SUPPORT
+    player_hdl = mbtk_audio_open_new(MBTK_AUTIO_TYPE_OUT, 1, Samprate, cb_func);
+    return (int)player_hdl;
+#else
     if(is_running || mbtk_audio_pcm_init()) {
         return -1;
     } else {
@@ -180,6 +190,7 @@
         is_running = 1;
         return play_handle;
     }
+#endif
 }
 
 /*========================================================================
@@ -202,12 +213,17 @@
 /*=======================================================================*/
 int Ql_AudPlayer_Play(int hdl, unsigned char* pData, unsigned int length)
 {
+#ifdef MBTK_AF_SUPPORT
+    return mbtk_audio_play_stream_new((void *)hdl, pData, length,50);
+
+#else
     if(!is_running || hdl != play_handle) {
         LOGE("Handle error : %d", hdl);
         return -1;
     }
 
     return play_stream(pData, length);
+#endif
 }
 
 /*========================================================================
@@ -235,12 +251,17 @@
 
 int  Ql_AudPlayer_PlayFrmFile(int hdl, int fd, int offset)
 {
+#ifdef MBTK_AF_SUPPORT
+    return mbtk_audio_play_file_new((void *)hdl, fd, offset);
+
+#else
     if(!is_running || hdl != play_handle) {
         LOGE("Handle error : %d", hdl);
         return -1;
     }
 
     return play_by_fd(fd, offset);
+#endif
 }
 
 //
@@ -318,6 +339,10 @@
 //   Handle received from Ql_AudPlayer_Open().
 void Ql_AudPlayer_Close(int hdl)
 {
+    mbtk_audio_close_new((void *)hdl);
+
+
+#if 0
     if(!is_running || hdl != play_handle) {
         LOGE("Handle error : %d", hdl);
         return;
@@ -330,6 +355,7 @@
 
     is_running = 0;
     mbtk_audio_pcm_deinit();
+#endif
 }
 
 
@@ -586,8 +612,30 @@
 
 int Ql_Rxgain_Set(int value)
 {
+#ifdef MBTK_AF_SUPPORT
+    int volume =0;
+    if(value < -36 || value > 9)
+    {
+        volume = 0;
+    }
+    else
+    {
+        volume = value;
+    }
+
+    if(player_hdl==NULL)
+       return 0;
+
+    char databuf[1025]={0};
+    memcpy(databuf, "                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                ", 1024);
+
+    mbtk_audio_play_stream_new(player_hdl, databuf, 1024, volume);
+    return 0;
+#else
     mbtk_dsp_gain_set(1, value);
     return 0;
+#endif
+    return 0;
 }