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

📄 hfp_headset_indicators.c

📁 CSR蓝牙芯片 无线蓝牙耳机的语音网关程序 蓝牙耳机程序已经上传
💻 C
字号:
/****************************************************************************
Copyright (C) Cambridge Silicon Radio Ltd. 2004

FILE NAME
    hfpHeadset_indicators.c

DESCRIPTION
    

NOTES

*/


/****************************************************************************
    Header files
*/
#include "headset_private.h"
#include "hfp_headset_indicators.h"
#include "hfp_headset_sco.h"
#include "av_headset_kalimba.h"

#include <panic.h>
#include <pcm.h>


/****************************************************************************
NAME    
    hfpHeadsetHandleInBandRingInd
    
DESCRIPTION
    In band ring indicator telling us whether the AG will use an in band 
    ring or not.

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


/****************************************************************************
NAME    
    hfpHeadsetHandleServiceIndicator
    
DESCRIPTION
    HFP service indicator update.

RETURNS
    void
*/
void hfpHeadsetHandleServiceIndicator(headsetTaskData *app, const HFP_SERVICE_IND_T *ind)
{
    /* For now we're ignoring these as we have no way of displaying the indicator. */
    app = app;
    ind = ind;
}


/****************************************************************************
NAME    
    hfpHeadsetHandleCallIndicator
    
DESCRIPTION
    HFP call indicator update.

RETURNS
    void
*/
void hfpHeadsetHandleCallIndicator(headsetTaskData *app, const HFP_CALL_IND_T *ind)
{
    DEBUG(("Call Ind = %d\n",ind->call));
    if (ind->call)
    {
        /* Active call */
        app->hfp_state = headsetActiveCall;
        
        /* Deal with the case where a phone has a SCO link open during an incoming call
           but doesn't support inband ring tones */
        if (app->sco_sink && (app->pcm_audio_state == pcm_ringtone))
        {
            app->pcm_audio_state = pcm_sco;
            (void) hfpSetupScoRouting(app);
        }
    }
    else
    {
        /* If an active call has been released update state accordingly */
        if (app->hfp_state == headsetActiveCall)
        {
            app->hfp_state = headsetConnected;
            DEBUG(("state connected\n"));
        }
    }
}


/****************************************************************************
NAME    
    hfpHeadsetHandleCallSetupIndicator
    
DESCRIPTION
    HFP call setup indicator update.

RETURNS
    void
*/
void hfpHeadsetHandleCallSetupIndicator(headsetTaskData *app, const HFP_CALL_SETUP_IND_T *ind)
{
    /* TODO: B-4373 how do we support multiple instances */
    headsetState old_hfp_state = app->hfp_state;
    headsetState new_hfp_state;
    
    /* Update the local state according to the value in this indicator */
    DEBUG(("Call Setup Ind = %d\n",ind->call_setup));
    DEBUG(("old hfp_state = %d\n",app->hfp_state));
    switch (ind->call_setup)
    {
    case hfp_no_call_setup:
        if (app->hfp_state != headsetActiveCall && app->hfp_state != headsetConnecting)
            app->hfp_state = headsetConnected;
        break;

    case hfp_incoming_call_setup:
		if (app->hfp_state != headsetActiveCall)
        {
			app->hfp_state = headsetIncomingCallEstablish;
            app->active_profile = hfp_active;
        }
        break;

    case hfp_outgoing_call_setup:
    case hfp_outgoing_call_alerting_setup:
        app->hfp_state = headsetOutgoingCallEstablish;
        break;

    default:
        /* Invalid call setup indicator value received. */
        DEBUG(("PANIC!\n"));
        Panic();
    }
    
    DEBUG(("new hfp_state = %d\n",app->hfp_state));
    new_hfp_state = app->hfp_state;
    
    if ((old_hfp_state == headsetIncomingCallEstablish) && (new_hfp_state == headsetConnected) &&
        (app->pcm_audio_state == pcm_ringtone))
    {
        /* Noone answered a locally generated ring tone so restart AV if necessary */
        (void) MessageCancelAll(getAppTask(), APP_MUSIC_RESTART_IND);
        MessageSendLater(getAppTask(), APP_MUSIC_RESTART_IND, 0, (uint32) MUSIC_RESTART_DELAY);
    }
}

⌨️ 快捷键说明

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