volume_setting.cpp
上传用户:gelin96
上传日期:2017-01-08
资源大小:20993k
文件大小:36k
- /*****************************************************************************
- * 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:
- * ---------
- * volume_setting.cpp
- *
- * Project:
- * --------
- * Maui META APP
- *
- * Description:
- * ------------
- * Acoustic volume setting source
- *
- * Author:
- * -------
- * Andy Ueng (mtk00490)
- *
- *============================================================================
- * HISTORY
- * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
- *------------------------------------------------------------------------------
- * $Revision$
- * $Modtime$
- * $Log$
- *
- *------------------------------------------------------------------------------
- * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
- *============================================================================
- ****************************************************************************/
- //---------------------------------------------------------------------------
- #include <IniFiles.hpp>
- #pragma hdrstop
- #ifndef _VOLUME_SETTING_H_
- #include "volume_setting.h"
- #endif
- #ifndef _MAN_ACTIVE_H_
- #include "man_active.h"
- #endif
- #ifndef _MAN_FDM_H_
- #include "man_fdm.h"
- #endif
- //===========================================================================
- static CVOLSET* volume_setting_ptr;
- static bool g_bIsRunning = false;
- //===========================================================================
- static void CNF_ReadFromNVRAM(void)
- {
- volume_setting_ptr->CNF_ReadFromNVRAM();
- }
- //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- static void CNF_WriteToNVRAM(void)
- {
- volume_setting_ptr->CNF_WriteToNVRAM();
- }
- //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- static void REQ_Get_Runtime_CustVol(void)
- {
- volume_setting_ptr->REQ_Get_Runtime_CustVol();
- }
- //---------------------------------------------------------------------------
- static void REQ_Set_Runtime_CustVol(void)
- {
- volume_setting_ptr->REQ_Set_Runtime_CustVol();
- }
- //===========================================================================
- CVOLSET::CVOLSET(void)
- {
- g_bIsRunning = false;
- ConfirmCallback = NULL;
- m_pcVolSetBuf = NULL;
- }
- //---------------------------------------------------------------------------
- CVOLSET::~CVOLSET()
- {
- g_bIsRunning = false;
- ConfirmCallback = NULL;
- ReleaseDynMemory();
- }
- //---------------------------------------------------------------------------
- void CVOLSET::Init(void)
- {
- ReleaseDynMemory();
- }
- //---------------------------------------------------------------------------
- void CVOLSET::ReleaseDynMemory(void)
- {
- if (NULL == m_pcVolSetBuf)
- {
- delete [] m_pcVolSetBuf;
- m_pcVolSetBuf = NULL;
- m_iVolSetBufSize = 0;
- }
- }
- //---------------------------------------------------------------------------
- void CVOLSET::REQ_Stop(void)
- {
- if (!g_bIsRunning)
- {
- return;
- }
- Confirm(METAAPP_STOP);
- }
- //---------------------------------------------------------------------------
- void CVOLSET::Confirm(E_METAAPP_RESULT_T confirm_state)
- {
- if (!g_bIsRunning)
- {
- return;
- }
- g_bIsRunning = false;
- if (NULL == ConfirmCallback)
- {
- return;
- }
- m_eConfirmState = confirm_state;
- ActiveMan->SetActiveFunction(ConfirmCallback);
- }
- //===========================================================================
- /////////////////////////// NVRAM read/write /////////////////////////////
- //===========================================================================
- void CVOLSET::REQ_Read_From_NVRAM(bool CustVolExSupport)
- {
- volume_setting_ptr = this;
- g_bIsRunning = true;
- m_bCustVolExSupport = CustVolExSupport;
- if (NULL == m_pcVolSetBuf)
- {
- META_RESULT MetaResult = META_NVRAM_GetRecLen("NVRAM_EF_CUST_ACOUSTIC_DATA_LID",
- &m_iVolSetBufSize
- );
- if (MetaResult != META_SUCCESS)
- {
- Confirm(METAAPP_FAIL);
- return;
- }
- m_pcVolSetBuf = new char[m_iVolSetBufSize];
- }
- NVRAMMan->ConfirmCallback = ::CNF_ReadFromNVRAM;
- NVRAMMan->REQ_ReadNVRAM_Start("NVRAM_EF_CUST_ACOUSTIC_DATA_LID",
- 1,
- m_iVolSetBufSize,
- m_pcVolSetBuf );
- }
- //-------------------------------------
- void CVOLSET::CNF_ReadFromNVRAM(void)
- {
- if (!g_bIsRunning)
- {
- return;
- }
- E_METAAPP_RESULT_T state = NVRAMMan->Get_ConfirmState();
- switch (state)
- {
- case METAAPP_SUCCESS:
- {
- if (!Decompose_CustAcousticVol())
- {
- Confirm(METAAPP_FAIL);
- return;
- }
- Confirm(METAAPP_SUCCESS);
- }
- break;
- default:
- {
- Confirm(state);
- }
- break;
- }
- }
- //---------------------------------------------------------------------------
- bool CVOLSET::Compose_CustAcousticVol(void)
- {
- META_RESULT MetaResult;
- if( ! m_bCustVolExSupport )
- {
- MetaResult = META_NVRAM_Compose_CustAcousticVol(&m_sCustVol, m_pcVolSetBuf, m_iVolSetBufSize);
- }
- else
- { MetaResult = META_NVRAM_Compose_16lvlCustAcousticVol(&m_sCustVolEx, m_pcVolSetBuf, m_iVolSetBufSize);
- }
- if(MetaResult!=META_SUCCESS) return false;
- return true;
- }
- //-------------------------------------
- bool CVOLSET::Decompose_CustAcousticVol(void)
- {
- META_RESULT MetaResult;
- if (!m_bCustVolExSupport)
- {
- MetaResult = META_NVRAM_Decompose_CustAcousticVol(&m_sCustVol, m_pcVolSetBuf, m_iVolSetBufSize);
- }
- else
- { MetaResult = META_NVRAM_Decompose_16lvlCustAcousticVol(&m_sCustVolEx, m_pcVolSetBuf, m_iVolSetBufSize);
- }
- if (MetaResult != META_SUCCESS)
- {
- return false;
- }
- return true;
- }
- //===========================================================================
- void CVOLSET::REQ_Write_To_NVRAM(bool CustVolExSupport, bool b_runtime_support)
- {
- volume_setting_ptr = this;
- g_bIsRunning = true;
- m_bCustVolExSupport = CustVolExSupport;
- m_bRuntimeSupport = b_runtime_support;
- if (NULL == m_pcVolSetBuf)
- {
- META_RESULT MetaResult = META_NVRAM_GetRecLen("NVRAM_EF_CUST_ACOUSTIC_DATA_LID", &m_iVolSetBufSize);
- if (MetaResult != META_SUCCESS)
- {
- Confirm(METAAPP_FAIL);
- return;
- }
- m_pcVolSetBuf = new char[m_iVolSetBufSize];
- }
- if (!Compose_CustAcousticVol())
- {
- Confirm(METAAPP_FAIL);
- return;
- }
- NVRAMMan->ConfirmCallback = ::CNF_WriteToNVRAM;
- NVRAMMan->REQ_WriteNVRAM_Start("NVRAM_EF_CUST_ACOUSTIC_DATA_LID",
- 1,
- m_iVolSetBufSize,
- m_pcVolSetBuf);
- }
- //-------------------------------------
- void CVOLSET::CNF_WriteToNVRAM(void)
- {
- if (!g_bIsRunning)
- {
- return;
- }
- E_METAAPP_RESULT_T state = NVRAMMan->Get_ConfirmState();
- if (METAAPP_SUCCESS == state)
- {
- if (m_bRuntimeSupport)
- {
- ActiveMan->SetActiveFunction(::REQ_Set_Runtime_CustVol);
- return;
- }
- }
- Confirm(state);
- }
- //===========================================================================
- ///////////////////////////// runtime setting ///////////////////////////////
- //===========================================================================
- void CVOLSET::REQ_Get_Runtime_CustVol_Start(void)
- {
- volume_setting_ptr = this;
- g_bIsRunning = true;
- ActiveMan->SetActiveFunction(::REQ_Get_Runtime_CustVol);
- }
- //---------------------------------------------------------------------------
- void CVOLSET::REQ_Get_Runtime_CustVol(void)
- {
- if (!g_bIsRunning)
- {
- return;
- }
- Audio_Get_Profile_Settings_By_Mode_Req_T req;
- Audio_Get_Profile_Settings_By_Mode_Cnf_T cnf;
- unsigned char ucTotalModeNum = 3;
- for (unsigned char ucMode = 0; ucMode < ucTotalModeNum; ucMode++)
- {
- req.m_ucMode = ucMode;
- META_RESULT MetaResult = META_Audio_Get_Audio_Profile_Settings_r(m_META_HANDLE_Obj.Get_MainHandle(), 5000, &req, &cnf);
- if (MetaResult != META_SUCCESS)
- {
- if (MetaResult != META_TIMEOUT)
- {
- Confirm(METAAPP_FAIL);
- return;
- }
- else
- {
- Confirm(METAAPP_TIMEOUT);
- return;
- }
- }
- }
- Confirm(METAAPP_SUCCESS);
- }
- //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- void CVOLSET::REQ_Set_Runtime_CustVol_Start(void)
- {
- volume_setting_ptr = this;
- g_bIsRunning = true;
- ActiveMan->SetActiveFunction(::REQ_Set_Runtime_CustVol);
- }
- //---------------------------------------------------------------------------
- void CVOLSET::REQ_Set_Runtime_CustVol(void)
- {
- if (!g_bIsRunning)
- {
- return;
- }
- Audio_Set_Profile_Settings_By_Mode_Req_T req;
- Audio_Set_Profile_Settings_By_Mode_Cnf_T cnf;
- unsigned char ucTotalModeNum = 3;
- for (unsigned char ucMode = 0; ucMode < ucTotalModeNum; ucMode++)
- {
- req.mode = ucMode;
- ComposeCustAcousticVol16Lvl(m_sCustVolEx, req);
- // req.m_ucMode = ucMode;
- META_RESULT MetaResult = META_Audio_Set_Audio_Profile_Settings_r(m_META_HANDLE_Obj.Get_MainHandle(), 5000, &req, &cnf);
- if (MetaResult != META_SUCCESS)
- {
- if (MetaResult != META_TIMEOUT)
- {
- Confirm(METAAPP_FAIL);
- return;
- }
- else
- {
- Confirm(METAAPP_TIMEOUT);
- return;
- }
- }
- }
- Confirm(METAAPP_SUCCESS);
- }
- //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- void CVOLSET::ComposeCustAcousticVol(CustAcousticVol_T s_cust_vol, Audio_Get_Profile_Settings_By_Mode_Cnf_T& s_runtime)
- {
- s_runtime.sidetone = s_cust_vol.volume_gain[s_runtime.mode][SIDE_TONE_TYPE][0];
- for (int i = 0; i < CUST_VOL_LEVEL_NUM; i++)
- {
- s_runtime.keytone[i] = s_cust_vol.volume_gain[s_runtime.mode][KEYPAD_TONE_TYPE][i];
- s_runtime.mic[i] = s_cust_vol.volume_gain[s_runtime.mode][MICROPHONE_TYPE][i];
- s_runtime.sound[i] = s_cust_vol.volume_gain[s_runtime.mode][GMI_TONE_TYPE][i];
- s_runtime.speech[i] = s_cust_vol.volume_gain[s_runtime.mode][SPEECH_TONE_TYPE][i];
- s_runtime.melody[i] = s_cust_vol.volume_gain[s_runtime.mode][MELODY_TYPE][i];
- }
- }
- //---------------------------------------------------------------------------
- void CVOLSET::DeComposeCustAcousticVol(Audio_Get_Profile_Settings_By_Mode_Cnf_T s_runtime, CustAcousticVol_T& s_cust_vol)
- {
- for (int i = 0; i < CUST_VOL_LEVEL_NUM; i++)
- {
- s_cust_vol.volume_gain[s_runtime.mode][KEYPAD_TONE_TYPE][i] = s_runtime.keytone[i];
- s_cust_vol.volume_gain[s_runtime.mode][MICROPHONE_TYPE][i] = s_runtime.mic[i];
- s_cust_vol.volume_gain[s_runtime.mode][GMI_TONE_TYPE][i] = s_runtime.sound[i];
- s_cust_vol.volume_gain[s_runtime.mode][SPEECH_TONE_TYPE][i] = s_runtime.speech[i];
- s_cust_vol.volume_gain[s_runtime.mode][SIDE_TONE_TYPE][i] = s_runtime.sidetone;
- s_cust_vol.volume_gain[s_runtime.mode][MELODY_TYPE][i] = s_runtime.melody[i];
- }
- }
- //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- void CVOLSET::ComposeCustAcousticVol16Lvl(CustAcousticVol16lvl_T s_cust_vol, Audio_Set_Profile_Settings_By_Mode_Req_T& s_runtime)
- {
- for (int i = 0; i < CUST_VOL_LEVEL_NUM; i++)
- {
- //s_runtime. = s_cust_vol.volume_gain[s_runtime.mode][CALL_TONE_TYPE][i];
- s_runtime.keytone[i] = s_cust_vol.volume_gain[s_runtime.mode][KEYPAD_TONE_TYPE][i];
- s_runtime.mic[i] = s_cust_vol.volume_gain[s_runtime.mode][MICROPHONE_TYPE][i];
- s_runtime.sound[i] = s_cust_vol.volume_gain[s_runtime.mode][GMI_TONE_TYPE][i];
- s_runtime.speech[i] = s_cust_vol.volume_gain[s_runtime.mode][SPEECH_TONE_TYPE][i];
- s_runtime.sidetone = s_cust_vol.volume_gain[s_runtime.mode][SIDE_TONE_TYPE][i];
- s_runtime.melody[i] = s_cust_vol.volume_gain[s_runtime.mode][MELODY_TYPE][i];
- s_runtime.tv_out_volume_gain[i] = s_cust_vol.tv_out_volume_gain[i];
- }
- s_runtime.max_melody_volume_gain = s_cust_vol.max_melody_volume_gain[s_runtime.mode];
- s_runtime.melody_volume_gain_step = s_cust_vol.melody_volume_gain_step[s_runtime.mode];
- }
- //---------------------------------------------------------------------------
- void CVOLSET::DeComposeCustAcousticVol16Lvl(Audio_Get_Profile_Settings_By_Mode_Cnf_T s_runtime, CustAcousticVol16lvl_T& s_cust_vol)
- {
- for (int i = 0; i < CUST_VOL_LEVEL_NUM; i++)
- {
- //s_cust_vol.volume_gain[s_runtime.mode][CALL_TONE_TYPE][i] = s_runtime.
- s_cust_vol.volume_gain[s_runtime.mode][KEYPAD_TONE_TYPE][i] = s_runtime.keytone[i];
- s_cust_vol.volume_gain[s_runtime.mode][MICROPHONE_TYPE][i] = s_runtime.mic[i];
- s_cust_vol.volume_gain[s_runtime.mode][GMI_TONE_TYPE][i] = s_runtime.sound[i];
- s_cust_vol.volume_gain[s_runtime.mode][SPEECH_TONE_TYPE][i] = s_runtime.speech[i];
- s_cust_vol.volume_gain[s_runtime.mode][SIDE_TONE_TYPE][i] = s_runtime.sidetone;
- s_cust_vol.volume_gain[s_runtime.mode][MELODY_TYPE][i] = s_runtime.melody[i];
- }
- s_cust_vol.max_melody_volume_gain[s_runtime.mode] = s_runtime.max_melody_volume_gain;
- s_cust_vol.melody_volume_gain_step[s_runtime.mode] = s_runtime.melody_volume_gain_step;
- }
- //===========================================================================
- ///////////////////////////// file read/write ///////////////////////////////
- //===========================================================================
- bool CVOLSET::REQ_Read_From_File( char *filename, bool CustVolExSupport )
- {
- TIniFile *ini_file;
- AnsiString data;
- AnsiString CategoryStr;
- AnsiString ItemStr;
- int i, j, k;
- AnsiString VolumeMode[] = { "Normal", "Headset", "Handfree", "TV Out" };
- AnsiString ToneType[] = {"Call Tone", "Keypad Tone", "Microphone", "GMI Tone", "Speech Tone", "Side Tone", "Melody"};
- AnsiString VolumeLevel[] = { "Level 0", "Level 1", "Level 2", "Level 3", "Level 4", "Level 5", "Level 6"};
- ini_file = new TIniFile( filename );
- if( ini_file == NULL ) return false;
- // Volume level
- for (i=0; i<TOTAL_AUDIO_MODE_NUM-1; i++)
- {
- for (j=0; j<TOTAL_TONE_NUM; j++)
- {
- if( j!= MICROPHONE_INDEX && j!= SIDE_TONE_INDEX && j!=CALL_TONE_INDEX && j!=GMI_TONE_INDEX )
- {
- CategoryStr = VolumeMode[i] + " Volume Level";
- ItemStr = ToneType[j];
- if( ! CustVolExSupport )
- {
- m_sCustVol.volume[i][j] = ini_file->ReadInteger(CategoryStr, ItemStr, 3);
- }
- else
- { m_sCustVolEx.volume[i][j] = ini_file->ReadInteger(CategoryStr, ItemStr, 3);
- }
- }
- }
- }
- // Volume gain
- for (i=0; i<TOTAL_AUDIO_MODE_NUM-1; i++)
- {
- for (j=0; j<TOTAL_TONE_NUM; j++)
- {
- if( j != MICROPHONE_INDEX && j != SIDE_TONE_INDEX && j!=CALL_TONE_INDEX && j!=GMI_TONE_INDEX )
- {
- for (k=0; k<TOTAL_VOLUME_LEVEL_NUM; k++)
- {
- CategoryStr = VolumeMode[i] + " Volume Gain";
- ItemStr = ToneType[j] + " " + VolumeLevel[k];
- if( ! CustVolExSupport )
- {
- m_sCustVol.volume_gain[i][j][k] = ini_file->ReadInteger(CategoryStr, ItemStr, 0);
- }
- else
- { m_sCustVolEx.volume_gain[i][j][k] = ini_file->ReadInteger(CategoryStr, ItemStr, 0);
- }
- }
- }
- else if( j == MICROPHONE_INDEX || j == SIDE_TONE_INDEX )
- {
- CategoryStr = VolumeMode[i] + " Volume Gain";
- ItemStr = ToneType[j] + " " + VolumeLevel[0];
- if( ! CustVolExSupport )
- {
- m_sCustVol.volume_gain[i][j][0] = ini_file->ReadInteger(CategoryStr, ItemStr, 0);
- }
- else
- { m_sCustVolEx.volume_gain[i][j][0] = ini_file->ReadInteger(CategoryStr, ItemStr, 0);
- }
- }
- }
- }
- if( CustVolExSupport )
- {
- for(i=0; i<TOTAL_AUDIO_MODE_NUM; i++)
- {
- CategoryStr = "16 Level Max Melody Volume Gain";
- ItemStr = VolumeMode[i] + " Max Melody Volume Gain";
- m_sCustVolEx.max_melody_volume_gain[i] = ini_file->ReadInteger( CategoryStr, ItemStr, 0 );
- }
- for(i=0; i<TOTAL_AUDIO_MODE_NUM; i++)
- {
- CategoryStr = "16 Level Melody Volume Gain Step";
- ItemStr = VolumeMode[i] + " Melody Volume Gain Step";
- m_sCustVolEx.melody_volume_gain_step[i] = ini_file->ReadInteger( CategoryStr, ItemStr, 0 );
- }
- for( i=0; i<TOTAL_VOLUME_LEVEL_NUM; i++ )
- {
- CategoryStr = "TV Out Volume Gain";
- ItemStr = "TV Out Volume Gain " + IntToStr(i);
- m_sCustVolEx.tv_out_volume_gain[i] = ini_file->ReadInteger( CategoryStr, ItemStr, 0 );
- }
- }
- delete ini_file;
- return true;
- }
- //-----------------------------------------------------------------------------------------------
- bool CVOLSET::REQ_Write_To_File( char *filename, bool hideEnable, bool CustVolExSupport )
- {
- TIniFile *ini_file;
- AnsiString data;
- AnsiString CategoryStr;
- AnsiString ItemStr;
- int i, j, k;
- AnsiString VolumeMode[] = { "Normal", "Headset", "Handfree", "TV Out" };
- AnsiString ToneType[] = {"Call Tone", "Keypad Tone", "Microphone", "GMI Tone", "Speech Tone", "Side Tone", "Melody"};
- AnsiString VolumeLevel[] = { "Level 0", "Level 1", "Level 2", "Level 3", "Level 4", "Level 5", "Level 6"};
- ini_file = new TIniFile( filename );
- if( ini_file == NULL ) return false;
- if (ini_file != NULL)
- {
- // Volume level
- for (i=0; i<TOTAL_AUDIO_MODE_NUM-1; i++)
- {
- for (j=0; j<TOTAL_TONE_NUM; j++)
- {
- if( j!= MICROPHONE_INDEX && j!= SIDE_TONE_INDEX && j!=CALL_TONE_INDEX && j!=GMI_TONE_INDEX )
- {
- CategoryStr = VolumeMode[i] + " Volume Level";
- ItemStr = ToneType[j];
- if( ! CustVolExSupport )
- {
- ini_file->WriteInteger( CategoryStr, ItemStr, m_sCustVol.volume[i][j] );
- }
- else
- {
- ini_file->WriteInteger( CategoryStr, ItemStr, m_sCustVolEx.volume[i][j] );
- }
- }
- }
- }
- for (i=0; i<TOTAL_AUDIO_MODE_NUM-1; i++)
- {
- for (j=0; j<TOTAL_TONE_NUM; j++)
- {
- for (k=0; k<TOTAL_VOLUME_LEVEL_NUM; k++)
- {
- if( j != MICROPHONE_INDEX && j != SIDE_TONE_INDEX && j!=CALL_TONE_INDEX && j!=GMI_TONE_INDEX )
- {
- CategoryStr = VolumeMode[i] + " Volume Gain";
- ItemStr = ToneType[j] + " " + VolumeLevel[k];
- if( ! CustVolExSupport )
- {
- ini_file->WriteInteger( CategoryStr, ItemStr, m_sCustVol.volume_gain[i][j][k] );
- }
- else
- {
- ini_file->WriteInteger( CategoryStr, ItemStr, m_sCustVolEx.volume_gain[i][j][k] );
- }
- }
- else if( j == MICROPHONE_INDEX || j == SIDE_TONE_INDEX )
- {
- CategoryStr = VolumeMode[i] + " Volume Gain";
- ItemStr = ToneType[j] + " " + VolumeLevel[0];
- if( ! CustVolExSupport )
- {
- ini_file->WriteInteger( CategoryStr, ItemStr, m_sCustVol.volume_gain[i][j][0] );
- }
- else
- { ini_file->WriteInteger( CategoryStr, ItemStr, m_sCustVolEx.volume_gain[i][j][0] );
- }
- }
- }
- }
- }
- if( CustVolExSupport )
- {
- for(i=0; i<TOTAL_AUDIO_MODE_NUM; i++)
- {
- CategoryStr = "16 Level Max Melody Volume Gain";
- ItemStr = VolumeMode[i] + " Max Melody Volume Gain";
- ini_file->WriteInteger( CategoryStr, ItemStr, m_sCustVolEx.max_melody_volume_gain[i] );
- }
- for(i=0; i<TOTAL_AUDIO_MODE_NUM; i++)
- {
- CategoryStr = "16 Level Melody Volume Gain Step";
- ItemStr = VolumeMode[i] + " Melody Volume Gain Step";
- ini_file->WriteInteger( CategoryStr, ItemStr, m_sCustVolEx.melody_volume_gain_step[i] );
- }
- for( i=0; i<TOTAL_VOLUME_LEVEL_NUM; i++ )
- {
- CategoryStr = "TV Out Volume Gain";
- ItemStr = "TV Out Volume Gain " + IntToStr(i);
- ini_file->WriteInteger( CategoryStr, ItemStr, m_sCustVolEx.tv_out_volume_gain[i] );
- }
- }
- delete ini_file;
- }
- return true;
- }
- //===========================================================================
- bool CVOLSET::REQ_Write_To_nvram_default_audio( char *filename, S_TONE_SUPPORT tone_support, bool CustVolExSupport )
- {
- FILE *fs;
- int i, j, k;
- AnsiString as_str;
- AnsiString as_mode[MAX_VOL_CATE+1] = { (AnsiString) "NOR",
- (AnsiString) "HED",
- (AnsiString) "HND",
- (AnsiString) "TVO"
- };
- AnsiString as_type[MAX_VOL_TYPE] = { (AnsiString) "CTN",
- (AnsiString) "KEY",
- (AnsiString) "MIC",
- (AnsiString) "GMI",
- (AnsiString) "SPH",
- (AnsiString) "SID",
- (AnsiString) "MED"
- };
- AnsiString as_comment[MAX_VOL_CATE] = { (AnsiString) "Normal",
- (AnsiString) "Headset",
- (AnsiString) "Handfree"
- };
- fs = fopen( filename, "w" );
- if(fs==0) return(false);
- fprintf( fs, "#include "kal_release.h"nn");
- if( CustVolExSupport )
- {
- for( i=0; i<MAX_VOL_CATE+1; i++ )
- {
- if( i != TVOUT_MODE )
- {
- as_str = "#define GAIN_" + as_mode[i] + "_MED_VOL_MAX " + m_sCustVolEx.max_melody_volume_gain[i] + "n";
- }
- else
- { as_str = "#define GAIN_" + as_mode[i] + "_VOL_MAX " + m_sCustVolEx.max_melody_volume_gain[i] + "n";
- }
- fprintf( fs, as_str.c_str() );
- }
- for( i=0; i<MAX_VOL_CATE+1; i++ )
- {
- if( i != TVOUT_MODE )
- {
- as_str = "#define GAIN_" + as_mode[i] + "_MED_VOL_STEP " + m_sCustVolEx.melody_volume_gain_step[i] + "n";
- }
- else
- { as_str = "#define GAIN_" + as_mode[i] + "_VOL_STEP " + m_sCustVolEx.melody_volume_gain_step[i] + "n";
- }
- fprintf( fs, as_str.c_str() );
- }
- fprintf( fs, "n" );
- for( i=0; i<MAX_VOL_LEVEL; i++ )
- { as_str = "#define GAIN_TVO_VOL" + IntToStr(i) + " " + m_sCustVolEx.tv_out_volume_gain[i] + "n";
- fprintf( fs, as_str.c_str() );
- }
- }
- for( i=0; i<MAX_VOL_CATE; i++ )
- {
- as_str = "/* define Gain For " + as_comment[i] + " */n";
- fprintf( fs, as_str.c_str() );
- fprintf( fs, "/* speaker, microphone, loudspeaker, buzzer */n" );
- for( j=0; j<MAX_VOL_TYPE; j++ )
- {
- if( j!=MICROPHONE_INDEX && j!=SIDE_TONE_INDEX && j!=CALL_TONE_INDEX && j!=GMI_TONE_INDEX )
- {
- // if( frmAudio->m_cbTone[j]->Visible )
- if( tone_support.b_ToneSupport[j] )
- {
- if( ! CustVolExSupport )
- {
- as_str = "#define GAIN_" + as_mode[i] + "_" + as_type[j] + "_VOL" + " " + m_sCustVol.volume[i][j] + "n";
- }
- else
- {
- as_str = "#define GAIN_" + as_mode[i] + "_" + as_type[j] + "_VOL" + " " + m_sCustVolEx.volume[i][j] + "n";
- }
- fprintf( fs, as_str.c_str() );
- }
- for( k=0; k<MAX_VOL_LEVEL; k++ )
- {
- if( ! CustVolExSupport )
- {
- as_str = "#define GAIN_" + as_mode[i] + "_" + as_type[j] + "_VOL" + IntToStr(k) + " " + m_sCustVol.volume_gain[i][j][k] + "n";
- }
- else
- {
- as_str = "#define GAIN_" + as_mode[i] + "_" + as_type[j] + "_VOL" + IntToStr(k) + " " + m_sCustVolEx.volume_gain[i][j][k] + "n";
- }
- fprintf( fs, as_str.c_str() );
- }
- fprintf( fs, "n" );
- }
- else if( j==MICROPHONE_INDEX || j==SIDE_TONE_INDEX ) // microphone & sidetone only contain one volume level
- {
- if( ! CustVolExSupport )
- {
- as_str = "#define GAIN_" + as_mode[i] + "_" + as_type[j] + "_VOL" + " " + m_sCustVol.volume[i][j] + "n";
- }
- else
- { as_str = "#define GAIN_" + as_mode[i] + "_" + as_type[j] + "_VOL" + " " + m_sCustVolEx.volume[i][j] + "n";
- }
- fprintf( fs, as_str.c_str() );
- if( ! CustVolExSupport )
- {
- as_str = "#define GAIN_" + as_mode[i] + "_" + as_type[j] + "_VOL" + IntToStr(0) + " " + m_sCustVol.volume_gain[i][j][0] + "n";
- }
- else
- { as_str = "#define GAIN_" + as_mode[i] + "_" + as_type[j] + "_VOL" + IntToStr(0) + " " + m_sCustVolEx.volume_gain[i][j][0] + "n";
- }
- fprintf( fs, as_str.c_str() );
- fprintf( fs, "n" );
- }
- }
- }
- // array
- fprintf( fs, "kal_uint8 const NVRAM_EF_CUST_ACOUSTIC_DATA_DEFAULT[] = {" );
- for( i=0; i<MAX_VOL_CATE; i++ )
- {
- fprintf( fs, "n " );
- as_str = "/* " + as_comment[i] + ": Call Tone, Keypad Tone, Microphone, GMI Tone, Speech Tone, Side Tone */n";
- fprintf( fs, as_str.c_str() );
- for( j=0; j<MAX_VOL_TYPE; j++ )
- {
- fprintf( fs, " " );
- for( k=0; k<MAX_VOL_LEVEL; k++ )
- {
- as_str = "GAIN_" + as_mode[i] + "_" + as_type[j] + "_VOL" + IntToStr(k) + ", ";
- fprintf( fs, as_str.c_str() );
- }
- fprintf( fs, "n" );
- }
- }
- for( i=0; i<MAX_VOL_CATE; i++ )
- {
- fprintf( fs, "n " );
- as_str = "/* " + as_comment[i] + " volume: CTN, SPK, MIC, BUZ, SPH, SID, MED */n";
- fprintf( fs, as_str.c_str() );
- fprintf( fs, " " );
- for( j=0; j<MAX_VOL_TYPE; j++ )
- {
- as_str = "GAIN_" + as_mode[i] + "_" + as_type[j] + "_VOL";
- fprintf( fs, as_str.c_str() );
- if( i == MAX_VOL_CATE-1 && j == MAX_VOL_TYPE-1 )
- {
- break;
- }
- fprintf( fs, ", " );
- }
- }
- fprintf( fs, "nn " );
- as_str = "/* Normal, Headset, Handfree mode melody volume gains */";
- fprintf( fs, as_str.c_str() );
- fprintf( fs, "n " );
- for( i=0; i<MAX_VOL_CATE; i++ )
- {
- as_str = ", GAIN_" + as_mode[i] + "_MED_VOL_MAX";
- fprintf( fs, as_str.c_str() );
- }
- as_str = ", GAIN_TVO_VOL_MAX,";
- fprintf( fs, as_str.c_str() );
- fprintf( fs, "n " );
- as_str = "/* Normal, Headset, Handfree mode melody volume gain steps */";
- fprintf( fs, as_str.c_str() );
- fprintf( fs, "n " );
- for( i=0; i<MAX_VOL_CATE; i++ )
- {
- as_str = " GAIN_" + as_mode[i] + "_MED_VOL_STEP,";
- fprintf( fs, as_str.c_str() );
- }
- as_str = " GAIN_TVO_VOL_STEP,";
- fprintf( fs, as_str.c_str() );
- fprintf( fs, "n " );
- as_str = "/* TV out volume gains*/";
- fprintf( fs, as_str.c_str() );
- fprintf( fs, "n " );
- for( i=0; i<MAX_VOL_LEVEL-1; i++ )
- {
- as_str = " GAIN_TVO_VOL" + IntToStr(i) + ",";
- fprintf( fs, as_str.c_str() );
- }
- as_str = " GAIN_TVO_VOL6";
- fprintf( fs, as_str.c_str() );
- fprintf( fs, "n};nn");
- fclose(fs);
- return(true);
- }
- //===========================================================================
- //////////////////////////// Query ///////////////////////////
- //===========================================================================
- bool CVOLSET::Query_CustVolExSupport_Start(void)
- {
- META_RESULT MetaResult = META_QueryIfTargetSupportAcoustic16level_r(m_META_HANDLE_Obj.Get_MainHandle(), 300);
- if (MetaResult != META_SUCCESS)
- {
- return false;
- }
- return true;
- }
- //--------------------------------------------------------------------------
- bool CVOLSET::Query_CustVolRuntime_Support_Start(void)
- {
- META_RESULT MetaResult = META_QueryIfFunctionSupportedByTarget_r(m_META_HANDLE_Obj.Get_MainHandle(), 300, "META_Audio_Set_Audio_Profile_Settings_r");
- if(MetaResult!=META_SUCCESS)
- {
- return false;
- }
- return true;
- }
- //===========================================================================
- //////////////////////////// Export information ///////////////////////////
- //===========================================================================
- E_METAAPP_RESULT_T CVOLSET::Get_ConfirmState(void)
- {
- return m_eConfirmState;
- }
- //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- CustAcousticVol_T* CVOLSET::Get_CustVol(void)
- {
- return &m_sCustVol;
- }
- //---------------------------------------------------------------------------
- void CVOLSET::Set_CustVol(CustAcousticVol_T cust_vol)
- {
- m_sCustVol = cust_vol;
- }
- //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- CustAcousticVol16lvl_T* CVOLSET::Get_CustVol16(void)
- {
- return &m_sCustVolEx;
- }
- //---------------------------------------------------------------------------
- void CVOLSET::Set_CustVol16(CustAcousticVol16lvl_T cust_vol)
- {
- m_sCustVolEx = cust_vol;
- }
- //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- unsigned char CVOLSET::Get_CustVol( int cate, int type, bool CustVolExSupport )
- {
- if( CustVolExSupport )
- {
- return m_sCustVolEx.volume[cate][type];
- }
- else
- {
- return m_sCustVol.volume[cate][type];
- }
- }
- //---------------------------------------------------------------------------
- void CVOLSET::Set_CustVol( int cate, int type, unsigned char vol, bool CustVolExSupport )
- {
- if( CustVolExSupport )
- {
- m_sCustVolEx.volume[cate][type] = vol;
- }
- else
- {
- m_sCustVol.volume[cate][type] = vol;
- }
- }
- //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- unsigned char CVOLSET::Get_CustVolGain( int cate, int type, int level, bool CustVolExSupport )
- {
- if( CustVolExSupport )
- {
- return m_sCustVolEx.volume_gain[cate][type][level];
- }
- else
- {
- return m_sCustVol.volume_gain[cate][type][level];
- }
- }
- //---------------------------------------------------------------------------
- void CVOLSET::Set_CustVolGain( int cate, int type, int level, unsigned char vol_gain, bool CustVolExSupport )
- {
- if( CustVolExSupport )
- {
- m_sCustVolEx.volume_gain[cate][type][level] = vol_gain;
- }
- else
- {
- m_sCustVol.volume_gain[cate][type][level] = vol_gain;
- }
- }
- //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- unsigned char CVOLSET::Get_MaxMelodyVolGain( int cate )
- {
- return m_sCustVolEx.max_melody_volume_gain[cate];
- }
- //--------------------------------------------------------------------------
- void CVOLSET::Set_MaxMelodyVolGain( int cate, unsigned char vol_gain )
- { m_sCustVolEx.max_melody_volume_gain[cate] = vol_gain;
- }
- //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- unsigned char CVOLSET::Get_MelodyVolGainStep( int cate )
- { return m_sCustVolEx.melody_volume_gain_step[cate];
- }
- //---------------------------------------------------------------------------
- void CVOLSET::Set_MelodyVolGainStep( int cate, unsigned char gain_step )
- { m_sCustVolEx.melody_volume_gain_step[cate] = gain_step;
- }
- //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- unsigned char CVOLSET::Get_TvOutVolGain( int level )
- { return m_sCustVolEx.tv_out_volume_gain[level];
- }
- //---------------------------------------------------------------------------
- void CVOLSET::Set_TvOutVolGain( int level, unsigned char vol_gain)
- { m_sCustVolEx.tv_out_volume_gain[level] = vol_gain;
- }