hfp_ring.c

来自「蓝牙立体声耳机 firmware」· C语言 代码 · 共 76 行

C
76
字号
/****************************************************************************
Copyright (C) Cambridge Silicon Radio Ltd. 2004-2006
Part of BlueLab 3.6.2-release

FILE NAME
    hfp_ring.c

DESCRIPTION
    Deals with incoming rings sent from the AG.

*/


/****************************************************************************
    Header files
*/
#include "headset_private.h"
#include "av_stream_control.h"
#include "headset_common.h"
#include "headset_tones.h"
#include "hfp_ring.h"

#include <hfp.h>


#ifdef DEBUG_RING
#define RING_DEBUG(x) DEBUG(x)
#else
#define RING_DEBUG(x) 
#endif


/*****************************************************************************/
void hfpHeadsetHandleRingInd(headsetTaskData *app, const HFP_RING_IND_T *ind)
{
    ind = ind;
    
    /* If in HSP mode use rings as indication of incoming call */
    if (app->profile_connected == hfp_headset_profile)
    {
        if (app->hfp_state == headsetConnected)
        {
            setHfpState(app, headsetIncomingCallEstablish);
            app->active_profile = hfp_active;
        }
        MessageCancelAll(getAppTask(), APP_RING_TIMEOUT_IND);
        MessageSendLater(getAppTask(), APP_RING_TIMEOUT_IND, 0, 5000);
    }

    /* Check to see if we should be playing a ring tone and if so play it */
    if (!app->in_band_ring_enabled)
    {
        RING_DEBUG(("RING: In band not enabled\n"));
        headsetPlayTone(app, tone_type_ring);
    }
    else
    {
        /* in band ring enabled at the AG - don't play local ring */
        if (app->a2dp_state == avHeadsetA2dpStreaming)
        {
            /* If the AV audio has not already been stopped then stop it now.
               Only if AG and A2DP source aren't same device. */
            if (!headsetIsA2dpSourceAnAg(app))
                avHeadsetAvStreamStop(app, TRUE);
        }
    }
}


/*****************************************************************************/
void hfpHeadsetHandleInBandRingInd(headsetTaskData *app, const HFP_IN_BAND_RING_IND_T *ind)
{
    /* Update the local flag */
    app->in_band_ring_enabled = ind->ring_enabled;
}

⌨️ 快捷键说明

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