📄 audio.c
字号:
#else
VG_DlVolume (in_Amplf); /* output volume */
VG_SideTone (175);
#endif
act_speakerVolume = in_Amplf;
}
else if (in_DeviceID EQ AUDIO_BUZZER)
{
act_buzVolume = in_Amplf;
}
else
{
return DRV_INVALID_PARAMS;
}
return DRV_OK;
}
/*
+--------------------------------------------------------------------+
| PROJECT : GSM-PS (6103) MODULE : DRV_AUDIO |
| STATE : code ROUTINE : audio_GetAmplf |
+--------------------------------------------------------------------+
PURPOSE : This function is used to get the amplification for the
device identified by the parameter in_DeviceID.
In the case of a speaker this is the volume, for a
microphone - the pre-amplifier that regulates the
sensitivity of the microphone. The valid range depends on
the hardware used.If the specified device is unknown the
function returns DRV_INVALID_PARAMS.
*/
GLOBAL UBYTE audio_GetAmplf (UBYTE in_DeviceID, UBYTE* out_Amplf)
{
if (in_DeviceID EQ AUDIO_MICROPHONE)
{
*out_Amplf = act_micVolume;
}
else if (in_DeviceID EQ AUDIO_SPEAKER)
{
*out_Amplf = act_speakerVolume;
}
else if (in_DeviceID EQ AUDIO_BUZZER)
{
*out_Amplf = act_buzVolume;
}
else
{
return DRV_INVALID_PARAMS;
}
return DRV_OK;
}
/*
+--------------------------------------------------------------------+
| PROJECT : GSM-PS (6103) MODULE : DRV_AUDIO |
| STATE : code ROUTINE : audio_PlaySoundID |
+--------------------------------------------------------------------+
PURPOSE : This function is used to play a sound or melody. The
function returns immediately after the "play process" has
been activated. It is implementation dependent if the
device/driver supports playing multiple sounds simultan-
eously, i.e. accepting multiple calls of audio_PlaySoundID().
If the calling process should be notified when the sound has
stopped playing automatically, the signal AUDIO_SIGTYPE_
SOUNDEND must be set using the audio_SetSignal() function.
If the special driver implementation or the device does
not support volume control, the driver ignores the value.
If the sound can be played, the function returns DRV_OK.
If the device is currently playing the sound identified by
the parameter in_SoundID, the function returns DRV_INPROCESS.
If the device/driver is currently playing a sound, but does
not support playing multiple sounds simultaneously, the
driver returns DRV_INPROCESS.
*/
GLOBAL UBYTE audio_PlaySoundID (UBYTE in_DeviceID,
UBYTE in_SoundID,
BYTE in_RelVolume,
UBYTE in_Repeats)
{
/*
* switch off current tone
*/
switch (act_tone.status)
{
case BUZZER_ON:
BZ_Disable ();
/*
* No Break
*/
case TONE_ON:
case BUZZER_SILENT:
case TONE_SILENT:
#if defined (NEW_FRAME)
vsi_t_stop (VSI_CALLER CST_AUDIOTIMER);
#else
vsi_t_stop (VSI_CALLER audio_handle);
#endif
break;
default:
break;
}
/*
* configure new tone
*/
if (in_SoundID EQ TONES_KEYBEEP) /* that is keybeep */
{
#if defined (RIV_AUDIO)
beep.frequency_beep[0] = ((F_697) >> 5) & 0x07ff;
beep.amplitude_beep[0] = -((char) ((F_697) & 0x001f));
beep.frequency_beep[1] = ((F_697) >> 5) & 0x07ff;
beep.amplitude_beep[1] = -((char) ((F_697) & 0x001f));
beep.duration = 120;
#ifdef _TARGET_
/*
* This function seems only to be available on target. (db / 2001-07-16)
*/
return audio_keybeep_start(beep,riv_audio_rp);
#endif
#else
/* MPHC is not present in GTI case */
#ifndef FF_GTI
PALLOC (keybeep, MMI_KEYBEEP_REQ);
keybeep->d_k_x1_kt0 = F_697;
keybeep->d_k_x1_kt1 = F_697;
keybeep->d_dur_kb = 6; /* equal 120 ms */
PSENDX (L1, keybeep);
#endif /* FF_GTI */
#endif
}
else
{
act_tone.call_tone = in_SoundID;
act_tone.status = BUZZER_SILENT;
act_tone.type = (UBYTE)TONE_TYPE[in_SoundID];
act_tone.descr = (T_DESCR *)TONE_DESCR[in_SoundID];
act_tone.style = in_Repeats;
act_tone.descr_index = 0;
if (act_tone.type EQ BUZZER)
{
act_tone.volume = act_buzVolume;
audio_buzzer ();
}
else
{
act_tone.volume = act_speakerVolume;
audio_audio ();
}
}
return DRV_OK;
}
/*
+--------------------------------------------------------------------+
| PROJECT : GSM-PS (6103) MODULE : DRV_AUDIO |
| STATE : code ROUTINE : audio_PlaySoundbyImage |
+--------------------------------------------------------------------+
PURPOSE : This function is used to play a sound or melody. The
image of the sound/melody is passed to the driver (the
sound image format is implmementation dependent).
*/
GLOBAL UBYTE audio_PlaySoundbyImage (UBYTE in_DeviceID,
void * in_SoundImagePtr,
BYTE in_RelVolume,
UBYTE in_Repeats)
{
return DRV_OK;
}
/*
+--------------------------------------------------------------------+
| PROJECT : GSM-PS (6103) MODULE : DRV_AUDIO |
| STATE : code ROUTINE : audio_StopSoundbyID |
+--------------------------------------------------------------------+
PURPOSE : This function is used to manually stop playing a sound
or melody. When a sound is stopped manually, no signal is
created as to whether or not the signal AUDIO_SIGTYP_SOUNDEND
has been defined. If the function could stop playing the
specified sound, the function returns DRV_OK. If the device
is unknown or does not support this function or the specified
sound ID is invalid, the function returns DRV_INVALID_PARAMS.
*/
GLOBAL UBYTE audio_StopSoundbyID (UBYTE in_DeviceID,
UBYTE in_SoundID)
{
/*
* switch off current tone
*/
switch (act_tone.status)
{
case BUZZER_ON:
BZ_Disable ();
/*
* No Break
*/
case TONE_ON:
case BUZZER_SILENT:
case TONE_SILENT:
/* Stop timer for reload */
#if defined (NEW_FRAME)
vsi_t_stop (VSI_CALLER CST_AUDIOTIMER);
#else
vsi_t_stop (VSI_CALLER audio_handle);
#endif
if (act_tone.status EQ TONE_ON)
{
/*
* stop the current playing audio tone immediately
*/
#if defined (RIV_AUDIO)
#ifdef _TARGET_
/*
* This function seems only to be available on target. (db / 2001-07-16)
*/
audio_tones_stop(riv_audio_rp);
#endif
#else
#ifndef FF_GTI
PALLOC (audio, MMI_TONE_REQ);
audio->d_k_x1_t0 = 0;
audio->d_k_x1_t1 = 0;
audio->d_k_x1_t2 = 0;
audio->d_pe_rep = 1;
audio->d_pe_off = 0;
audio->d_se_off = 0;
audio->d_bu_off = 0;
audio->d_t0_on = 0;
audio->d_t0_off = 0;
audio->d_t1_on = 0;
audio->d_t1_off = 0;
audio->d_t2_on = 0;
audio->d_t2_off = 0;
PSENDX (L1, audio);
#endif /* FF_GTI */
#endif
}
act_tone.status = NO_TONE;
break;
default:
break;
}
return DRV_OK;
}
/*
+--------------------------------------------------------------------+
| PROJECT : GSM-PS (6103) MODULE : DRV_AUDIO |
| STATE : code ROUTINE : audio_StopSoundbyImage |
+--------------------------------------------------------------------+
PURPOSE : This function is used to manually stop playing a sound
or melody. When a sound is stopped manually, no signal is
created as to whether or not the signal AUDIO_SIGTYP_SOUNDEND
has been defined. If the function could stop playing the
specified sound image, the function returns DRV_OK.
If the device is unknown or does not support this function
or the specified sound ID is invalid, the function
returns DRV_INVALID_PARAMS.
*/
GLOBAL UBYTE audio_StopSoundbyImage (UBYTE in_DeviceID,
void * in_SoundImagePtr)
{
return DRV_OK;
}
/*
+--------------------------------------------------------------------+
| PROJECT : GSM-PS (6103) MODULE : DRV_AUDIO |
| STATE : code ROUTINE : audio_SetSignal |
+--------------------------------------------------------------------+
PURPOSE : This function is used to defines a single signal or multiple
signals that is/are indicated to the process when the
event identified in the signal information data type as
SignalType occurs. To remove a signal call the function
audio_ResetSignal(). If one of the parameters of the
signal information data is invalid, the function returns
DRV_INVALID_PARAMS. If no signal call-back function has
been defined at the time of initialization, the driver
returns DRV_SIGFCT_NOTAVAILABLE.
*/
GLOBAL UBYTE audio_SetSignal (drv_SignalID_Type * in_SignalIDPtr)
{
return DRV_OK;
}
/*
+--------------------------------------------------------------------+
| PROJECT : GSM-PS (6103) MODULE : DRV_AUDIO |
| STATE : code ROUTINE : audio_ResetSignal |
+--------------------------------------------------------------------+
PURPOSE : This function is used to remove a previously set single
multiple signals. The signals that are removed are identified
by the Signal Information Data element Signal Type. All other
elements of the signal information data must be identical
to the signal(s) that is/are to be removed.
*/
GLOBAL UBYTE audio_ResetSignal (drv_SignalID_Type * in_SignalIDPtr)
{
return DRV_OK;
}
/*
+--------------------------------------------------------------------+
| PROJECT : GSM-PS (6103) MODULE : DRV_AUDIO |
| STATE : code ROUTINE : audio_timeout |
+--------------------------------------------------------------------+
PURPOSE : This function is used after timeout of the audio timer.
*/
#if defined (NEW_FRAME)
GLOBAL void audio_timeout (USHORT index)
#else
GLOBAL void audio_timeout (T_VSI_THANDLE handle)
#endif
{
#if defined (NEW_FRAME)
if (index EQ CST_AUDIOTIMER)
#else
if (handle EQ audio_handle)
#endif
{
/*ccc
* only if it is the audio timer
*/
if (act_tone.type EQ BUZZER)
audio_buzzer ();
else
audio_audio ();
}
}
/*
+--------------------------------------------------------------------+
| PROJECT : GSM-PS (6103) MODULE : DRV_AUDIO |
| STATE : code ROUTINE : audio_buzzer |
+--------------------------------------------------------------------+
PURPOSE : Process a buzzer tone.
*/
LOCAL void audio_buzzer (void)
{
if (act_tone.status EQ NO_TONE)
return;
switch (act_tone.descr
[act_tone.descr_index].command_1)
{
case 0:
/*
* switch buzzer off
*/
BZ_Disable ();
#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_SILENT;
break;
case 0xFFFE:
/*
* switch buzzer on continously
*/
BZ_Enable ();
BZ_Volume (act_buzVolume);
BZ_Tone (act_tone.descr
[act_tone.descr_index].command_1);
act_tone.status = BUZZER_ON;
break;
case 0xFFFF:
/*
* end of list
*/
BZ_Disable ();
if (act_tone.style EQ 2)
{
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -