📄 aud_post_process.c
字号:
/*****************************************************************************
* Copyright Statement:
* --------------------
* This software is protected by Copyright and the information contained
* herein is confidential. The software may not be copied and the information
* contained herein may not be used or disclosed except with the written
* permission of MediaTek Inc. (C) 2005
*
* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
*
* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
*
* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
*
*****************************************************************************/
/*******************************************************************************
* Filename:
* ---------
* aud_post_process.c
*
* Project:
* --------
* Maui
*
* Description:
* ------------
* This file is to handle all messages for post audio process
* (include time stretch and 3D effect currently)
*
* Author:
* -------
* -------
*
*==============================================================================
* HISTORY
* Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
*------------------------------------------------------------------------------
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
*------------------------------------------------------------------------------
* Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
*==============================================================================
*******************************************************************************/
#ifndef MED_NOT_PRESENT
/*==== INCLUDES =========*/
/* system includes */
#include "kal_release.h"
#include "kal_trace.h"
#include "stack_common.h"
#include "stack_msgs.h"
#include "app_ltlcom.h" /* Task message communiction */
#include "syscomp_config.h"
#include "task_config.h" /* Task creation */
#include "app_buff_alloc.h" /* Declaration of buffer management API */
#include "stacklib.h" /* Basic type for dll, evshed, stacktimer */
#include "event_shed.h" /* Event scheduler */
#include "stack_timer.h" /* Stack timer */
/* global includes */
#include "l1audio.h"
#include "device.h"
#include "custom_equipment.h"
#include "custom_nvram_editor_data_item.h"
/* local includes */
#include "med_global.h"
#include "med_main.h"
#include "aud_defs.h"
#include "med_struct.h"
#include "med_api.h"
#include "med_context.h"
#include "aud_main.h"
#include "med_main.h"
#include "med_utility.h"
#ifdef __AUD_TRACE_ON__
#include "med_trc.h"
#endif
#ifdef __MED_APP_MOD__
/*
* Local Variable
*/
aud_app_context_struct *aud_app_cntx_p = &med_context.app_context;
/*
* Local Function
*/
static kal_uint16 aud_stretch_get_mode_from_speed(kal_uint16 speed);
static void aud_3d_pause_effect(void);
static void aud_3d_resume_effect(void);
/*
* Global Variable
*/
/*
* Global Function
*/
#define BEGIN_AUD_POST_PROCESS_FUNCTION_DEF
/*****************************************************************************
* FUNCTION
* aud_post_process_startup
* DESCRIPTION
* This function is to initialize the audio post process interface in media task
* PARAMETERS
* void
* RETURNS
* kal_bool
*****************************************************************************/
kal_bool aud_post_process_startup(void)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
aud_app_cntx_p->state_stretch = AUD_EFFECT_OFF;
aud_app_cntx_p->state_3d = AUD_EFFECT_UNSET;
return KAL_TRUE;
}
/*****************************************************************************
* FUNCTION
* aud_stretch_check_stream_format_req_hdlr
* DESCRIPTION
* This function is to check format for audio data stream
* PARAMETERS
* ilm_ptr [?]
* RETURNS
* void
*****************************************************************************/
void aud_stretch_check_stream_format_req_hdlr(ilm_struct *ilm_ptr)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
kal_bool is_support;
STFSAL ext_file;
FSAL_Status fsal_ret;
media_stretch_check_stream_format_req_struct *msg_p;
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
msg_p = (media_stretch_check_stream_format_req_struct*) ilm_ptr->local_para_ptr;
FSAL_Direct_SetRamFileSize(&ext_file, msg_p->size);
fsal_ret = FSAL_Open(&ext_file, (void*)msg_p->data_p, FSAL_ROMFILE);
if (fsal_ret == FSAL_OK)
{
/* Check if the file can play with time stretch on */
is_support = AudioPP_IsTSSupport((Media_Format) msg_p->format, &ext_file);
FSAL_Close(&ext_file);
if (is_support)
{
aud_app_set_result(MED_RES_OK);
EFFECT_SET_EVENT(TS_EVT_CHECK);
return;
}
}
aud_app_set_result(MED_RES_FAIL);
EFFECT_SET_EVENT(TS_EVT_CHECK);
}
/*****************************************************************************
* FUNCTION
* aud_stretch_check_file_format_req_hdlr
* DESCRIPTION
* This function is to check format for audio file
* PARAMETERS
* ilm_ptr [?]
* RETURNS
* void
*****************************************************************************/
void aud_stretch_check_file_format_req_hdlr(ilm_struct *ilm_ptr)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
kal_int16 format;
kal_bool is_support;
STFSAL ext_file;
FSAL_Status fsal_ret;
media_stretch_check_file_format_req_struct *msg_p;
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
msg_p = (media_stretch_check_file_format_req_struct*) ilm_ptr->local_para_ptr;
/* Get file audio type from extension */
format = med_get_media_type(msg_p->file_path);
/* get file handle */
fsal_ret = FSAL_Open(&ext_file, (void*)msg_p->file_path, FSAL_READ);
if (fsal_ret == FSAL_OK)
{
/* Check if the file can play with time stretch on */
is_support = AudioPP_IsTSSupport((Media_Format) format, &ext_file);
FSAL_Close(&ext_file);
if (is_support)
{
aud_app_set_result(MED_RES_OK);
}
else
{
aud_app_set_result(MED_RES_UNSUPPORTED_SPEED);
}
}
else if (fsal_ret == FSAL_OPEN_ERROR)
{
aud_app_set_result(MED_RES_OPEN_FILE_FAIL);
}
else
{
aud_app_set_result(MED_RES_FAIL);
}
EFFECT_SET_EVENT(TS_EVT_CHECK);
}
/*****************************************************************************
* FUNCTION
* aud_stretch_set_speed_req_hdlr
* DESCRIPTION
* This function is the request hanlder of setting play speed for all audio
* PARAMETERS
* ilm_ptr [?]
* RETURNS
* void
*****************************************************************************/
void aud_stretch_set_speed_req_hdlr(ilm_struct *ilm_ptr)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
media_stretch_set_speed_req_struct *msg_p;
kal_int32 set_result;
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
msg_p = (media_stretch_set_speed_req_struct*) ilm_ptr->local_para_ptr;
/* Set time stretch speed */
set_result = aud_stretch_set_speed(msg_p->speed);
aud_app_set_result(set_result);
EFFECT_SET_EVENT(TS_EVT_SET);
}
/*****************************************************************************
* FUNCTION
* aud_stretch_set_speed
* DESCRIPTION
* This function is the interface of setting play speed for all audio for media task
* PARAMETERS
* speed [IN]
* RETURNS
* void
*****************************************************************************/
kal_int32 aud_stretch_set_speed(kal_uint16 speed)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
kal_uint16 mode;
Media_Status ts_result;
kal_int32 set_result;
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
/* Convert speed to mode */
if ((mode = aud_stretch_get_mode_from_speed(speed)) != 0)
{
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -