icfans

蓝牙立体声切换延时

0
阅读(2489)

[DESCRIPTION]
连接蓝牙耳机播放Audioplayer,进行单声道与立体声互相切换时,声音会先从外放播出,然后才切回到蓝牙耳机
[SOLUTION]来自半导体社区
产生这个问题的原因是进行蓝牙立体声/单声道的切换时会有一个A2DP断开/HFP连接或HFP断开A2DP连接的过程,在这个
过程中由于蓝牙处于断开状态,声音就会从外放播出;解决方法是在进行切换的过程中将AudioPlayer pause,连接建
立后重新resume Audioplayer。可按如下方式修改Code:
1) AudioPlayerProt.h
#ifdef __MMI_AUDIO_PLAYER__
...
//add the following Code
extern BOOL GetPauseState(void);
extern void SetPauseState(BOOL state);
//end add
#endif /* __MMI_AUDIO_PLAYER__ */
2) AudioPlayerMsgHandler.c
//add the following Code
BOOL is_pause_by_switch_bt = FALSE; // Add this variable
BOOL GetPauseState()
{
return is_pause_by_switch_bt;
}
void SetPauseState(BOOL state)
{
is_pause_by_switch_bt = state;
}
//end add
void mmi_audply_switch_bt_output(void)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
//add the following Code
// pause audioplay before new bt transport connection established.
if (g_audply.state == STATE_PLAY)
{
mmi_audply_pause();
is_pause_by_switch_bt = TRUE;
}
//end add
if (mmi_audply_is_output_to_bt())
{
/* switch output: OFF -> ON */
//change the following Code
// if (g_audply.state == STATE_PLAY)
if((g_audply.state == STATE_PLAY) ||((g_audply.state != STATE_PLAY) && is_pause_by_switch_bt))
{
wait_open_bt = TRUE;
av_bt_open(mmi_audply_get_bt_headset(), g_audply.prev_filefullname,
mmi_audply_bt_open_callback, !mmi_audply_is_play_speed_normal(),
KAL_TRUE);
} }
else
{
/* switch output: ON -> OFF */
//change the following Code
// if (g_audply.state == STATE_PLAY)
if((g_audply.state == STATE_PLAY) ||((g_audply.state != STATE_PLAY) && is_pause_by_switch_bt))
{
av_bt_close_codec();
#ifdef __MMI_AUDIO_PLAYER_A2DP_BLOCK_SPECTRUM__
g_audply_spectrum_blocked = FALSE ;
mmi_audply_turn_on_spectrum();
#endif
}
av_bt_close(KAL_TRUE);
} }
3) av_bt.c
Note: if software version is 09AW0924 and later(not include 08B), please use API mmi_audply_play()
instead of mmi_audply_resume()
void av_bt_start_stream_cnf(void *msg)
{
...
//add the following Code
// resume audioplayer when bt link established
if(GetPauseState())
{
mmi_audply_resume();
SetPauseState(FALSE);
}
//end add
}
void av_bt_open_stream_ind(void* msg)
{
...
//add the following code
// resume audioplayer when bt link established
if(GetPauseState())
{
mmi_audply_resume();
SetPauseState(FALSE);
}
//end add
}
4) settingprof.c
Note: if software version is 09AW0924 and later(not include 08B), please use API mmi_audply_play()
instead of mmi_audply_resume()
//add the following code
#include "AudioPlayerProt.h"
//end add
void mmi_profiles_bt_connect_callback(U8 connect_type, U8 callback_type, U16 result)
{
...
case MMI_PROFILES_BT_HFP_SCO:
...
//add the following code
if(GetPauseState())
{
mmi_audply_resume();
SetPauseState(FALSE);
}
//end add
break;
...
}
Also add path "plutommi\mtkapp\AudioPlayer\AudioPlayerInc" to make\plutommi\mmi_app\mmi_app.inc
5) if the software version is 09AW0924 and later(not include 08B), please add the following change:
修改文件SettingProf.c
void mmi_profiles_bt_enable_sco_connection()
{
.........
if(!g_mmi_profiles_bt_disalbe_sco)
{
//if(mmi_bt_is_aud2hf() && !mmi_profiles_bt_is_sco_app_idle())
if(mmi_bt_is_aud2hf() && (!mmi_profiles_bt_is_sco_app_idle()|| GetPauseState()))
{
……
} } }


ICfans