af_ql_audio
Change-Id: Ic0c8174f86070e5a8f3b39e1e03d73ae437739a7
diff --git a/mbtk/include/mbtk/mbtk_audio2.h b/mbtk/include/mbtk/mbtk_audio2.h
index 2821632..2059c27 100755
--- a/mbtk/include/mbtk/mbtk_audio2.h
+++ b/mbtk/include/mbtk/mbtk_audio2.h
@@ -67,7 +67,7 @@
int mbtk_audio_wav_deinit();
-#if 1
+
@@ -103,7 +103,7 @@
int mbtk_audio_close_new(void *dev_hdl);
-#endif
+
#endif /* _MBTK_AUDIO2_H */
diff --git a/mbtk/libmbtk_audio/src/mbtk_pcm_stream.c b/mbtk/libmbtk_audio/src/mbtk_pcm_stream.c
index ca0ca50..a08338f 100755
--- a/mbtk/libmbtk_audio/src/mbtk_pcm_stream.c
+++ b/mbtk/libmbtk_audio/src/mbtk_pcm_stream.c
@@ -663,6 +663,7 @@
mbtk_audio_handle mbtk_audio_open_new(mbtk_audio_dev_enum dev, int flag, int rate, void *usrData)
{
+
int value = 1;
struct mopen_audio_t *aud_hdl = NULL;
int ret;
@@ -676,10 +677,11 @@
aud_hdl = (struct mopen_audio_t *) calloc(1, sizeof(struct mopen_audio_t));
if (!aud_hdl)
{
- fprintf(stderr, "\n%s:Failed to allocate audio hdl!, errno=%d\n", __FUNCTION__, errno);
+ LOGD("\n%s:Failed to allocate audio hdl!, errno=%d\n", __FUNCTION__, errno);
return NULL;
}
memset(aud_hdl, 0, sizeof(struct mopen_audio_t));
+ LOGD("mbtk_audio_open() success aud_hdl:%p\n", aud_hdl);
//init global variables
aud_hdl->audio_ahw_dev_ubus = audio_hal_install();
@@ -710,6 +712,7 @@
/* printf("Mbtk_Audio_Open aud_hdl[%x][%x][%x]\n", aud_hdl, aud_hdl->_mixer_ctl, aud_hdl->_pcm); */
internal_hdl = aud_hdl;
+ LOGD("mbtk_audio_open() success aud_hdl:%p\n", aud_hdl);
return (void *)aud_hdl;
error:
@@ -737,6 +740,8 @@
if (NULL == dev_hdl || NULL == internal_hdl)
return -1;
+
+ LOGD("mbtk_audio_play_file_new() dev_hdl:%p\n", dev_hdl);
if(AUDIO_RUNNING == pcxt->state)
return -2;
@@ -828,6 +833,8 @@
if (NULL == dev_hdl || NULL == internal_hdl || pData == NULL)
return -1;
+ LOGD("mbtk_audio_play_stream_new() dev_hdl:%p\n", dev_hdl);
+
if(AUDIO_RUNNING == pcxt->state)
return -2;
@@ -909,13 +916,13 @@
int mbtk_audio_close_new(void *dev_hdl)
{
- printf("mbtk_audio_close()\n");
+ LOGD("mbtk_audio_close()\n");
int value = 0;
struct mopen_audio_t *_hdl = (struct mopen_audio_t *)dev_hdl;
if (NULL == _hdl || NULL == internal_hdl )
{
- printf("mbtk_audio_close() fail dev_hdl is NULL\n");
+ LOGD("mbtk_audio_close() fail dev_hdl is NULL\n");
return -1;
}
diff --git a/mbtk/libql_lib/src/ql_audio.c b/mbtk/libql_lib/src/ql_audio.c
index 12a65bb..d95ca9e 100755
--- a/mbtk/libql_lib/src/ql_audio.c
+++ b/mbtk/libql_lib/src/ql_audio.c
@@ -14,6 +14,7 @@
#ifdef MBTK_AF_SUPPORT
static mbtk_audio_handle player_hdl = NULL;
+static int player_hdl_1 = AUDIO_HANDLE;
static _cb_onRecorder record_cb_fun = NULL;
static int Samprate = 8000;
#endif
@@ -181,7 +182,14 @@
{
#ifdef MBTK_AF_SUPPORT
player_hdl = mbtk_audio_open_new(MBTK_AUTIO_TYPE_OUT, 1, Samprate, cb_func);
- return (int)player_hdl;
+ if(player_hdl == NULL)
+ {
+ return -1;
+ }
+ else
+ {
+ return player_hdl_1 = AUDIO_HANDLE;
+ }
#else
if(is_running || mbtk_audio_pcm_init()) {
return -1;
@@ -214,7 +222,11 @@
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);
+ if(hdl != player_hdl_1 || player_hdl == NULL){
+ LOGE("Handle error : %d", hdl);
+ return -1;
+ }
+ return mbtk_audio_play_stream_new((void *)player_hdl, pData, length,50);
#else
if(!is_running || hdl != play_handle) {
@@ -252,7 +264,12 @@
int Ql_AudPlayer_PlayFrmFile(int hdl, int fd, int offset)
{
#ifdef MBTK_AF_SUPPORT
- return mbtk_audio_play_file_new((void *)hdl, fd, offset);
+ if(hdl != player_hdl_1 || player_hdl == NULL){
+ LOGE("Handle error : %d", hdl);
+ return -1;
+ }
+
+ return mbtk_audio_play_file_new((void *)player_hdl, fd, offset);
#else
if(!is_running || hdl != play_handle) {
@@ -340,8 +357,13 @@
void Ql_AudPlayer_Close(int hdl)
{
#ifdef MBTK_AF_SUPPORT
- mbtk_audio_close_new((void *)hdl);
+ if(hdl != player_hdl_1 || player_hdl == NULL){
+ LOGE("Handle error : %d", hdl);
+ return -1;
+ }
+ mbtk_audio_close_new((void *)player_hdl);
+ player_hdl_1 = 0;
#else
if(!is_running || hdl != play_handle) {
@@ -615,7 +637,7 @@
{
#ifdef MBTK_AF_SUPPORT
int volume =0;
- if(value < -36 || value > 9)
+ if(value < -36 || value > 13)
{
volume = 0;
}