www.pudn.com > headset.rar > mute.c


#include "demohs.h"

#include <audio.h>


static const audio_note mute_beep[] =
{
AUDIO_TEMPO(80), AUDIO_VOLUME(32), AUDIO_TIMBRE(sine),
AUDIO_NOTE(G5, QUAVER),
AUDIO_END
};


static Delay delayMuteBeepPlay(TimerHandle h)
{
h = h;
hsState.AudioRingHandle = AudioPlay(mute_beep);
return MUTE_BEEP_DELAY;
}


/*
muteRequest

Toggles the current mute state i.e. if mute was on turns it off and vice versa
*/
void muteRequest(void)
{
uint16 want = hsState.isMuted ^ 1;
if(AudioMuteMicrophone(want))
hsState.isMuted = want;

if (!hsState.isMuted)
{
/* Stop playing beeps */
(void) AudioStop(hsState.AudioRingHandle);
(void) TimerCancelCallback(delayMuteBeepPlay);
}
else if (hsState.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);
}
}