SoundEffect.c
上传用户:lqx1163
上传日期:2014-08-13
资源大小:9183k
文件大小:64k
源码类别:

MTK

开发平台:

C/C++

  1. /*****************************************************************************
  2. *  Copyright Statement:
  3. *  --------------------
  4. *  This software is protected by Copyright and the information contained
  5. *  herein is confidential. The software may not be copied and the information
  6. *  contained herein may not be used or disclosed except with the written
  7. *  permission of MediaTek Inc. (C) 2005
  8. *
  9. *  BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
  10. *  THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
  11. *  RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
  12. *  AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
  13. *  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
  14. *  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
  15. *  NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
  16. *  SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
  17. *  SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
  18. *  THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
  19. *  NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
  20. *  SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
  21. *
  22. *  BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
  23. *  LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
  24. *  AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
  25. *  OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
  26. *  MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE. 
  27. *
  28. *  THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
  29. *  WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
  30. *  LAWS PRINCIPLES.  ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
  31. *  RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
  32. *  THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
  33. *
  34. *****************************************************************************/
  35. /*****************************************************************************
  36. *
  37. * Filename:
  38. * ---------
  39. * SoundEffect.c
  40. *
  41. * Project:
  42. * --------
  43. *   MAUI
  44. *
  45. * Description:
  46. * ------------
  47. *   This file is intends to setup sound effect.
  48. *
  49. * Author:
  50. * -------
  51. * Tim Chen
  52. *
  53. *============================================================================
  54. *             HISTORY
  55. * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
  56.  *------------------------------------------------------------------------------
  57.  * $Log$
  58.  *
  59.  * removed!
  60.  * removed!
  61.  * 
  62.  *
  63.  * removed!
  64.  * removed!
  65.  * 
  66.  *
  67.  * removed!
  68.  * removed!
  69.  * 
  70.  *
  71.  * removed!
  72.  * removed!
  73.  * 
  74.  *
  75.  * removed!
  76.  * removed!
  77.  * 
  78.  *
  79.  * removed!
  80.  * removed!
  81.  * 
  82.  *
  83.  * removed!
  84.  * removed!
  85.  * 
  86.  *
  87.  * removed!
  88.  * removed!
  89.  * 
  90.  *
  91.  * removed!
  92.  * removed!
  93.  * 
  94.  *
  95.  * removed!
  96.  * removed!
  97.  * 
  98.  *
  99.  * removed!
  100.  * removed!
  101.  * 
  102.  *
  103.  * removed!
  104.  * removed!
  105.  * 
  106.  *
  107.  * removed!
  108.  * removed!
  109.  * 
  110.  *
  111.  * removed!
  112.  * removed!
  113.  * 
  114.  *
  115.  * removed!
  116.  * removed!
  117.  * 
  118.  *
  119.  * removed!
  120.  * removed!
  121.  * 
  122.  *
  123.  * removed!
  124.  * removed!
  125.  * 
  126.  *
  127.  * removed!
  128.  * removed!
  129.  * 
  130.  *
  131.  *------------------------------------------------------------------------------
  132. * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
  133. *============================================================================
  134. ****************************************************************************/
  135. #include "MMI_features.h"
  136. #include "StdC.h"
  137. #include "L4Dr1.h"
  138. #include "L4Dr.h"
  139. #include "wgui_categories.h"
  140. #include "wgui_categories_inputs.h"
  141. #include "SettingDefs.h"
  142. #include "SettingsGdcl.h"
  143. #include "settingstructs.h"
  144. #include "settinggprots.h"
  145. #include "ProtocolEvents.h"
  146. #include "NVRAMType.h"
  147. #include "NVRAMProt.h"
  148. #include "NVRAMEnum.h"
  149. #include "CommonScreens.h"
  150. #include "SettingProt.h"
  151. #include "SettingProfile.h"
  152. #include "SoundEffect.h"
  153. #include "Audio3DEffect.h"
  154. #include "mdi_datatype.h"
  155. #include "mdi_audio.h"
  156. #include "DebugInitDef.h"
  157. #if defined(__MMI_AUDIO_EQUALIZER__)
  158. #include "ProfilesEnum.h"
  159. #endif
  160. #ifdef __MMI_SOUND_EFFECT__
  161. #if defined(__MMI_AUDIO_EQUALIZER__)
  162. audio_equalizer_struct g_settings_audio_equalizer;
  163. static U16 selected_audio_equalizer_index = 0;
  164. #endif /* defined(__MMI_AUDIO_EQUALIZER__) */ 
  165. #ifdef __MMI_EDITABLE_AUDIO_EQUALIZER__
  166. #ifdef MMI_ON_HARDWARE_P
  167. #include "nvram_default_audio.h"
  168. #endif 
  169. extern equalizer_setting_info g_audio_equalizer_current_setting_info;
  170. extern float one_pixel_represents;
  171. void mmi_settings_audio_equalizer_adjust_values_for_editor(audio_equalizer_struct *);
  172. static UI_character_type name_text_editor_buffer[SETTING_NAME_MAX_LEN];
  173. U16 setting_name_edit_option_highlighted_item_text;
  174. BOOL g_audio_equalizer_setting_modified = FALSE;
  175. extern U16 g_audio_equalizer_scrollable_ht, g_audio_equalizer_unit_scroll;
  176. extern void mmi_aud_eq_init_image_specific_vals(void);
  177. #endif /* __MMI_EDITABLE_AUDIO_EQUALIZER__ */ 
  178. #endif /* __MMI_SOUND_EFFECT__ */ 
  179. audio_mic_volume_struct g_settings_audio_mic_volume;
  180. /*****************************************************************************
  181.  * FUNCTION
  182.  *  InitSoundEffect
  183.  * DESCRIPTION
  184.  *  This function is for initializing the Sound efeects application.
  185.  * PARAMETERS
  186.  *  void
  187.  * RETURNS
  188.  *  void
  189.  *****************************************************************************/
  190. void InitSoundEffect(void)
  191. {
  192. #ifdef __MMI_SOUND_EFFECT__
  193.     /*----------------------------------------------------------------*/
  194.     /* Local Variables                                                */
  195.     /*----------------------------------------------------------------*/
  196.     /*----------------------------------------------------------------*/
  197.     /* Code Body                                                      */
  198.     /*----------------------------------------------------------------*/
  199.     SetHiliteHandler(MENU_SETTING_SOUND_EFFECT, mmi_settings_sound_effect_highlight_hdlr);
  200. #if defined(__MMI_AUDIO_EQUALIZER__)
  201.     SetHiliteHandler(MENU_SETTING_AUDIO_EQUALIZIER, mmi_settings_audio_equalizer_highlight_hdlr);
  202.     SetHintHandler(MENU_SETTING_AUDIO_EQUALIZIER, mmi_settings_audio_equalizer_hint_hdlr);
  203. #endif /* defined(__MMI_AUDIO_EQUALIZER__) */ 
  204. #ifdef __MMI_EDITABLE_AUDIO_EQUALIZER__
  205.     SetHiliteHandler(
  206.         MENU_SETTING_AUDIO_EQUALIZER_SET_OPT_SELECT,
  207.         mmi_settings_audio_equalizer_opt_select_highlight_hdlr);
  208.     SetHiliteHandler(MENU_SETTING_AUDIO_EQUALIZER_SET_OPT_EDIT, mmi_settings_audio_equalizer_opt_edit_highlight_hdlr);
  209.     SetHiliteHandler(
  210.         MENU_SETTING_AUDIO_EQUALIZER_SET_OPT_RENAME,
  211.         mmi_settings_audio_equalizer_opt_rename_highlight_hdlr);
  212. #endif /* __MMI_EDITABLE_AUDIO_EQUALIZER__ */ 
  213. #if defined(__MMI_AUDIO_EQUALIZER__)
  214.     mmi_aud_eq_init_image_specific_vals();
  215.     mmi_settings_read_audio_equalizer_from_nvram(&g_settings_audio_equalizer);
  216.     mdi_audio_set_equalizer(g_settings_audio_equalizer.magnitude[g_settings_audio_equalizer.index]);
  217. #endif /* defined(__MMI_AUDIO_EQUALIZER__) */ 
  218. #endif /* __MMI_SOUND_EFFECT__ */ 
  219.     mmi_settings_read_audio_mic_volume_from_nvram(&g_settings_audio_mic_volume);
  220.     /* Init Audio 3D Effect */
  221. #ifdef __MMI_AUDIO_3D_EFFECT__
  222.     mmi_aud_3d_effect_init();
  223. #endif 
  224. }
  225. #ifdef __MMI_SOUND_EFFECT__
  226. #if defined(__MMI_AUDIO_EQUALIZER__)
  227. /*****************************************************************************
  228.  * FUNCTION
  229.  *  mmi_settings_audio_equalizer_hint_hdlr
  230.  * DESCRIPTION
  231.  *  This function is hint handler for equalizer menu item..
  232.  * PARAMETERS
  233.  *  index       [IN]        
  234.  * RETURNS
  235.  *  void
  236.  *****************************************************************************/
  237. void mmi_settings_audio_equalizer_hint_hdlr(U16 index)
  238. {
  239.     /*----------------------------------------------------------------*/
  240.     /* Local Variables                                                */
  241.     /*----------------------------------------------------------------*/
  242.     /*----------------------------------------------------------------*/
  243.     /* Code Body                                                      */
  244.     /*----------------------------------------------------------------*/
  245.     memset((S8*) hintData[(index)], 0, MAX_SUB_MENU_SIZE);
  246. #ifdef __MMI_EDITABLE_AUDIO_EQUALIZER__
  247.     pfnUnicodeStrcpy(
  248.         (S8*) hintData[index],
  249.         (S8*) g_settings_audio_equalizer.setting_name[g_settings_audio_equalizer.index]);
  250. #else /* __MMI_EDITABLE_AUDIO_EQUALIZER__ */ 
  251.     pfnUnicodeStrcpy(
  252.         (S8*) hintData[(index)],
  253.         GetString((U16) (STR_ID_SETTING_AUDIO_EQUALIZER_SET_1 + g_settings_audio_equalizer.index)));
  254. #endif /* __MMI_EDITABLE_AUDIO_EQUALIZER__ */ 
  255. }
  256. /*****************************************************************************
  257.  * FUNCTION
  258.  *  mmi_settings_audio_equalizer_highlight_hdlr
  259.  * DESCRIPTION
  260.  *  This function is highlight handler for the Equalizer menu item.
  261.  * PARAMETERS
  262.  *  void
  263.  * RETURNS
  264.  *  void
  265.  *****************************************************************************/
  266. void mmi_settings_audio_equalizer_highlight_hdlr(void)
  267. {
  268.     /*----------------------------------------------------------------*/
  269.     /* Local Variables                                                */
  270.     /*----------------------------------------------------------------*/
  271.     /*----------------------------------------------------------------*/
  272.     /* Code Body                                                      */
  273.     /*----------------------------------------------------------------*/
  274.     ChangeLeftSoftkey(STR_GLOBAL_OK, 0);
  275.     ChangeRightSoftkey(STR_GLOBAL_BACK, 0);
  276.     SetLeftSoftkeyFunction(mmi_settings_entry_audio_equalizer_list, KEY_EVENT_UP);
  277.     SetRightSoftkeyFunction(GoBackHistory, KEY_EVENT_UP);
  278.     SetKeyHandler(mmi_settings_entry_audio_equalizer_list, KEY_RIGHT_ARROW, KEY_EVENT_DOWN);
  279.     SetKeyHandler(GoBackHistory, KEY_LEFT_ARROW, KEY_EVENT_DOWN);
  280. }
  281. /*****************************************************************************
  282.  * FUNCTION
  283.  *  mmi_settings_entry_audio_equalizer_list
  284.  * DESCRIPTION
  285.  *  This function is for entering the audio equalizer setting list screen.
  286.  * PARAMETERS
  287.  *  void
  288.  * RETURNS
  289.  *  void
  290.  *****************************************************************************/
  291. void mmi_settings_entry_audio_equalizer_list(void)
  292. {
  293. #ifdef __MMI_EDITABLE_AUDIO_EQUALIZER__
  294.     /*----------------------------------------------------------------*/
  295.     /* Local Variables                                                */
  296.     /*----------------------------------------------------------------*/
  297.     U8 *guiBuffer;  /* Buffer holding history data */
  298.     U16 gimagearray2[MAX_SUB_MENUS];
  299.     U8 i;
  300.     U16 nNumofItem; /* Stores no of children in the submenu */
  301.     U16 ItemIcons[MAX_SUB_MENUS];
  302.     /*----------------------------------------------------------------*/
  303.     /* Code Body                                                      */
  304.     /*----------------------------------------------------------------*/
  305.     /* 1 Call Exit Handler */
  306.     EntryNewScreen(SCR_ID_SETTING_AUDIO_EQUALIZER, NULL, mmi_settings_entry_audio_equalizer_list, NULL);
  307.     /* 2 Get current screen to gui buffer  for history purposes */
  308.     guiBuffer = GetCurrGuiBuffer(SCR_ID_SETTING_AUDIO_EQUALIZER);
  309.     /* 3. Retrieve no of child of menu item to be displayed */
  310.     nNumofItem = g_settings_audio_equalizer.count + 1;
  311.     SetParentHandler(MENU_SETTING_AUDIO_EQUALIZIER);
  312.     for (i = 0; i < g_settings_audio_equalizer.count; i++)
  313.     {
  314.         memset((S8*) subMenuDataPtrs[i], 0, MAX_SUB_MENU_SIZE);
  315.         pfnUnicodeStrncpy(
  316.             (S8*) subMenuDataPtrs[i],
  317.             (S8*) g_settings_audio_equalizer.setting_name[i],
  318.             MAX_SUBMENU_CHARACTERS);
  319.     }
  320.     /* set the last menu item as "Restore Factory Defaults" */
  321.     pfnUnicodeStrncpy(
  322.             (S8*) subMenuDataPtrs[i],
  323.             GetString(STR_ID_SETTING_AUDIO_EQUALIZER_REST_FACT_DEFAULT),
  324.             MAX_SUBMENU_CHARACTERS);
  325.     for (i = 0; i < nNumofItem; i++)
  326.     {
  327.         if (i == g_settings_audio_equalizer.index)
  328.         {
  329.             gimagearray2[i] = IMG_VICON;
  330.         }
  331.         else
  332.         {
  333.             gimagearray2[i] = IMG_PROFILES_NO_IMAGE;
  334.         }
  335.         ItemIcons[i] = IMG_PROFILES_NO_IMAGE;
  336.     }
  337.     RegisterHighlightHandler(mmi_settings_audio_equalizer_list_highlight_hdlr);
  338.     ShowCategory73Screen(
  339.         STR_ID_SETTING_AUDIO_EQUALIZER_CAPTION,
  340.         GetRootTitleIcon(MENU_SETTING_SOUND_EFFECT),
  341.         STR_GLOBAL_OPTIONS,
  342.         0,
  343.         STR_GLOBAL_BACK,
  344.         0,
  345.         nNumofItem,
  346.         (U8 **) subMenuDataPtrs,
  347.         (U16*) gimagearray2,
  348.         ItemIcons,
  349.         g_settings_audio_equalizer.index,
  350.         guiBuffer,
  351.         0);
  352.     SetRightSoftkeyFunction(GoBackHistory, KEY_EVENT_UP);
  353.     SetKeyHandler(GoBackHistory, KEY_LEFT_ARROW, KEY_EVENT_DOWN);
  354. #else /* __MMI_EDITABLE_AUDIO_EQUALIZER__ */ /* if the editing of audio equalizer settings is not to be there */
  355.     U8 *guiBuffer;
  356.     U16 audio_equalizer_list_strings[] = 
  357.     {
  358.         STR_ID_SETTING_AUDIO_EQUALIZER_SET_1,
  359.         STR_ID_SETTING_AUDIO_EQUALIZER_SET_2,
  360.         STR_ID_SETTING_AUDIO_EQUALIZER_SET_3,
  361.         STR_ID_SETTING_AUDIO_EQUALIZER_SET_4,
  362.         STR_ID_SETTING_AUDIO_EQUALIZER_SET_5,
  363.         STR_ID_SETTING_AUDIO_EQUALIZER_SET_6,
  364.         STR_ID_SETTING_AUDIO_EQUALIZER_SET_7,
  365.         STR_ID_SETTING_AUDIO_EQUALIZER_SET_8
  366.     };
  367.     EntryNewScreen(SCR_ID_SETTING_AUDIO_EQUALIZER, NULL, mmi_settings_entry_audio_equalizer_list, NULL);
  368.     guiBuffer = GetCurrGuiBuffer(SCR_ID_SETTING_AUDIO_EQUALIZER);
  369.     SetParentHandler(MENU_SETTING_AUDIO_EQUALIZIER);
  370.     RegisterHighlightHandler(mmi_settings_audio_equalizer_list_highlight_hdlr);
  371.     ShowCategory11Screen(
  372.         STR_ID_SETTING_AUDIO_EQUALIZER,
  373.         GetRootTitleIcon(MENU_SETTING_SOUND_EFFECT),
  374.         STR_GLOBAL_OK,
  375.         IMG_GLOBAL_OK,
  376.         STR_GLOBAL_BACK,
  377.         IMG_GLOBAL_BACK,
  378.         g_settings_audio_equalizer.count,
  379.         audio_equalizer_list_strings,
  380.         (U16) g_settings_audio_equalizer.index,
  381.         guiBuffer);
  382.     SetLeftSoftkeyFunction(mmi_settings_audio_equalizer_list_LSK_hdlr, KEY_EVENT_UP);
  383.     SetRightSoftkeyFunction(GoBackHistory, KEY_EVENT_UP);
  384.     SetKeyHandler(GoBackHistory, KEY_LEFT_ARROW, KEY_EVENT_DOWN);
  385. #endif /* __MMI_EDITABLE_AUDIO_EQUALIZER__ */ 
  386. }
  387. /*****************************************************************************
  388.  * FUNCTION
  389.  *  mmi_settings_audio_equalizer_list_highlight_hdlr
  390.  * DESCRIPTION
  391.  *  This function is highlight handler for the setting list screen.
  392.  * PARAMETERS
  393.  *  index       [IN]        
  394.  * RETURNS
  395.  *  void
  396.  *****************************************************************************/
  397. void mmi_settings_audio_equalizer_list_highlight_hdlr(S32 index)
  398. {
  399.     /*----------------------------------------------------------------*/
  400.     /* Local Variables                                                */
  401.     /*----------------------------------------------------------------*/
  402.     /*----------------------------------------------------------------*/
  403.     /* Code Body                                                      */
  404.     /*----------------------------------------------------------------*/
  405.     selected_audio_equalizer_index = (U16) index;
  406. #ifdef __MMI_EDITABLE_AUDIO_EQUALIZER__
  407.     if (index == g_settings_audio_equalizer.count)  /* the case when the highlighted item is restore factory default */
  408.     {
  409.         ChangeLeftSoftkey(STR_GLOBAL_OK, IMG_GLOBAL_OK);
  410.         SetLeftSoftkeyFunction(mmi_settings_audio_equalizer_restore_factory_default, KEY_EVENT_UP);
  411.         SetKeyHandler(mmi_settings_audio_equalizer_restore_factory_default, KEY_RIGHT_ARROW, KEY_EVENT_DOWN);
  412.     }
  413.     else
  414.     {
  415.         ChangeLeftSoftkey(STR_GLOBAL_OPTIONS, IMG_GLOBAL_OPTIONS);
  416.         SetLeftSoftkeyFunction(mmi_settings_entry_audio_equalizer_setting_options, KEY_EVENT_UP);
  417.         SetKeyHandler(mmi_settings_entry_audio_equalizer_setting_options, KEY_RIGHT_ARROW, KEY_EVENT_DOWN);
  418.     }
  419. #endif /* __MMI_EDITABLE_AUDIO_EQUALIZER__ */ 
  420. }
  421. /*****************************************************************************
  422.  * FUNCTION
  423.  *  mmi_settings_audio_equalizer_list_LSK_hdlr
  424.  * DESCRIPTION
  425.  *  This function is the LSK handler for the setting list screen.
  426.  * PARAMETERS
  427.  *  void
  428.  * RETURNS
  429.  *  void
  430.  *****************************************************************************/
  431. void mmi_settings_audio_equalizer_list_LSK_hdlr(void)
  432. {
  433.     /*----------------------------------------------------------------*/
  434.     /* Local Variables                                                */
  435.     /*----------------------------------------------------------------*/
  436.     /*----------------------------------------------------------------*/
  437.     /* Code Body                                                      */
  438.     /*----------------------------------------------------------------*/
  439.     mmi_settings_select_audio_equalizer((S16) selected_audio_equalizer_index);
  440.     DisplayPopup((PU8) GetString(STR_GLOBAL_DONE), IMG_GLOBAL_ACTIVATED, 1, UI_POPUP_NOTIFYDURATION_TIME, SUCCESS_TONE);
  441.     DeleteScreenIfPresent(SCR_ID_SETTING_AUDIO_EQUALIZER);
  442. }
  443. /*****************************************************************************
  444.  * FUNCTION
  445.  *  mmi_settings_read_audio_equalizer_from_nvram
  446.  * DESCRIPTION
  447.  *  This function is for reading the NVRAM data for audio equalizer
  448.  * PARAMETERS
  449.  *  audio_equalizer_p       [?]     
  450.  * RETURNS
  451.  *  void
  452.  *****************************************************************************/
  453. void mmi_settings_read_audio_equalizer_from_nvram(audio_equalizer_struct *audio_equalizer_p)
  454. {
  455. #ifdef MMI_ON_HARDWARE_P
  456.     /*----------------------------------------------------------------*/
  457.     /* Local Variables                                                */
  458.     /*----------------------------------------------------------------*/
  459.     S16 error;
  460.     /*----------------------------------------------------------------*/
  461.     /* Code Body                                                      */
  462.     /*----------------------------------------------------------------*/
  463.     ReadRecord(NVRAM_EF_AUDIO_EQUALIZER_LID, 1, (void*)audio_equalizer_p, NVRAM_EF_AUDIO_EQUALIZER_SIZE, &error);
  464. #else /* MMI_ON_HARDWARE_P */ 
  465.     audio_equalizer_p->count = MAX_EQUALIZER_NUM;
  466.     audio_equalizer_p->index = 0;
  467.     memset(audio_equalizer_p->magnitude, -100, MAX_EQUALIZER_NUM * 8);
  468.     /* for testing purpose */
  469.     audio_equalizer_p->magnitude[1][0] = 100;
  470.     audio_equalizer_p->magnitude[1][1] = 60;
  471.     audio_equalizer_p->magnitude[1][2] = 20;
  472.     audio_equalizer_p->magnitude[1][3] = -20;
  473.     audio_equalizer_p->magnitude[1][4] = -60;
  474.     audio_equalizer_p->magnitude[1][5] = -100;
  475.     audio_equalizer_p->magnitude[1][6] = -100;
  476.     audio_equalizer_p->magnitude[1][7] = -100;
  477.     /* copy the names */
  478.     pfnUnicodeStrcpy((S8*) audio_equalizer_p->setting_name[0], (S8*) L"Normal");
  479.     pfnUnicodeStrcpy((S8*) audio_equalizer_p->setting_name[1], (S8*) L"Bass");
  480.     pfnUnicodeStrcpy((S8*) audio_equalizer_p->setting_name[2], (S8*) L"Dance");
  481.     pfnUnicodeStrcpy((S8*) audio_equalizer_p->setting_name[3], (S8*) L"Classical");
  482.     pfnUnicodeStrcpy((S8*) audio_equalizer_p->setting_name[4], (S8*) L"Treble");
  483.     pfnUnicodeStrcpy((S8*) audio_equalizer_p->setting_name[5], (S8*) L"Party");
  484.     pfnUnicodeStrcpy((S8*) audio_equalizer_p->setting_name[6], (S8*) L"Pop");
  485.     pfnUnicodeStrcpy((S8*) audio_equalizer_p->setting_name[7], (S8*) L"Rock");
  486.     pfnUnicodeStrcpy((S8*) audio_equalizer_p->setting_name[8], (S8*) L"Restore Factory Default");
  487. #endif /* MMI_ON_HARDWARE_P */ 
  488. #ifdef __MMI_EDITABLE_AUDIO_EQUALIZER__
  489.     mmi_settings_audio_equalizer_adjust_values_for_editor(audio_equalizer_p);
  490. #endif 
  491. }
  492. /*****************************************************************************
  493.  * FUNCTION
  494.  *  mmi_settings_write_audio_equalizer_to_nvram
  495.  * DESCRIPTION
  496.  *  This function is for writing to NVRAM the audio equalizer values.
  497.  * PARAMETERS
  498.  *  audio_equalizer_p       [?]     
  499.  * RETURNS
  500.  *  void
  501.  *****************************************************************************/
  502. void mmi_settings_write_audio_equalizer_to_nvram(audio_equalizer_struct *audio_equalizer_p)
  503. {
  504. #ifdef MMI_ON_HARDWARE_P
  505.     /*----------------------------------------------------------------*/
  506.     /* Local Variables                                                */
  507.     /*----------------------------------------------------------------*/
  508.     S16 error;
  509.     /*----------------------------------------------------------------*/
  510.     /* Code Body                                                      */
  511.     /*----------------------------------------------------------------*/
  512.     WriteRecord(NVRAM_EF_AUDIO_EQUALIZER_LID, 1, (void*)audio_equalizer_p, NVRAM_EF_AUDIO_EQUALIZER_SIZE, &error);
  513. #endif /* MMI_ON_HARDWARE_P */ 
  514. }
  515. /*****************************************************************************
  516.  * FUNCTION
  517.  *  mmi_settings_select_audio_equalizer
  518.  * DESCRIPTION
  519.  *  This function is for selecting a particular setting.
  520.  * PARAMETERS
  521.  *  index       [IN]        
  522.  * RETURNS
  523.  *  void
  524.  *****************************************************************************/
  525. void mmi_settings_select_audio_equalizer(S16 index)
  526. {
  527.     /*----------------------------------------------------------------*/
  528.     /* Local Variables                                                */
  529.     /*----------------------------------------------------------------*/
  530.     /*----------------------------------------------------------------*/
  531.     /* Code Body                                                      */
  532.     /*----------------------------------------------------------------*/
  533.     if (g_settings_audio_equalizer.index != index)
  534.     {
  535.         g_settings_audio_equalizer.index = index;
  536.         mdi_audio_set_equalizer(g_settings_audio_equalizer.magnitude[index]);
  537.         mmi_settings_write_audio_equalizer_to_nvram(&g_settings_audio_equalizer);
  538.     }
  539. }
  540. #endif /* defined(__MMI_AUDIO_EQUALIZER__) */ /* __MMI_AUDIO_EQUALIZER */
  541. /*****************************************************************************
  542.  * FUNCTION
  543.  *  mmi_settings_sound_effect_highlight_hdlr
  544.  * DESCRIPTION
  545.  *  This function is highlight handler for the sound effect menu item.
  546.  * PARAMETERS
  547.  *  void
  548.  * RETURNS
  549.  *  void
  550.  *****************************************************************************/
  551. void mmi_settings_sound_effect_highlight_hdlr(void)
  552. {
  553.     /*----------------------------------------------------------------*/
  554.     /* Local Variables                                                */
  555.     /*----------------------------------------------------------------*/
  556.     /*----------------------------------------------------------------*/
  557.     /* Code Body                                                      */
  558.     /*----------------------------------------------------------------*/
  559.     ChangeLeftSoftkey(STR_GLOBAL_OK, 0);
  560.     ChangeRightSoftkey(STR_GLOBAL_BACK, 0);
  561.     SetLeftSoftkeyFunction(mmi_settings_entry_sound_effect_list, KEY_EVENT_UP);
  562.     SetRightSoftkeyFunction(GoBackHistory, KEY_EVENT_UP);
  563.     SetKeyHandler(mmi_settings_entry_sound_effect_list, KEY_RIGHT_ARROW, KEY_EVENT_DOWN);
  564.     SetKeyHandler(GoBackHistory, KEY_LEFT_ARROW, KEY_EVENT_DOWN);
  565. }
  566.  
  567. /*****************************************************************************
  568.  * FUNCTION
  569.  *  mmi_settings_entry_sound_effect_list
  570.  * DESCRIPTION
  571.  *  This function is entry function for the sound effect list screen
  572.  * PARAMETERS
  573.  *  void
  574.  * RETURNS
  575.  *  void
  576.  *****************************************************************************/
  577. void mmi_settings_entry_sound_effect_list(void)
  578. {
  579.     /*----------------------------------------------------------------*/
  580.     /* Local Variables                                                */
  581.     /*----------------------------------------------------------------*/
  582.     U16 n_items;
  583.     U8 *guiBuffer;
  584.     U16 item_strs[10];
  585.     U16 item_icons[10];
  586.     U8 *item_hints[10];
  587.     /*----------------------------------------------------------------*/
  588.     /* Code Body                                                      */
  589.     /*----------------------------------------------------------------*/
  590.     EntryNewScreen(SCR_ID_SETTING_SOUND_EFFECT, NULL, mmi_settings_entry_sound_effect_list, NULL);
  591.     guiBuffer = GetCurrGuiBuffer(SCR_ID_SETTING_SOUND_EFFECT);
  592.     n_items = GetNumOfChild(MENU_SETTING_SOUND_EFFECT);
  593.     GetSequenceStringIds(MENU_SETTING_SOUND_EFFECT, item_strs);
  594.     GetSequenceImageIds(MENU_SETTING_SOUND_EFFECT, item_icons);
  595.     SetParentHandler(MENU_SETTING_SOUND_EFFECT);
  596.     RegisterHighlightHandler(ExecuteCurrHiliteHandler);
  597.     ConstructHintsList(MENU_SETTING_SOUND_EFFECT, (U8 **) item_hints);
  598.     ShowCategory52Screen(
  599.         STR_ID_SETTING_SOUND_EFFECT,
  600.         IMG_SCR_SETTING_CAPTION,
  601.         STR_GLOBAL_OK,
  602.         IMG_GLOBAL_OK,
  603.         STR_GLOBAL_BACK,
  604.         IMG_GLOBAL_BACK,
  605.         n_items,
  606.         item_strs,
  607.         item_icons,
  608.         (U8 **) item_hints,
  609.         LIST_MENU,
  610.         0,
  611.         guiBuffer);
  612.     SetRightSoftkeyFunction(GoBackHistory, KEY_EVENT_UP);
  613. }
  614. #ifdef __MMI_EDITABLE_AUDIO_EQUALIZER__
  615. /*****************************************************************************
  616.  * FUNCTION
  617.  *  mmi_settings_audio_equalizer_adjust_values_for_editor
  618.  * DESCRIPTION
  619.  *  
  620.  * PARAMETERS
  621.  *  audio_equalizer_p       [?]     
  622.  * RETURNS
  623.  *  void
  624.  *****************************************************************************/
  625. void mmi_settings_audio_equalizer_adjust_values_for_editor(audio_equalizer_struct *audio_equalizer_p)
  626. {
  627.     /*----------------------------------------------------------------*/
  628.     /* Local Variables                                                */
  629.     /*----------------------------------------------------------------*/
  630.     U8 index, index1;
  631.     signed char temp[100];
  632.     S16 number_of_steps_in_bar;
  633.     /*----------------------------------------------------------------*/
  634.     /* Code Body                                                      */
  635.     /*----------------------------------------------------------------*/
  636.     MMI_ASSERT(g_audio_equalizer_scrollable_ht / g_audio_equalizer_unit_scroll <= 100);
  637.     MMI_ASSERT(audio_equalizer_p->count <= MAX_EQUALIZER_NUM);
  638.     MMI_ASSERT(audio_equalizer_p->index >= 0 && audio_equalizer_p->index < MAX_EQUALIZER_NUM);
  639.     //modifcation of values to make the equalizer user friendly and more meaningful.
  640.     //calculation of intervals for each bar:
  641.     number_of_steps_in_bar = g_audio_equalizer_scrollable_ht / g_audio_equalizer_unit_scroll;
  642.     for (index = 0; index < number_of_steps_in_bar; index++)
  643.     {
  644.         temp[index] = LOWER_LIMIT_SOUND_LEVEL / 10 + (index * (256 / number_of_steps_in_bar));
  645.     }
  646.     /* applying binary search algorithm for manipulation of values: */
  647.     for (index = 0; index < audio_equalizer_p->count; index++)
  648.     {
  649.         for (index1 = 0; index1 < NUM_OF_BARS_IN_A_SETTING; index1++)
  650.         {
  651.             signed char num_to_be_modified = audio_equalizer_p->magnitude[index][index1];
  652.             /* find the number closest to it in the temp array: */
  653.             int mid, left, right;
  654.             BOOL found = FALSE;
  655.             left = 0;
  656.             right = number_of_steps_in_bar - 1;
  657.             while (left < right)
  658.             {
  659.                 mid = (left + right) / 2;
  660.                 if (num_to_be_modified == temp[mid])
  661.                 {
  662.                     found = TRUE;
  663.                     break;
  664.                 }
  665.                 else if (num_to_be_modified < temp[mid])
  666.                 {
  667.                     right = mid - 1;
  668.                 }
  669.                 else
  670.                 {
  671.                     left = mid + 1;
  672.                 }
  673.             }
  674.             if (!found)
  675.             {
  676.                 if (left == right)  /* in this case the num_to_be_modified lies between left and left - 1 */
  677.                 {
  678.                     if (num_to_be_modified < temp[left])
  679.                     {
  680.                         /* her left will always be more than zero ....assuming that the value from NVRAM is with in range */
  681.                         if (num_to_be_modified - temp[left - 1] > temp[left] - num_to_be_modified)
  682.                         {
  683.                             audio_equalizer_p->magnitude[index][index1] = temp[left];
  684.                         }
  685.                         else
  686.                         {
  687.                             audio_equalizer_p->magnitude[index][index1] = temp[left - 1];
  688.                         }
  689.                     }
  690.                     else
  691.                     {
  692.                         if (left == number_of_steps_in_bar - 1)
  693.                         {
  694.                             if (num_to_be_modified - temp[left] > 127 - num_to_be_modified)
  695.                             {
  696.                                 audio_equalizer_p->magnitude[index][index1] = 127;
  697.                             }
  698.                             else
  699.                             {
  700.                                 audio_equalizer_p->magnitude[index][index1] = temp[left];
  701.                             }
  702.                         }
  703.                         else
  704.                         {
  705.                             if (num_to_be_modified - temp[left] > temp[left + 1] - num_to_be_modified)
  706.                             {
  707.                                 audio_equalizer_p->magnitude[index][index1] = temp[left + 1];
  708.                             }
  709.                             else
  710.                             {
  711.                                 audio_equalizer_p->magnitude[index][index1] = temp[left];
  712.                             }
  713.                         }
  714.                     }
  715.                 }
  716.                 else if (right < left)  /* in this case the num_to_be_modified lies between right and left */
  717.                 {
  718.                     if (num_to_be_modified - temp[right] > temp[left] - num_to_be_modified)
  719.                     {
  720.                         audio_equalizer_p->magnitude[index][index1] = temp[left];
  721.                     }
  722.                     else
  723.                     {
  724.                         audio_equalizer_p->magnitude[index][index1] = temp[right];
  725.                     }
  726.                 }
  727.             }
  728.         }
  729.     }
  730. }
  731. /*****************************************************************************
  732.  * FUNCTION
  733.  *  mmi_settings_audio_equalizer_restore_factory_default
  734.  * DESCRIPTION
  735.  *  This function is for restoring the settings to default values.
  736.  * PARAMETERS
  737.  *  void
  738.  * RETURNS
  739.  *  void
  740.  *****************************************************************************/
  741. void mmi_settings_audio_equalizer_restore_factory_default(void)
  742. {
  743. #ifdef MMI_ON_HARDWARE_P
  744.     /*----------------------------------------------------------------*/
  745.     /* Local Variables                                                */
  746.     /*----------------------------------------------------------------*/
  747.     /*----------------------------------------------------------------*/
  748.     /* Code Body                                                      */
  749.     /*----------------------------------------------------------------*/
  750.     memcpy(
  751.         (void*)&g_settings_audio_equalizer,
  752.         (void*)&NVRAM_EF_AUDIO_EQUALIZER_DEFAULT,
  753.         NVRAM_EF_AUDIO_EQUALIZER_SIZE);
  754. #else /* MMI_ON_HARDWARE_P */ 
  755.     g_settings_audio_equalizer.count = MAX_EQUALIZER_NUM;
  756.     g_settings_audio_equalizer.index = 0;
  757.     memset(g_settings_audio_equalizer.magnitude, 0, MAX_EQUALIZER_NUM * 8);
  758.     /* copy the names */
  759.     pfnUnicodeStrcpy((S8*) g_settings_audio_equalizer.setting_name[0], (S8*) L"Normal");
  760.     pfnUnicodeStrcpy((S8*) g_settings_audio_equalizer.setting_name[1], (S8*) L"Bass");
  761.     pfnUnicodeStrcpy((S8*) g_settings_audio_equalizer.setting_name[2], (S8*) L"Dance");
  762.     pfnUnicodeStrcpy((S8*) g_settings_audio_equalizer.setting_name[3], (S8*) L"Classical");
  763.     pfnUnicodeStrcpy((S8*) g_settings_audio_equalizer.setting_name[4], (S8*) L"Treble");
  764.     pfnUnicodeStrcpy((S8*) g_settings_audio_equalizer.setting_name[5], (S8*) L"Party");
  765.     pfnUnicodeStrcpy((S8*) g_settings_audio_equalizer.setting_name[6], (S8*) L"Pop");
  766.     pfnUnicodeStrcpy((S8*) g_settings_audio_equalizer.setting_name[7], (S8*) L"Rock");
  767.     pfnUnicodeStrcpy((S8*) g_settings_audio_equalizer.setting_name[8], (S8*) L"Restore Factory Default");
  768. #endif /* MMI_ON_HARDWARE_P */ 
  769.     mmi_settings_audio_equalizer_adjust_values_for_editor(&g_settings_audio_equalizer);
  770.     mdi_audio_set_equalizer(g_settings_audio_equalizer.magnitude[g_settings_audio_equalizer.index]);
  771.     mmi_settings_write_audio_equalizer_to_nvram(&g_settings_audio_equalizer);
  772.     DisplayPopup((PU8) GetString(STR_GLOBAL_DONE), IMG_GLOBAL_ACTIVATED, 1, UI_POPUP_NOTIFYDURATION_TIME, SUCCESS_TONE);
  773. }
  774. /*****************************************************************************
  775.  * FUNCTION
  776.  *  mmi_settings_entry_audio_equalizer_setting_options
  777.  * DESCRIPTION
  778.  *  This function is for entering the audio equalizer settings options screen
  779.  * PARAMETERS
  780.  *  void
  781.  * RETURNS
  782.  *  void
  783.  *****************************************************************************/
  784. void mmi_settings_entry_audio_equalizer_setting_options(void)
  785. {
  786.     /*----------------------------------------------------------------*/
  787.     /* Local Variables                                                */
  788.     /*----------------------------------------------------------------*/
  789.     U8 *guiBuffer;
  790.     U16 nStrItemList[3];    /* Stores the strings id of submenus returned */
  791.     U16 nNumofItem;         /* Stores no of children in the submenu */
  792.     U16 item_icons[] = {IMG_GLOBAL_L1, IMG_GLOBAL_L2, IMG_GLOBAL_L3};
  793.     U8 *item_popups[] = {NULL, NULL, NULL};
  794.     /*----------------------------------------------------------------*/
  795.     /* Code Body                                                      */
  796.     /*----------------------------------------------------------------*/
  797.     EntryNewScreen(
  798.         SCR_ID_SETTING_AUDIO_EQUALIZER_OPTIONS,
  799.         NULL,
  800.         mmi_settings_entry_audio_equalizer_setting_options,
  801.         NULL);
  802.     guiBuffer = GetCurrGuiBuffer(SCR_ID_SETTING_AUDIO_EQUALIZER_OPTIONS);
  803.     /*  Retrieve no of child of menu item to be displayed */
  804.     nNumofItem = GetNumOfChild(MENU_SETTING_AUDIO_EQUALIZER_SET_OPT);
  805.     /*  Retrieve string ids in sequence of given menu item to be displayed */
  806.     GetSequenceStringIds(MENU_SETTING_AUDIO_EQUALIZER_SET_OPT, nStrItemList);
  807.     /*  Set current parent id */
  808.     SetParentHandler(MENU_SETTING_AUDIO_EQUALIZER_SET_OPT);
  809.     RegisterHighlightHandler(ExecuteCurrHiliteHandler);
  810.     ShowCategory52Screen(
  811.         STR_GLOBAL_OPTIONS,
  812.         0,
  813.         STR_GLOBAL_OK,
  814.         IMG_GLOBAL_OK,
  815.         STR_GLOBAL_BACK,
  816.         IMG_GLOBAL_OK,
  817.         nNumofItem,
  818.         nStrItemList,
  819.         item_icons,
  820.         item_popups,
  821.         0,
  822.         0,
  823.         guiBuffer);
  824. }
  825. /*****************************************************************************
  826.  * FUNCTION
  827.  *  mmi_settings_audio_equalizer_opt_select_highlight_hdlr
  828.  * DESCRIPTION
  829.  *  This function is highlight handler for the select menu item.
  830.  * PARAMETERS
  831.  *  void
  832.  * RETURNS
  833.  *  void
  834.  *****************************************************************************/
  835. void mmi_settings_audio_equalizer_opt_select_highlight_hdlr(void)
  836. {
  837.     /*----------------------------------------------------------------*/
  838.     /* Local Variables                                                */
  839.     /*----------------------------------------------------------------*/
  840.     /*----------------------------------------------------------------*/
  841.     /* Code Body                                                      */
  842.     /*----------------------------------------------------------------*/
  843.     SetLeftSoftkeyFunction(mmi_settings_audio_equalizer_setting_select, KEY_EVENT_UP);
  844.     SetRightSoftkeyFunction(GoBackHistory, KEY_EVENT_UP);
  845.     SetKeyHandler(GoBackHistory, KEY_LEFT_ARROW, KEY_EVENT_DOWN);
  846. }
  847. /*****************************************************************************
  848.  * FUNCTION
  849.  *  mmi_settings_audio_equalizer_opt_edit_highlight_hdlr
  850.  * DESCRIPTION
  851.  *  This function is highlight handler for the edit menu item.
  852.  * PARAMETERS
  853.  *  void
  854.  * RETURNS
  855.  *  void
  856.  *****************************************************************************/
  857. void mmi_settings_audio_equalizer_opt_edit_highlight_hdlr(void)
  858. {
  859.     /*----------------------------------------------------------------*/
  860.     /* Local Variables                                                */
  861.     /*----------------------------------------------------------------*/
  862.     /*----------------------------------------------------------------*/
  863.     /* Code Body                                                      */
  864.     /*----------------------------------------------------------------*/
  865.     SetLeftSoftkeyFunction(mmi_settings_entry_audio_equalizer_setting_edit, KEY_EVENT_UP);
  866.     SetRightSoftkeyFunction(GoBackHistory, KEY_EVENT_UP);
  867.     SetKeyHandler(GoBackHistory, KEY_LEFT_ARROW, KEY_EVENT_DOWN);
  868.     SetKeyHandler(mmi_settings_entry_audio_equalizer_setting_edit, KEY_RIGHT_ARROW, KEY_EVENT_DOWN);
  869. }
  870. /*****************************************************************************
  871.  * FUNCTION
  872.  *  mmi_settings_audio_equalizer_opt_rename_highlight_hdlr
  873.  * DESCRIPTION
  874.  *  This function is highlight handler for the rename option
  875.  * PARAMETERS
  876.  *  void
  877.  * RETURNS
  878.  *  void
  879.  *****************************************************************************/
  880. void mmi_settings_audio_equalizer_opt_rename_highlight_hdlr(void)
  881. {
  882.     /*----------------------------------------------------------------*/
  883.     /* Local Variables                                                */
  884.     /*----------------------------------------------------------------*/
  885.     /*----------------------------------------------------------------*/
  886.     /* Code Body                                                      */
  887.     /*----------------------------------------------------------------*/
  888.     SetLeftSoftkeyFunction(mmi_settings_entry_audio_equalizer_setting_rename, KEY_EVENT_UP);
  889.     SetRightSoftkeyFunction(GoBackHistory, KEY_EVENT_UP);
  890.     SetKeyHandler(GoBackHistory, KEY_LEFT_ARROW, KEY_EVENT_DOWN);
  891.     SetKeyHandler(mmi_settings_entry_audio_equalizer_setting_rename, KEY_RIGHT_ARROW, KEY_EVENT_DOWN);
  892. }
  893. /*****************************************************************************
  894.  * FUNCTION
  895.  *  mmi_settings_audio_equalizer_setting_select
  896.  * DESCRIPTION
  897.  *  This function is for selecting a particular setting.
  898.  * PARAMETERS
  899.  *  void
  900.  * RETURNS
  901.  *  void
  902.  *****************************************************************************/
  903. void mmi_settings_audio_equalizer_setting_select(void)
  904. {
  905.     /*----------------------------------------------------------------*/
  906.     /* Local Variables                                                */
  907.     /*----------------------------------------------------------------*/
  908.     /*----------------------------------------------------------------*/
  909.     /* Code Body                                                      */
  910.     /*----------------------------------------------------------------*/
  911.     mmi_settings_select_audio_equalizer((S16) selected_audio_equalizer_index);
  912.     DisplayPopup((PU8) GetString(STR_GLOBAL_DONE), IMG_GLOBAL_ACTIVATED, 1, UI_POPUP_NOTIFYDURATION_TIME, SUCCESS_TONE);
  913.     DeleteScreenIfPresent(SCR_ID_SETTING_AUDIO_EQUALIZER_OPTIONS);
  914. }
  915. /*****************************************************************************
  916.  * FUNCTION
  917.  *  mmi_settings_entry_audio_equalizer_setting_edit
  918.  * DESCRIPTION
  919.  *  This function is for entering the editing screen.
  920.  * PARAMETERS
  921.  *  void
  922.  * RETURNS
  923.  *  void
  924.  *****************************************************************************/
  925. void mmi_settings_entry_audio_equalizer_setting_edit(void)
  926. {
  927.     /*----------------------------------------------------------------*/
  928.     /* Local Variables                                                */
  929.     /*----------------------------------------------------------------*/
  930.     U8 *guiBuffer;
  931.     /*----------------------------------------------------------------*/
  932.     /* Code Body                                                      */
  933.     /*----------------------------------------------------------------*/
  934.     EntryNewScreen(
  935.         SCR_ID_SETTING_AUDIO_EQUALIZER_OPTIONS_EDIT,
  936.         NULL,
  937.         mmi_settings_entry_audio_equalizer_setting_edit,
  938.         NULL);
  939.     guiBuffer = GetCurrGuiBuffer(SCR_ID_SETTING_AUDIO_EQUALIZER_OPTIONS_EDIT);
  940.     if (!guiBuffer)
  941.     {
  942.         g_audio_equalizer_current_setting_info.active_bar = 0;  /* initially the first bar is to be activated. */
  943.         ShowCategory334Screen(
  944.             STR_ID_SETTING_AUDIO_EQUALIZER_CAPTION,
  945.             0,
  946.             0,
  947.             0,
  948.             STR_GLOBAL_BACK,
  949.             IMG_GLOBAL_BACK,
  950.             g_settings_audio_equalizer.magnitude[selected_audio_equalizer_index],
  951.             guiBuffer);
  952.     }
  953.     else
  954.     {
  955.         if (g_audio_equalizer_setting_modified)
  956.         {
  957.             U8 index;
  958.             signed char changed_magnitude[NUM_OF_BARS_IN_A_SETTING];
  959.             for (index = 0; index < NUM_OF_BARS_IN_A_SETTING; index++)
  960.             {
  961.                 changed_magnitude[index] = g_audio_equalizer_current_setting_info.sound_level[index] / 10;
  962.             }
  963.             ShowCategory334Screen(
  964.                 STR_ID_SETTING_AUDIO_EQUALIZER_CAPTION,
  965.                 0,
  966.                 STR_GLOBAL_SAVE,
  967.                 0,
  968.                 STR_GLOBAL_BACK,
  969.                 IMG_GLOBAL_BACK,
  970.                 changed_magnitude,
  971.                 guiBuffer);
  972.             SetLeftSoftkeyFunction(mmi_settings_audio_equalizer_save_values, KEY_EVENT_UP);
  973.         }
  974.         else
  975.         {
  976.             ShowCategory334Screen(
  977.                 STR_ID_SETTING_AUDIO_EQUALIZER_CAPTION,
  978.                 0,
  979.                 0,
  980.                 0,
  981.                 STR_GLOBAL_BACK,
  982.                 IMG_GLOBAL_BACK,
  983.                 g_settings_audio_equalizer.magnitude[selected_audio_equalizer_index],
  984.                 guiBuffer);
  985.         }
  986.     }
  987.     SetKeyHandler(mmi_settings_audio_equalizer_activate_previous_bar, KEY_LEFT_ARROW, KEY_EVENT_DOWN);
  988.     SetKeyHandler(mmi_settings_audio_equalizer_activate_next_bar, KEY_RIGHT_ARROW, KEY_EVENT_DOWN);
  989.     SetKeyHandler(mmi_settings_audio_equalizer_increment_sound_level, KEY_UP_ARROW, KEY_EVENT_DOWN);
  990.     SetKeyHandler(mmi_settings_audio_equalizer_decrement_sound_level, KEY_DOWN_ARROW, KEY_EVENT_DOWN);
  991.     SetKeyHandler(mmi_settings_audio_equalizer_increment_sound_level, KEY_VOL_UP, KEY_EVENT_DOWN);
  992.     SetKeyHandler(mmi_settings_audio_equalizer_decrement_sound_level, KEY_VOL_DOWN, KEY_EVENT_DOWN);
  993.     SetRightSoftkeyFunction(mmi_settings_audio_equalizer_setting_edit_RSK_hdlr, KEY_EVENT_UP);
  994.     SetDelScrnIDCallbackHandler(SCR_ID_SETTING_AUDIO_EQUALIZER_OPTIONS_EDIT, (HistoryDelCBPtr) mmi_settings_audio_equalizer_delete_history_hdlr);
  995. }
  996. /*****************************************************************************
  997.  * FUNCTION
  998.  *  mmi_settings_audio_equalizer_delete_history_hdlr
  999.  * DESCRIPTION
  1000.  *  
  1001.  * PARAMETERS
  1002.  *  in_param     
  1003.  * RETURNS
  1004.  *  U8
  1005.  *****************************************************************************/
  1006. U8 mmi_settings_audio_equalizer_delete_history_hdlr(void *in_param)
  1007. {
  1008.     /*----------------------------------------------------------------*/
  1009.     /* Local Variables                                                */
  1010.     /*----------------------------------------------------------------*/
  1011.     /*----------------------------------------------------------------*/
  1012.     /* Code Body                                                      */
  1013.     /*----------------------------------------------------------------*/
  1014.     g_audio_equalizer_setting_modified = FALSE;
  1015.     return FALSE;
  1016. }
  1017. /*****************************************************************************
  1018.  * FUNCTION
  1019.  *  mmi_settings_audio_equalizer_setting_edit_RSK_hdlr
  1020.  * DESCRIPTION
  1021.  *  
  1022.  * PARAMETERS
  1023.  *  void
  1024.  * RETURNS
  1025.  *  void
  1026.  *****************************************************************************/
  1027. void mmi_settings_audio_equalizer_setting_edit_RSK_hdlr(void)
  1028. {
  1029.     /*----------------------------------------------------------------*/
  1030.     /* Local Variables                                                */
  1031.     /*----------------------------------------------------------------*/
  1032.     /*----------------------------------------------------------------*/
  1033.     /* Code Body                                                      */
  1034.     /*----------------------------------------------------------------*/
  1035.     /* reset the modification flag */
  1036.     g_audio_equalizer_setting_modified = FALSE;
  1037.     GoBackHistory();
  1038. }
  1039. /*****************************************************************************
  1040.  * FUNCTION
  1041.  *  mmi_settings_audio_equalizer_activate_previous_bar
  1042.  * DESCRIPTION
  1043.  *  This function is for activating the previous bar.
  1044.  * PARAMETERS
  1045.  *  void
  1046.  * RETURNS
  1047.  *  void
  1048.  *****************************************************************************/
  1049. void mmi_settings_audio_equalizer_activate_previous_bar(void)
  1050. {
  1051.     /*----------------------------------------------------------------*/
  1052.     /* Local Variables                                                */
  1053.     /*----------------------------------------------------------------*/
  1054.     /*----------------------------------------------------------------*/
  1055.     /* Code Body                                                      */
  1056.     /*----------------------------------------------------------------*/
  1057.     wgui_audio_equalizer_activate_bar((U8) ((NUM_OF_BARS_IN_A_SETTING +
  1058.                                              (g_audio_equalizer_current_setting_info.active_bar -
  1059.                                               1)) % NUM_OF_BARS_IN_A_SETTING));
  1060. }
  1061. /*****************************************************************************
  1062.  * FUNCTION
  1063.  *  mmi_settings_audio_equalizer_activate_next_bar
  1064.  * DESCRIPTION
  1065.  *  This function is for activating the next bar in the editing screen
  1066.  * PARAMETERS
  1067.  *  void
  1068.  * RETURNS
  1069.  *  void
  1070.  *****************************************************************************/
  1071. void mmi_settings_audio_equalizer_activate_next_bar(void)
  1072. {
  1073.     /*----------------------------------------------------------------*/
  1074.     /* Local Variables                                                */
  1075.     /*----------------------------------------------------------------*/
  1076.     /*----------------------------------------------------------------*/
  1077.     /* Code Body                                                      */
  1078.     /*----------------------------------------------------------------*/
  1079.     wgui_audio_equalizer_activate_bar((U8) ((g_audio_equalizer_current_setting_info.active_bar
  1080.                                              + 1) % NUM_OF_BARS_IN_A_SETTING));
  1081. }
  1082. /*****************************************************************************
  1083.  * FUNCTION
  1084.  *  mmi_settings_audio_equalizer_increment_sound_level
  1085.  * DESCRIPTION
  1086.  *  This function is to increase the sound level.
  1087.  * PARAMETERS
  1088.  *  void
  1089.  * RETURNS
  1090.  *  void
  1091.  *****************************************************************************/
  1092. void mmi_settings_audio_equalizer_increment_sound_level(void)
  1093. {
  1094.     /*----------------------------------------------------------------*/
  1095.     /* Local Variables                                                */
  1096.     /*----------------------------------------------------------------*/
  1097.     S16 sound_level = g_audio_equalizer_current_setting_info.sound_level[
  1098.         g_audio_equalizer_current_setting_info.active_bar];
  1099.     S16 delta = (S16) (g_audio_equalizer_unit_scroll * one_pixel_represents);
  1100.     S16 magnitude = (S16) g_settings_audio_equalizer.magnitude[
  1101.         selected_audio_equalizer_index][
  1102.         g_audio_equalizer_current_setting_info.active_bar];
  1103.     /*----------------------------------------------------------------*/
  1104.     /* Code Body                                                      */
  1105.     /*----------------------------------------------------------------*/
  1106.     sound_level += delta;
  1107.     if (sound_level > UPPER_LIMIT_SOUND_LEVEL)
  1108.     {
  1109.         sound_level = UPPER_LIMIT_SOUND_LEVEL;
  1110.     }
  1111.     g_audio_equalizer_current_setting_info.sound_level[
  1112.          g_audio_equalizer_current_setting_info.active_bar] = sound_level;
  1113.     if (!g_audio_equalizer_setting_modified && sound_level/10 != magnitude)
  1114.     {
  1115.         g_audio_equalizer_setting_modified = TRUE;
  1116.         ChangeLeftSoftkey(STR_GLOBAL_SAVE, 0);
  1117.         SetLeftSoftkeyFunction(mmi_settings_audio_equalizer_save_values, KEY_EVENT_UP);
  1118.     }
  1119.     wgui_audio_equalizer_change_sound_level();
  1120. }
  1121. /*****************************************************************************
  1122.  * FUNCTION
  1123.  *  mmi_settings_audio_equalizer_decrement_sound_level
  1124.  * DESCRIPTION
  1125.  *  This function is for decreasing the sound level.
  1126.  * PARAMETERS
  1127.  *  void
  1128.  * RETURNS
  1129.  *  void
  1130.  *****************************************************************************/
  1131. void mmi_settings_audio_equalizer_decrement_sound_level(void)
  1132. {
  1133.     /*----------------------------------------------------------------*/
  1134.     /* Local Variables                                                */
  1135.     /*----------------------------------------------------------------*/
  1136.     S16 sound_level = g_audio_equalizer_current_setting_info.sound_level[
  1137.         g_audio_equalizer_current_setting_info.active_bar];
  1138.     S16 delta = (S16) (g_audio_equalizer_unit_scroll * one_pixel_represents);
  1139.     S16 magnitude = (S16) g_settings_audio_equalizer.magnitude[
  1140.         selected_audio_equalizer_index][
  1141.         g_audio_equalizer_current_setting_info.active_bar];
  1142.     /*----------------------------------------------------------------*/
  1143.     /* Code Body                                                      */
  1144.     /*----------------------------------------------------------------*/
  1145.     sound_level -= delta;
  1146.     if ( sound_level < LOWER_LIMIT_SOUND_LEVEL)
  1147.     {
  1148.         sound_level = LOWER_LIMIT_SOUND_LEVEL;
  1149.     }
  1150.     g_audio_equalizer_current_setting_info.sound_level[
  1151.         g_audio_equalizer_current_setting_info.active_bar] = sound_level;
  1152.     if (!g_audio_equalizer_setting_modified && sound_level/10 != magnitude)
  1153.     {
  1154.         g_audio_equalizer_setting_modified = TRUE;
  1155.         ChangeLeftSoftkey(STR_GLOBAL_SAVE, 0);
  1156.         SetLeftSoftkeyFunction(mmi_settings_audio_equalizer_save_values, KEY_EVENT_UP);
  1157.     }
  1158.     wgui_audio_equalizer_change_sound_level();
  1159. }
  1160. #ifdef __MMI_TOUCH_SCREEN__
  1161. /*****************************************************************************
  1162.  * FUNCTION
  1163.  *  mmi_settings_audio_equalizer_change_sound_level
  1164.  * DESCRIPTION
  1165.  *  
  1166.  * PARAMETERS
  1167.  *  change      [IN]        
  1168.  * RETURNS
  1169.  *  void
  1170.  *****************************************************************************/
  1171. void mmi_settings_audio_equalizer_change_sound_level(S16 change)
  1172. {
  1173.     /*----------------------------------------------------------------*/
  1174.     /* Local Variables                                                */
  1175.     /*----------------------------------------------------------------*/
  1176.     S16 sound_level = g_audio_equalizer_current_setting_info.sound_level[
  1177.         g_audio_equalizer_current_setting_info.active_bar];
  1178.     S16 magnitude = (S16) g_settings_audio_equalizer.magnitude[
  1179.         selected_audio_equalizer_index][
  1180.         g_audio_equalizer_current_setting_info.active_bar];
  1181.     /*----------------------------------------------------------------*/
  1182.     /* Code Body                                                      */
  1183.     /*----------------------------------------------------------------*/
  1184.     sound_level += change;
  1185.     /* since the scrollable height for the +ve side and -ve side is same and the absolute val of the max and min
  1186.        limits (1270 and -1280)is different so we need to modify the +ve value when it to becomes 1280. */
  1187.     if (sound_level > UPPER_LIMIT_SOUND_LEVEL)
  1188.     {
  1189.         sound_level = UPPER_LIMIT_SOUND_LEVEL;
  1190.     }
  1191.     else if(sound_level < LOWER_LIMIT_SOUND_LEVEL)
  1192.     {
  1193.         sound_level = LOWER_LIMIT_SOUND_LEVEL;
  1194.     }
  1195.     g_audio_equalizer_current_setting_info.sound_level[
  1196.         g_audio_equalizer_current_setting_info.active_bar] = sound_level;
  1197.     if (!g_audio_equalizer_setting_modified && sound_level/10 != magnitude)
  1198.     {
  1199.         g_audio_equalizer_setting_modified = TRUE;
  1200.         ChangeLeftSoftkey(STR_GLOBAL_SAVE, 0);
  1201.         SetLeftSoftkeyFunction(mmi_settings_audio_equalizer_save_values, KEY_EVENT_UP);
  1202.     }
  1203.     wgui_audio_equalizer_change_sound_level();
  1204. }
  1205. #endif /* __MMI_TOUCH_SCREEN__ */ 
  1206. /*****************************************************************************
  1207.  * FUNCTION
  1208.  *  mmi_settings_audio_equalizer_save_values
  1209.  * DESCRIPTION
  1210.  *  This function is for saving the values of the edited setting.
  1211.  * PARAMETERS
  1212.  *  void
  1213.  * RETURNS
  1214.  *  void
  1215.  *****************************************************************************/
  1216. void mmi_settings_audio_equalizer_save_values(void)
  1217. {
  1218.     /*----------------------------------------------------------------*/
  1219.     /* Local Variables                                                */
  1220.     /*----------------------------------------------------------------*/
  1221.     U8 index;
  1222.     /*----------------------------------------------------------------*/
  1223.     /* Code Body                                                      */
  1224.     /*----------------------------------------------------------------*/
  1225.     /* 1. copy the values to the global audio equalizer setting structure */
  1226.     for (index = 0; index < NUM_OF_BARS_IN_A_SETTING; index++)
  1227.     {
  1228.         g_settings_audio_equalizer.magnitude[selected_audio_equalizer_index][index] =
  1229.             g_audio_equalizer_current_setting_info.sound_level[index] / 10;
  1230.     }
  1231.     /* reset the modification flag */
  1232.     g_audio_equalizer_setting_modified = FALSE;
  1233.     if (g_settings_audio_equalizer.index == selected_audio_equalizer_index)
  1234.     {
  1235.         mdi_audio_set_equalizer(g_settings_audio_equalizer.magnitude[selected_audio_equalizer_index]);
  1236.     }
  1237.     mmi_settings_write_audio_equalizer_to_nvram(&g_settings_audio_equalizer);
  1238.     DisplayPopup((PU8) GetString(STR_GLOBAL_DONE), IMG_GLOBAL_ACTIVATED, 1, UI_POPUP_NOTIFYDURATION_TIME, SUCCESS_TONE);
  1239. }
  1240. /* renaming related functions */
  1241. /*****************************************************************************
  1242.  * FUNCTION
  1243.  *  mmi_settings_entry_audio_equalizer_setting_rename
  1244.  * DESCRIPTION
  1245.  *  
  1246.  * PARAMETERS
  1247.  *  void
  1248.  * RETURNS
  1249.  *  void
  1250.  *****************************************************************************/
  1251. void mmi_settings_entry_audio_equalizer_setting_rename(void)
  1252. {
  1253.     /*----------------------------------------------------------------*/
  1254.     /* Local Variables                                                */
  1255.     /*----------------------------------------------------------------*/
  1256.     U8 *gui_buffer;
  1257.     /*----------------------------------------------------------------*/
  1258.     /* Code Body                                                      */
  1259.     /*----------------------------------------------------------------*/
  1260.     EntryNewScreen(
  1261.         SCR_ID_AUDIO_EQUALIZER_SETTING_NAME_EDIT,
  1262.         NULL,
  1263.         mmi_settings_entry_audio_equalizer_setting_rename,
  1264.         NULL);
  1265.     if ((gui_buffer = GetCurrGuiBuffer(SCR_ID_AUDIO_EQUALIZER_SETTING_NAME_EDIT)) == NULL)
  1266.     {
  1267.         pfnUnicodeStrcpy(
  1268.             (S8*) name_text_editor_buffer,
  1269.             (S8*) g_settings_audio_equalizer.setting_name[selected_audio_equalizer_index]);
  1270.     }
  1271.     ShowCategory5Screen(
  1272.         STR_ID_SETTING_AUDIO_EQUALIZER_SETTIN_NAME_EDIT_TITLE,
  1273.         0,
  1274.         STR_GLOBAL_OPTIONS,
  1275.         0,
  1276.         STR_GLOBAL_BACK,
  1277.         0,
  1278.         INPUT_TYPE_ALPHANUMERIC_SENTENCECASE | INPUT_TYPE_USE_ENCODING_BASED_LENGTH,
  1279.         (U8*) name_text_editor_buffer,
  1280.         SETTING_NAME_MAX_LEN,
  1281.         gui_buffer);
  1282.     SetLeftSoftkeyFunction(mmi_settings_entry_audio_equalizer_setting_name_edit_option, KEY_EVENT_UP);
  1283.     SetCategory5RightSoftkeyFunction(GoBackHistory, KEY_EVENT_UP);
  1284.     RegisterInputMethodScreenCloseFunction(GoBackHistory);
  1285. }
  1286. /*****************************************************************************
  1287.  * FUNCTION
  1288.  *  mmi_settings_entry_audio_equalizer_setting_name_edit_option
  1289.  * DESCRIPTION
  1290.  *  
  1291.  * PARAMETERS
  1292.  *  void
  1293.  * RETURNS
  1294.  *  void
  1295.  *****************************************************************************/
  1296. void mmi_settings_entry_audio_equalizer_setting_name_edit_option(void)
  1297. {
  1298.     /*----------------------------------------------------------------*/
  1299.     /* Local Variables                                                */
  1300.     /*----------------------------------------------------------------*/
  1301.     U16 item_texts[] = {STR_GLOBAL_DONE, STR_GLOBAL_INPUT_METHOD};
  1302.     U16 item_icons[] = {IMG_GLOBAL_L1, IMG_GLOBAL_L2};
  1303.     /*----------------------------------------------------------------*/
  1304.     /* Code Body                                                      */
  1305.     /*----------------------------------------------------------------*/
  1306.     EntryNewScreen(
  1307.         SCR_ID_AUDIO_EQUALIZER_SETTING_NAME_EDIT_OPTION,
  1308.         NULL,
  1309.         mmi_settings_entry_audio_equalizer_setting_name_edit_option,
  1310.         NULL);
  1311.     RegisterHighlightHandler(mmi_settings_audio_equalizer_setting_name_edit_option_highlight_hdlr);
  1312.     ShowCategory52Screen(
  1313.         STR_GLOBAL_OPTIONS,
  1314.         0,
  1315.         STR_GLOBAL_OK,
  1316.         0,
  1317.         STR_GLOBAL_BACK,
  1318.         0,
  1319.         2,
  1320.         item_texts,
  1321.         item_icons,
  1322.         NULL,
  1323.         0,
  1324.         0,
  1325.         NULL);
  1326.     /* register left, right arrow key handlers */
  1327.     SetKeyHandler(GoBackHistory, KEY_LEFT_ARROW, KEY_EVENT_DOWN);
  1328.     SetKeyHandler(mmi_settings_audio_equalizer_setting_name_edit_option_LSK, KEY_RIGHT_ARROW, KEY_EVENT_DOWN);
  1329.     /* register LSK, RSK handlers */
  1330.     SetLeftSoftkeyFunction(mmi_settings_audio_equalizer_setting_name_edit_option_LSK, KEY_EVENT_UP);
  1331.     SetRightSoftkeyFunction(GoBackHistory, KEY_EVENT_UP);
  1332. }
  1333. /*****************************************************************************
  1334.  * FUNCTION
  1335.  *  mmi_settings_audio_equalizer_setting_name_edit_option_highlight_hdlr
  1336.  * DESCRIPTION
  1337.  *  
  1338.  * PARAMETERS
  1339.  *  index       [IN]        
  1340.  * RETURNS
  1341.  *  void
  1342.  *****************************************************************************/
  1343. void mmi_settings_audio_equalizer_setting_name_edit_option_highlight_hdlr(S32 index)
  1344. {
  1345.     /*----------------------------------------------------------------*/
  1346.     /* Local Variables                                                */
  1347.     /*----------------------------------------------------------------*/
  1348.     U16 item_texts[] = {STR_GLOBAL_DONE, STR_GLOBAL_INPUT_METHOD};
  1349.     /*----------------------------------------------------------------*/
  1350.     /* Code Body                                                      */
  1351.     /*----------------------------------------------------------------*/
  1352.     setting_name_edit_option_highlighted_item_text = item_texts[index];
  1353. }
  1354. /*****************************************************************************
  1355.  * FUNCTION
  1356.  *  mmi_settings_audio_equalizer_setting_name_edit_option_LSK
  1357.  * DESCRIPTION
  1358.  *  
  1359.  * PARAMETERS
  1360.  *  void
  1361.  * RETURNS
  1362.  *  void
  1363.  *****************************************************************************/
  1364. void mmi_settings_audio_equalizer_setting_name_edit_option_LSK(void)
  1365. {
  1366.     /*----------------------------------------------------------------*/
  1367.     /* Local Variables                                                */
  1368.     /*----------------------------------------------------------------*/
  1369.     /*----------------------------------------------------------------*/
  1370.     /* Code Body                                                      */
  1371.     /*----------------------------------------------------------------*/
  1372.     switch (setting_name_edit_option_highlighted_item_text)
  1373.     {
  1374.         case STR_GLOBAL_DONE:
  1375.             if (pfnUnicodeStrlen((S8*) name_text_editor_buffer) != 0)
  1376.             {
  1377.                 pfnUnicodeStrcpy(
  1378.                     (S8*) g_settings_audio_equalizer.setting_name[selected_audio_equalizer_index],
  1379.                     (S8*) name_text_editor_buffer);
  1380.                 mmi_settings_write_audio_equalizer_to_nvram(&g_settings_audio_equalizer);
  1381.                 DisplayPopup(
  1382.                     (PU8) GetString(STR_GLOBAL_DONE),
  1383.                     IMG_GLOBAL_ACTIVATED,
  1384.                     1,
  1385.                     UI_POPUP_NOTIFYDURATION_TIME,
  1386.                     SUCCESS_TONE);
  1387.                 DeleteScreenIfPresent(SCR_ID_AUDIO_EQUALIZER_SETTING_NAME_EDIT_OPTION);
  1388.                 DeleteScreenIfPresent(SCR_ID_AUDIO_EQUALIZER_SETTING_NAME_EDIT);
  1389.             }
  1390.             else
  1391.             {
  1392.                 DisplayPopup(
  1393.                     (PU8) GetString(STR_ID_SETTING_AUDIO_EQUALIZER_SETTING_INVALID_NAME),
  1394.                     0,
  1395.                     1,
  1396.                     UI_POPUP_NOTIFYDURATION_TIME,
  1397.                     SUCCESS_TONE);
  1398.             }
  1399.             break;
  1400.         case STR_GLOBAL_INPUT_METHOD:
  1401.             EntryInputMethodScreen();
  1402.             DeleteScreenIfPresent(SCR_ID_AUDIO_EQUALIZER_SETTING_NAME_EDIT_OPTION);
  1403.             break;
  1404.     }
  1405. }
  1406. #endif /* __MMI_EDITABLE_AUDIO_EQUALIZER__ */ 
  1407. #endif /* __MMI_SOUND_EFFECT__ */ 
  1408. /*****************************************************************************
  1409.  * FUNCTION
  1410.  *  mmi_settings_read_audio_mic_volume_from_nvram
  1411.  * DESCRIPTION
  1412.  *  
  1413.  * PARAMETERS
  1414.  *  audio_mic_volume_p      [?]     
  1415.  * RETURNS
  1416.  *  void
  1417.  *****************************************************************************/
  1418. void mmi_settings_read_audio_mic_volume_from_nvram(audio_mic_volume_struct *audio_mic_volume_p)
  1419. {
  1420. #ifdef MMI_ON_HARDWARE_P
  1421.     /*----------------------------------------------------------------*/
  1422.     /* Local Variables                                                */
  1423.     /*----------------------------------------------------------------*/
  1424.     S16 error;
  1425.     U16 mic_volume_set;
  1426.     U8 set_index;
  1427.     unsigned char *ptr = (unsigned char*)&mic_volume_set;
  1428.     /*----------------------------------------------------------------*/
  1429.     /* Code Body                                                      */
  1430.     /*----------------------------------------------------------------*/
  1431.     ReadValue(NVRAM_AUDIO_MIC_VOLUME_SET, &mic_volume_set, DS_SHORT, &error);
  1432.     for (set_index = 0; set_index < AUDIO_MIC_SET_NUM; set_index++)
  1433.     {
  1434.         /* check if the value from NVRAM an invalid data */
  1435.         if (*ptr == 0xFF)
  1436.         {
  1437.             ptr = (unsigned char*)&mic_volume_set;
  1438.             /* reset in call mic volume level to 3 */
  1439.             audio_mic_volume_p->levels[AUDIO_MIC_IN_CALL] = *ptr++ = 3;
  1440.             /* reset app mic volume level to 4 */
  1441.             audio_mic_volume_p->levels[AUDIO_MIC_APP] = *ptr++ = 4;
  1442.             WriteValue(NVRAM_AUDIO_MIC_VOLUME_SET, &mic_volume_set, DS_SHORT, &error);
  1443.             break;
  1444.         }
  1445.         else
  1446.         {
  1447.             audio_mic_volume_p->levels[set_index] = *ptr++;
  1448.         }
  1449.     }
  1450. #endif /* MMI_ON_HARDWARE_P */ 
  1451. }
  1452. /*****************************************************************************
  1453.  * FUNCTION
  1454.  *  mmi_settings_write_audio_mic_volume_to_nvram
  1455.  * DESCRIPTION
  1456.  *  
  1457.  * PARAMETERS
  1458.  *  audio_mic_volume_p      [?]     
  1459.  * RETURNS
  1460.  *  void
  1461.  *****************************************************************************/
  1462. void mmi_settings_write_audio_mic_volume_to_nvram(audio_mic_volume_struct *audio_mic_volume_p)
  1463. {
  1464. #ifdef MMI_ON_HARDWARE_P
  1465.     /*----------------------------------------------------------------*/
  1466.     /* Local Variables                                                */
  1467.     /*----------------------------------------------------------------*/
  1468.     S16 error;
  1469.     U16 mic_volume_set;
  1470.     U8 set_index;
  1471.     unsigned char *ptr = (unsigned char*)&mic_volume_set;
  1472.     /*----------------------------------------------------------------*/
  1473.     /* Code Body                                                      */
  1474.     /*----------------------------------------------------------------*/
  1475.     for (set_index = 0; set_index < AUDIO_MIC_SET_NUM; set_index++)
  1476.     {
  1477.         *ptr++ = audio_mic_volume_p->levels[set_index];
  1478.     }
  1479.     WriteValue(NVRAM_AUDIO_MIC_VOLUME_SET, &mic_volume_set, DS_SHORT, &error);
  1480. #endif /* MMI_ON_HARDWARE_P */ 
  1481. }