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

📄 microphone.c

📁 蓝牙HANDFREE软件源代码
💻 C
字号:
#include "handsfree_private.h"
#include "handsfree.h"


#include <audio.h>


/* "Beep" to play whilst the microphone is muted */
static const audio_note mute_beep[] =
{
    AUDIO_TEMPO(80), AUDIO_VOLUME(32), AUDIO_TIMBRE(sine),
    AUDIO_NOTE(G5, QUAVER),
    AUDIO_END
};


/* Function used to play this beep */
static Delay delayMuteBeepPlay(TimerHandle h)
{
    /* keep the compiler happy */
    h = h;

    /* Store the ring handle so we can cancel the beeps */
    HFstate.AudioRingHandle = AudioPlay(mute_beep);

    /* Call this function again after this delay */
    return MUTE_BEEP_DELAY;
}


/*
    hfToggleMuteMicAction

    Toggle the mute state of the local microphone. While the mic is muted
    play "beeps" to indicate this to the user.
*/
void hfToggleMuteMicAction(void)
{
    uint16 want = HFstate.microphoneMute ^ 1;
    if(AudioMuteMicrophone(want))
        HFstate.microphoneMute = want;
        
    if (!HFstate.microphoneMute)
    {
        /* Stop playing beeps microphone no longer muted */
        (void) AudioStop(HFstate.AudioRingHandle);
        TimerCancelCallback(delayMuteBeepPlay);
    }
    else if (HFstate.connectState == scoConnected)
    {
        /* 
            If we have a SCO connected and the mic is muted play beeps 
            until it is unmuted. Reuse the ring handle for now.
        */
        (void) TimerAdd(D_mSEC(MUTE_BEEP_DELAY), delayMuteBeepPlay);        
    }
}


/*
    hfMicrophoneInd

    Indication of a change in the microphone gain setting. Could be 
    due to the AG sending us a mic gain AT command or the HF device
    attempting to set the mic gain locally
*/
void hfMicrophoneInd(const HS_MIC_IND_T *ind)
{
    /* Set the local microphone gain to this new value */
    hfHalSetMicrophoneGain(ind->gain);

    /* TODO call interface fun here */
}

⌨️ 快捷键说明

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