Esempio n. 1
0
void aud_set_active_tone_volume(void)
{
   kal_uint8 volume;
   kal_uint8 mode=aud_context_p->audio_mode;

   /* tone follow speech volume */
   volume = aud_get_volume_gain(mode, AUD_VOLUME_SPH, aud_get_volume_level(mode, AUD_VOLUME_SPH));
   aud_tone_set_output_volume(volume, volume);
}
/*****************************************************************************
 * FUNCTION
 *  aud_media_play_by_id_req_hdlr
 * DESCRIPTION
 *  
 * PARAMETERS
 *  ilm_ptr     [?]     
 * RETURNS
 *  void
 *****************************************************************************/
void aud_media_play_by_id_req_hdlr(ilm_struct *ilm_ptr)
{

    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/    
    kal_uint8 audio_id;
    kal_uint8 audio_out_device;    
    kal_uint8 volume;
    media_aud_play_by_id_req_struct *req_p = (media_aud_play_by_id_req_struct*) ilm_ptr->local_para_ptr;
    media_aud_play_by_id_cnf_struct *cnf_p = NULL;

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    audio_id = req_p->audio_id;

    if (req_p->output_path == AUDIO_DEVICE_SPEAKER2)
    {
        /* Use default configuration */
        aud_cfg_audio_out_device(audio_id, &audio_out_device);
    }
    else
    {
        /* Use user-specified path */
        audio_out_device = req_p->output_path;
    }

    if (audio_id <= TONE_KEY_CLICK)
    {
        aud_keytone_stop();

        /* Update keytone volume */
        volume = aud_get_volume_gain(aud_context_p->audio_mode, AUD_VOLUME_KEY, req_p->volume);
        aud_keytone_set_output_volume(volume, 0);
    
        aud_keytone_play(audio_id, audio_out_device, req_p->play_style);
    }
    else if ((audio_id > TONE_KEY_CLICK) && (audio_id <= MAX_TONE_ID))
    {
        /* if keytone is playing, stop it */
        aud_keytone_stop();

        if (req_p->play_style == DEVICE_AUDIO_PLAY_INFINITE)
        {
            aud_context_p->tone_playing = KAL_TRUE;
        }

        /* Update tone volume */
        volume = aud_get_volume_gain(aud_context_p->audio_mode, AUD_VOLUME_CTN, req_p->volume);
        aud_tone_set_output_volume(volume, 0);

        aud_tone_play(audio_id, audio_out_device);
    }

    cnf_p = (media_aud_play_by_id_cnf_struct*)
        construct_local_para(sizeof(media_aud_play_by_id_cnf_struct), TD_CTRL);

    cnf_p->result = MED_RES_OK;

    aud_send_ilm(ilm_ptr->src_mod_id, MSG_ID_MEDIA_AUD_PLAY_BY_ID_CNF, cnf_p, NULL);

}