?? headset_a2dp_connection.c
字號:
/****************************************************************************
Copyright (C) Cambridge Silicon Radio Ltd. 2004-2007
FILE NAME
headset_a2dp_connection.c
DESCRIPTION
Handles a2dp connection.
*/
#include "headset_a2dp_connection.h"
#include "headset_a2dp_stream_control.h"
#include "headset_avrcp_event_handler.h"
#include "headset_configmanager.h"
#include "headset_hfp_slc.h"
#include <bdaddr.h>
#include <ps.h>
#ifdef DEBUG_A2DP_CONNECTION
#define A2DP_CONNECTION_DEBUG(x) DEBUG(x)
#else
#define A2DP_CONNECTION_DEBUG(x)
#endif
/****************************************************************************
FUNCTIONS
*/
bool a2dpGetLastUsedSource(bdaddr *addr, a2dp_sep_type *sep_type)
{
bool ret = TRUE;
if (!PsRetrieve(PSKEY_LAST_USED_AV_SOURCE, addr, sizeof(bdaddr)))
{
if (!PsRetrieve(PSKEY_LAST_PAIRED_DEVICE, addr, sizeof(bdaddr)))
{
ret = FALSE;
}
}
if ((ret) && (!PsRetrieve(PSKEY_LAST_USED_AV_SOURCE_SEP, sep_type, sizeof(a2dp_sep_type))))
{
*sep_type = a2dp_sbc;
}
return ret;
}
/****************************************************************************/
void a2dpReconnectProcedure(hsTaskData *app)
{
bdaddr a2dp_addr, ag_addr;
a2dp_sep_type sep_type;
/*
If this A2DP source is also an AG then only connect signalling channel.
If the A2DP source and AG are different devices then connect signalling and media channels.
*/
if (!a2dpGetLastUsedSource(&a2dp_addr, &sep_type))
return;
if (!hfpSlcGetLastConnectedAG(&ag_addr))
{
a2dpConnectRequest(app, TRUE);
return;
}
if (BdaddrIsSame(&a2dp_addr, &ag_addr) && app->slcConnectFromPowerOn)
{
if (!app->a2dp.sig_sink)
a2dpConnectRequest(app, FALSE);
}
else
{
a2dpConnectRequest(app, TRUE);
}
}
/****************************************************************************/
void a2dpConnectRequest(hsTaskData *app, bool connect_media)
{
bdaddr addr;
a2dp_sep_type sep_type = a2dp_sbc;
if (!a2dpGetLastUsedSource(&addr, &sep_type))
{
MessageSend(&app->task, EventA2dpReconnectFailed, 0);
return;
}
app->a2dpConnecting = TRUE;
/* Send an avrcp_play once media has connected and entered
the correct state. This is so A2DP sources (standalone and AGs)
will start playing music straight away.
*/
if (connect_media)
app->sendPlayOnConnection = TRUE;
if (!app->a2dpMP3Enabled)
{
sep_type = a2dp_sbc;
}
A2dpOpen(app->a2dp.a2dp, sep_type, &addr, connect_media);
}
/****************************************************************************/
void a2dpDisconnectRequest(hsTaskData *app)
{
/* Don't resume A2DP streaming */
streamControlCancelResumeA2dpStreaming( app );
/* Disconnect AVRCP first. */
avrcpDisconnectReq(app);
/* Close all A2DP signalling and media channels */
A2dpCloseAll(app->a2dp.a2dp);
}
/****************************************************************************/
bool a2dpIsConnecting ( hsTaskData * pApp )
{
return pApp->a2dpConnecting;
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -