📄 audio.c
字号:
act_tone.descr_index = 0;
audio_buzzer ();
}
else
act_tone.status = NO_TONE;
break;
default:
/*
* switch buzzer on
*/
BZ_Enable ();
BZ_Volume (act_buzVolume);
BZ_Tone (act_tone.descr
[act_tone.descr_index].command_1);
#if defined (NEW_FRAME)
vsi_t_start (VSI_CALLER
CST_AUDIOTIMER,
act_tone.descr
[act_tone.descr_index++].length*60/13);
#else
vsi_t_start (VSI_CALLER
audio_handle,
act_tone.descr
[act_tone.descr_index++].length*60/13);
#endif
act_tone.status = BUZZER_ON;
break;
}
}
/*
+--------------------------------------------------------------------+
| PROJECT : GSM-PS (6103) MODULE : DRV_AUDIO |
| STATE : code ROUTINE : audio_audio |
+--------------------------------------------------------------------+
PURPOSE : Process an audio tone.
*/
LOCAL void audio_audio (void)
{
if (act_tone.status EQ NO_TONE)
return;
switch (act_tone.descr
[act_tone.descr_index].command_1)
{
case 0:
/*
* switch audio off
*/
#if defined (NEW_FRAME)
vsi_t_start (VSI_CALLER CST_AUDIOTIMER,
act_tone.descr
[act_tone.descr_index++].length*60/13);
#else
vsi_t_start (VSI_CALLER audio_handle,
act_tone.descr
[act_tone.descr_index++].length*60/13);
#endif
act_tone.status = TONE_SILENT;
break;
case 0xFFFF:
/*
* end of list
*/
if (act_tone.style EQ 2)
{
act_tone.descr_index = 0;
audio_audio ();
}
else
act_tone.status = NO_TONE;
break;
default:
/*
* switch audio tone on
*/
{
#if defined (RIV_AUDIO)
USHORT fa1 = act_tone.descr[act_tone.descr_index].command_1;
USHORT fa2 = act_tone.descr[act_tone.descr_index].command_2;
ULONG len = act_tone.descr[act_tone.descr_index].length;
t.tones[0].start_tone = 0;
t.tones[0].stop_tone = (USHORT) ((60 * len) / 13);
t.tones[0].frequency_tone = (fa1 >> 5) & 0x07ff;
t.tones[0].amplitude_tone = -((char) (fa1 & 0x001f));
t.tones[1].start_tone = 0;
t.tones[1].stop_tone = (USHORT) ((60 * len) / 13);
t.tones[1].frequency_tone = (fa2 >> 5) & 0x07ff;
t.tones[1].amplitude_tone = -((char) (fa2 & 0x001f));
t.tones[2].start_tone = 0;
// t.tones[2].stop_tone = 1; - NDH : Removed as this does not comply with the i/f spec
t.tones[2].stop_tone = (USHORT) ((60 * len) / 13);
t.tones[2].frequency_tone = NO_TONE;
t.tones[2].amplitude_tone = 0;
t.frame_duration = (USHORT) ((60 * len) / 13);
t.sequence_duration = (USHORT) ((60 * len) / 13); /* why 120 ??? -> changed to 60 */
t.period_duration = (USHORT) ((60 * len) / 13); /* -"- */
t.repetition = 1;
#ifdef _TARGET_
/*
* This function seems only to be available on target. (db / 2001-07-16)
*/
audio_tones_start(&t,riv_audio_rp);
#endif
#else
#ifndef FF_GTI
PALLOC (audio, MMI_TONE_REQ);
/*
* Convert TDMA frames to 20 ms -> 3/13
*/
audio->d_k_x1_t0 = act_tone.descr[act_tone.descr_index].command_1;
audio->d_k_x1_t1 = act_tone.descr[act_tone.descr_index].command_2;
audio->d_k_x1_t2 = 0;
audio->d_pe_rep = 1;
audio->d_pe_off = (6*act_tone.descr[act_tone.descr_index].length) / 13;
audio->d_se_off = (6*act_tone.descr[act_tone.descr_index].length) / 13;
audio->d_bu_off = (3*act_tone.descr[act_tone.descr_index].length) / 13;
audio->d_t0_on = 0;
audio->d_t0_off = (3*act_tone.descr[act_tone.descr_index].length) / 13;
audio->d_t1_on = 0;
audio->d_t1_off = (3*act_tone.descr[act_tone.descr_index].length) / 13;
audio->d_t2_on = 0;
audio->d_t2_off = 0;
PSENDX (L1, audio);
#endif /* FF_GTI */
#endif
#if defined (NEW_FRAME)
vsi_t_start (VSI_CALLER CST_AUDIOTIMER,
act_tone.descr
[act_tone.descr_index++].length*60/13);
#else
vsi_t_start (VSI_CALLER audio_handle,
act_tone.descr
[act_tone.descr_index++].length*60/13);
#endif
act_tone.status = TONE_ON;
}
break;
}
}
/*
+--------------------------------------------------------------------+
| PROJECT : GSM-PS (6103) MODULE : DRV_AUDIO |
| STATE : code ROUTINE : audio_UlMute |
+--------------------------------------------------------------------+
PURPOSE : This function mutes the uplink path.
*/
LOCAL void audio_UlMute (UBYTE mute)
{
if (mute)
{
#ifdef ALR
ABB_UlMute (1);
#else
VG_UlVolume (0);
#endif
}
else
{
#ifdef ALR
ABB_UlMute (0);
#else
VG_UlVolume (act_micVolume);
#endif
}
}
/*
+--------------------------------------------------------------------+
| PROJECT : GSM-PS (6103) MODULE : DRV_AUDIO |
| STATE : code ROUTINE : audio_set_tty |
+--------------------------------------------------------------------+
PURPOSE : This function (de)activates the TTY codec.
*/
#if defined (FF_TTY) || defined (_TTY_SIMU)
GLOBAL void audio_set_tty (UBYTE tty)
{
if (tty)
{
#if defined (RIV_AUDIO) && !defined (_TTY_SIMU)
T_AUDIO_MODE_SAVE audio_mode;
T_RV_RETURN ret = {NOT_PRESENT_16BIT, NULL};
T_AUDIO_RET audio_ret;
if (!tty_state)
{
tty_cfg.Mode = TTY_EXT_START;
tty_cfg.ThresholdRead = tty_cfg.ThreshHoldWrite = 0;
ret.callback_func = audio_save_def_return;
strcpy (audio_mode.audio_mode_filename, audio_mode_name_def);
audio_ret = audio_mode_save (&audio_mode, ret);
if (audio_ret NEQ AUDIO_OK)
{
TRACE_EVENT_P1 ("Error AUDIO MODE SAVE def: %d", (int)audio_ret);
}
else
{
TRACE_EVENT ("AUDIO MODE SAVE def");
}
}
else
{
TRACE_EVENT ("TTY running");
}
#else
TRACE_EVENT ("TTY start");
#endif
}
else
{
#if defined (RIV_AUDIO) && !defined (_TTY_SIMU)
T_RV_RETURN ret = {NOT_PRESENT_16BIT, NULL};
T_AUDIO_RET audio_ret;
if (tty_state)
{
ret.callback_func = audio_tty_return;
tty_cfg.ThresholdRead = tty_cfg.ThreshHoldWrite = 0;
tty_cfg.Mode = TTY_STOP;
audio_ret = audio_tty_set_config (&tty_cfg, &ret);
if (audio_ret NEQ AUDIO_OK)
{
TRACE_EVENT_P1 ("Error TTY stop: %d", (int)audio_ret);
}
}
else
{
TRACE_EVENT ("TTY ended");
}
#else
TRACE_EVENT ("TTY stop");
#endif
}
}
#if defined (RIV_AUDIO) AND !defined (_TTY_SIMU)
LOCAL void audio_tty_return (void *tty_result)
{
T_AUDIO_MODE_LOAD audio_mode;
T_RV_RETURN ret = {NOT_PRESENT_16BIT, NULL};
T_AUDIO_RET audio_ret;
if (((T_AUDIO_TTY_STATUS *)tty_result)->status NEQ AUDIO_OK)
{
TRACE_EVENT_P1 ("Error TTY callback: %d",
(int)((T_AUDIO_TTY_STATUS *)tty_result)->status);
}
tty_state = FALSE;
tty_cfg.Mode = TTY_STOP;
TRACE_EVENT ("TTY end");
ret.callback_func = audio_load_return;
strcpy (audio_mode.audio_mode_filename, audio_mode_name_def);
audio_ret = audio_mode_load (&audio_mode, ret);
if (audio_ret NEQ AUDIO_OK)
{
TRACE_EVENT_P1 ("Error AUDIO MODE LOAD def: %d", (int)audio_ret);
}
}
LOCAL void audio_save_def_return (void *result)
{
T_AUDIO_MODE_LOAD audio_mode;
T_RV_RETURN load_ret = {NOT_PRESENT_16BIT, NULL};
T_AUDIO_RET audio_ret;
if (((T_AUDIO_SAVE_DONE *)result)->status NEQ AUDIO_OK)
{
TRACE_EVENT_P1 ("Error AUDIO MODE SAVE def callback: %d",
(int)((T_AUDIO_SAVE_DONE *)result)->status);
}
else
{
TRACE_EVENT ("AUDIO def saved");
load_ret.callback_func = audio_load_return;
strcpy (audio_mode.audio_mode_filename, audio_mode_name_tty);
audio_ret = audio_mode_load (&audio_mode, load_ret);
if (audio_ret NEQ AUDIO_OK)
{
TRACE_EVENT_P1 ("Error AUDIO MODE LOAD TTY: %d", (int)audio_ret);
}
}
}
LOCAL void audio_load_return (void *result)
{
if (((T_AUDIO_LOAD_DONE *)result)->status NEQ AUDIO_OK)
{
TRACE_EVENT_P1 ("Error AUDIO MODE LOAD callback: %d",
(int)((T_AUDIO_LOAD_DONE *)result)->status);
}
else
{
T_RV_RETURN ret = {NOT_PRESENT_16BIT, NULL};
T_AUDIO_RET audio_ret;
if (!tty_state AND tty_cfg.Mode EQ TTY_EXT_START)
{
ret.callback_func = audio_tty_return;
audio_ret = audio_tty_set_config (&tty_cfg, &ret);
if (audio_ret NEQ AUDIO_OK)
{
TRACE_EVENT_P1 ("Error TTY set: %d", (int)audio_ret);
}
else
{
tty_state = TRUE;
TRACE_EVENT ("AUDIO TTY loaded & start");
}
}
else if (!tty_state AND tty_cfg.Mode EQ TTY_STOP)
{
TRACE_EVENT ("AUDIO def loaded");
}
}
}
#endif
#endif
/*******************************************************************
* *
* PART II: Simulation for Windows *
* *
*******************************************************************/
#if defined (_SIMULATION_)
/*
* Dummies for driver calls
*/
LOCAL void BZ_Init (void)
{
}
LOCAL void BZ_Enable (void)
{
}
LOCAL void BZ_Disable (void)
{
}
LOCAL void BZ_Tone (int f)
{
}
LOCAL void BZ_Volume (int v)
{
}
#ifdef ALR
LOCAL void ABB_DlVolume (UBYTE v)
{
}
LOCAL void ABB_DlMute (UBYTE mute)
{
}
LOCAL void ABB_UlMute (UBYTE value)
{
}
LOCAL void ABB_SideTone (UBYTE v)
{
}
#else
LOCAL void VG_UlVolume (UBYTE v)
{
}
LOCAL void VG_DlVolume (UBYTE v)
{
}
LOCAL void VG_DlMute (UBYTE mute)
{
}
LOCAL void VG_SideTone (UBYTE v)
{
}
#endif
#endif
#if defined (RIV_AUDIO)
void audio_riv_audio_cb (void *buf)
{
/* nothing to do for this time */
}
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -