⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 a2dp_sd_close.c

📁 CSR蓝牙MP3播放USB DONGLE源码
💻 C
字号:
/****************************************************************************
Copyright (C) Cambridge Silicon Radio Ltd. 2004-2006
Part of BlueLab 3.5.2-release

FILE NAME
    a2dp_sd_close.c

DESCRIPTION
    Close the connection

NOTES
    
*/


/****************************************************************************
    Header files
*/
#include "a2dp_sd_private.h"
#include "a2dp_sd_close.h"
#include "a2dp_sd_initiate.h"
#include "a2dp_sd_kalimba.h"

#include <a2dp.h>
#include <bdaddr.h>


/****************************************************************************
NAME    
    a2dpSdCloseConnectionRequest
    
DESCRIPTION
    Initiate the release of the A2DP connection.

RETURNS
    void
*/
void a2dpSdCloseConnectionRequest(const a2dpSourceDongleTaskData *theApp)
{
    /* Update the local state */
    avSourceDongleUpdateA2dpState(a2dp_state_disconnecting);

    /* Close the connection */
    A2dpClose(theApp->a2dp, theApp->media_sink);

    /* If the remote control is open, close it */
    if (theApp->avrcpState == avrcp_state_connected)
    {
        /* Issue an RCP disconnect request */
        AvrcpDisconnect(theApp->avrcp);

        /* Update the local state */
        avSourceDongleUpdateAvrcpState(avrcp_state_disconnecting);
    }
}


/****************************************************************************
NAME    
    a2dpSdHandleCloseCfm
    
DESCRIPTION
    Handle the close_cfm received from the A2DP library.

RETURNS
    void
*/
void a2dpSdHandleCloseCfm(const a2dpSourceDongleTaskData *theApp)
{
    /* Stop Kalimba */
    a2dpSdKalimbaStop(theApp);

    /* Wait for the device to reconnect */
    avSourceDongleUpdateA2dpState(a2dp_state_accepting);

    /* If a discover was pending, do it now */
    if (theApp->discover_pending)
        MessageSend((Task) &theApp->task, APP_DISCOVER_REQ, 0);
}


/****************************************************************************
NAME    
    a2dpSdHandleCloseInd
    
DESCRIPTION
    Indication that the connection has been lost.

RETURNS
    void
*/
void a2dpSdHandleCloseInd(a2dpSourceDongleTaskData *theApp, const A2DP_CLOSE_IND_T *ind)
{
    /* Stop Kalimba */
    a2dpSdKalimbaStop(theApp);

    /* Update the local state to accepting */
    avSourceDongleUpdateA2dpState(a2dp_state_accepting);
    
    /* If a discover was pending, do it now */
    if (theApp->discover_pending)
        MessageSend((Task) &theApp->task, APP_DISCOVER_REQ, 0);
    else if (ind->result != a2dp_closed_by_remote_device)
    {
        if (!BdaddrIsZero(&theApp->av_sink_addr))
        {
            /* Link lost unexpectedly, try to reconnect unless this was discovery. */
            a2dpSdInitiateRequest(&theApp->av_sink_addr);
        }
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -