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

📄 hfp_headset_ring.c

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

FILE NAME
    hfp_headset_ring.c

DESCRIPTION
    

NOTES

*/


/****************************************************************************
    Header files
*/
#include "headset_private.h"
#include "hfp_headset_ring.h"
#include "av_headset_kalimba.h"
#include "av_headset_controls.h"
#include "cvc_headset.h"

#include <connection.h>
#include <hfp.h>
#include <pcm.h>
#include <file.h>
#include <codec.h>
#include <panic.h>

static const audio_note audio_ring[] = {

    AUDIO_TEMPO(120), AUDIO_VOLUME(128), AUDIO_TIMBRE(sine),

    AUDIO_NOTE(C5, QUAVER),

    AUDIO_NOTE(D5, QUAVER),
    
    AUDIO_NOTE(E5, QUAVER),
    
    AUDIO_NOTE(F5, QUAVER),
    
    AUDIO_NOTE(G5, QUAVER),
    
    AUDIO_NOTE(A5, QUAVER),
    
    AUDIO_NOTE(B5, QUAVER),
    
    AUDIO_NOTE(C6, QUAVER),

    AUDIO_END 
};

static const audio_note audio_error[] = {

    AUDIO_TEMPO(120), AUDIO_VOLUME(128), AUDIO_TIMBRE(sine),

    AUDIO_NOTE(B4, MINIM),

    AUDIO_END 
};

/****************************************************************************
NAME    
    hfpHeadsetHandleRingInd
    
DESCRIPTION
    Received a RING indication from the AG.

RETURNS
    void
*/
void hfpHeadsetHandleRingInd(headsetTaskData *app, const HFP_RING_IND_T *ind)
{
    /* TODO: B-4373 how do we support multiple instances */
    ind = ind;
    
    /* If in HSP mode use rings as indication of incoming call */
    if ((app->profile_connected == hfp_headset_profile) && (app->hfp_state == headsetConnected))
    {
        app->hfp_state = headsetIncomingCallEstablish;
        app->active_profile = hfp_active;
    }

    /* Check to see if we should be playing a ring tone and if so play it */
    if (!app->in_band_ring_enabled)
    {
        DEBUG(("In band not enabled\n"));
        hfpHeadsetPlayRingTone(app, default_ring);
    }
    /* else - in band ring enabled at the AG - don't play local ring */
}

/****************************************************************************
NAME    
    hfpHeadsetPlayRingTone
    
DESCRIPTION
    Play a ringtone in the headset

RETURNS
    void
*/
void hfpHeadsetPlayRingTone(headsetTaskData *app, toneType type_of_tone)
{
    bool ring_success = FALSE;
    Source stream_source;
    
    if (app->pcm_audio_state != pcm_ringtone)
    {
        avHeadsetAvStreamStop(app,TRUE);

        app->pcm_audio_state = pcm_ringtone;

        /*
            Disconnect anything already connected to PCM slots 0 and 1
        */   
        StreamDisconnect(StreamPcmSource(0), StreamPcmSink(0));
        StreamDisconnect(StreamPcmSource(1), StreamPcmSink(1));

#ifndef INCLUDE_CVC		
        /*
            Reconfigure the DACs to output the ring to left and right
        */
        (void) PanicFalse(PcmRoute(0,VM_PCM_NONE,PCM_NO_SYNC));
        (void) PanicFalse(PcmRoute(1,VM_PCM_NONE,PCM_NO_SYNC));

#ifdef WOLFSON_CODEC
        (void) PanicFalse(PcmRateAndRoute(0, PCM_NO_SYNC, 8000, 8000, VM_PCM_EXTERNAL_I2S));
        CodecConfigure(app->codec_task,0);
#else
	    (void) PanicFalse(PcmRateAndRoute(0, PCM_NO_SYNC, 8000, 8000, VM_PCM_INTERNAL_A_AND_B));
#endif
#endif
		
#ifdef INCLUDE_CVC
		CvcHeadsetVolume(app->speaker_volume);
#else	
        avHeadsetUpdateHfVolume(app->codec_task, app->speaker_volume);
#endif
    }
    
    switch (type_of_tone)
    {
    case default_ring:
	stream_source = StreamAudioSource(audio_ring);
	break;
    case error_tone:
	stream_source = StreamAudioSource(audio_error);
	break;
    default:
	stream_source = StreamAudioSource(audio_error);
	break;
    }
    ring_success = StreamConnectAndDispose(stream_source, StreamPcmSink(0));
    
    DEBUG(("Ring success = %d\n", ring_success));
}


⌨️ 快捷键说明

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