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

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. * Filename:
  37. * ---------
  38. *  gui_spectrum.c
  39. *
  40. * Project:
  41. * --------
  42. *   MAUI
  43. *
  44. * Description:
  45. * ------------
  46. *   audio spectrum display APIs
  47. *
  48. * Author:
  49. * -------
  50. *  Pankaj
  51. *
  52. *==============================================================================
  53. *           HISTORY
  54. * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!! 
  55. *------------------------------------------------------------------------------
  56. * $Log$
  57.  *
  58.  * removed!
  59.  * removed!
  60.  * 
  61.  *
  62.  * removed!
  63.  * removed!
  64.  * 
  65.  *
  66.  * removed!
  67.  * removed!
  68.  * 
  69.  *
  70.  * removed!
  71.  * removed!
  72.  * 
  73.  *
  74.  * removed!
  75.  * removed!
  76.  * 
  77.  *
  78.  * removed!
  79.  * removed!
  80.  * 
  81.  *
  82.  * removed!
  83.  * removed!
  84.  * 
  85. *
  86. *------------------------------------------------------------------------------
  87. * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!! 
  88. *==============================================================================
  89. *******************************************************************************/
  90. #include "MMI_features.h"
  91. #ifdef __MMI_AUDIO_SPECTRUM_DISPLAY__
  92. #include "gui_spectrum.h"
  93. #include "gdi_include.h"
  94. #include "gui.h"
  95. #include "DebugInitDef.h"
  96. #include "mdi_datatype.h"
  97. #include "mdi_audio.h"
  98. extern gd_color_from_rgb_func gdi_act_color_from_rgb;
  99. extern void gd_draw_ellipse16(
  100.                 U16 *dstPtr,
  101.                 int destWidth,
  102.                 int x,
  103.                 int y,
  104.                 int arcWidth,
  105.                 int arcHeight,
  106.                 int clipx1,
  107.                 int clipy1,
  108.                 int clipx2,
  109.                 int clipy2,
  110.                 gdi_color color,
  111.                 BOOL dotted);
  112. extern void gd_fill_ellipse16(
  113.                 U16 *dstPtr,
  114.                 int destWidth,
  115.                 int x,
  116.                 int y,
  117.                 int arcWidth,
  118.                 int arcHeight,
  119.                 int clipx1,
  120.                 int clipy1,
  121.                 int clipx2,
  122.                 int clipy2,
  123.                 gdi_color color);
  124. /* HARDCODE */
  125. spectrum_struct *g_ui_spectrum_list[MAX_NUM_OF_SPECTRUMS] = {NULL, NULL, NULL, NULL, NULL};
  126. U8 amplitude_val[16];
  127. U8 top[16];
  128. U16 g_ui_spectrum_timer_interval = 150; /* ms */
  129. U8 g_ui_spectrum_active_count = 0;  /* how many spectrums atre active */
  130. BOOL g_ui_spectrum_no_blt_after_clear = FALSE;  /* flag used for deciding whether the blt should be done after clear. */
  131. U8 g_ui_spectrum_odd_even_identifier = 1;   /* In case of STYLE_CIRCLES, odd and even positioned vals are shown turn by turn. */
  132. /* 1 means odd vals and 2 means even vals. */
  133. /*****************************************************************************
  134.  * FUNCTION
  135.  *  mmi_audio_spectrum_init_display
  136.  * DESCRIPTION
  137.  *  
  138.  * PARAMETERS
  139.  *  spectrum        [?]     
  140.  * RETURNS
  141.  *  
  142.  *****************************************************************************/
  143. BOOL mmi_audio_spectrum_init_display(spectrum_struct *spectrum)
  144. {
  145.     /*----------------------------------------------------------------*/
  146.     /* Local Variables                                                */
  147.     /*----------------------------------------------------------------*/
  148.     GDI_HANDLE present_lcd;
  149.     int index = 0;
  150.     int row, col;
  151.     BOOL found = FALSE;
  152.     int ind ;
  153.     S32 hrzntl_space_for_bars = 0;
  154.     S16 no_of_blocks_in_block_style;
  155.     S16 bar_width = 0;
  156.     /*----------------------------------------------------------------*/
  157.     /* Code Body                                                      */
  158.     /*----------------------------------------------------------------*/
  159.     /* proceed only if there is room for the spectrum */
  160.     for (ind = 0; ind < MAX_NUM_OF_SPECTRUMS; ind++)
  161.     {
  162.         if(g_ui_spectrum_list[ind] == spectrum)
  163.         {
  164.             found = TRUE;
  165.             index = ind;
  166.             break;
  167.         }
  168.         else if(g_ui_spectrum_list[ind] == NULL && found == FALSE)
  169.         {
  170.             found = TRUE;
  171.             index = ind;
  172.         }
  173.     }
  174.     
  175.     if(found) //(g_ui_spectrum_list[index] == spectrum || g_ui_spectrum_list[index] == NULL)
  176.     {
  177.         // check if the spectrum already exist in the list, if so, check if it's already active, then to stop it
  178.         // this case will happen when a spectrum is re-inited without stopping it
  179.         if (g_ui_spectrum_list[index] == spectrum)
  180.         {
  181.             if (spectrum->active)
  182.             {
  183.                 if (--g_ui_spectrum_active_count == 0)
  184.                 {
  185.                     gui_cancel_timer(mmi_audio_spectrum_display_timer);
  186.                 }
  187.             }
  188.         }
  189.         spectrum->active = FALSE;
  190.         gdi_lcd_get_active(&present_lcd);
  191.         if (spectrum->target_lcd == GDI_LCD_SUB_LCD_HANDLE && present_lcd == GDI_LCD_MAIN_LCD_HANDLE)
  192.         {
  193.             UI_set_sub_LCD_graphics_context();  /* switch to sub lcd graphic context */
  194.         }
  195.         else if (spectrum->target_lcd == GDI_LCD_MAIN_LCD_HANDLE && present_lcd == GDI_LCD_SUB_LCD_HANDLE)
  196.         {
  197.             UI_set_main_LCD_graphics_context(); /* switch to sub lcd graphic context */
  198.         }
  199.     #ifdef __GDI_MEMORY_PROFILE_2__
  200.         if (spectrum->target_layer)
  201.         {
  202.             gdi_layer_push_and_set_active(spectrum->target_layer);
  203.         }
  204.     #endif /* __GDI_MEMORY_PROFILE_2__ */ 
  205.         gdi_layer_lock_frame_buffer();
  206.         gdi_layer_push_clip();
  207.         gdi_layer_set_clip(
  208.             spectrum->start_x,
  209.             spectrum->start_y,
  210.             spectrum->start_x + spectrum->width,
  211.             spectrum->start_y + spectrum->height);
  212.         if (spectrum->style == STYLE_BARS || spectrum->style == STYLE_BLOCKS)
  213.         {
  214.             /* check for proper parameters for bar and block styles. */
  215.             if (spectrum->width <
  216.                 (spectrum->number_of_bars * (MIN_BAR_WIDTH) +
  217.                  (spectrum->number_of_bars + 1) * DIST_BETWEEN_BARS /* + SPACE_FOR_SCALE * 2 */ ))
  218.             {
  219.                 MMI_ASSERT(0);
  220.             }
  221.             else if (spectrum->height < ( /* SPACE_FOR_SCALE + */ DIST_BETWEEN_BLOCKS + BLOCK_HEIGHT))
  222.             {
  223.                 MMI_ASSERT(0);
  224.             }
  225.         #if 0
  226. /* under construction !*/
  227. /* under construction !*/
  228. /* under construction !*/
  229. /* under construction !*/
  230. /* under construction !*/
  231. /* under construction !*/
  232. /* under construction !*/
  233. /* under construction !*/
  234. /* under construction !*/
  235. /* under construction !*/
  236. /* under construction !*/
  237. /* under construction !*/
  238. /* under construction !*/
  239. /* under construction !*/
  240. /* under construction !*/
  241. /* under construction !*/
  242.         #endif /* 0 */ 
  243.             /* find the bar width ... */
  244.             hrzntl_space_for_bars = spectrum->width - DIST_BETWEEN_BARS * (spectrum->number_of_bars + 1);   /* 2 * (spectrum->number_of_bars + 1) 
  245.                                                                                                                is sub. for leaving 2 pixel space between the various bars. */
  246.             if (hrzntl_space_for_bars % spectrum->number_of_bars)
  247.             {
  248.                 bar_width =
  249.                     (hrzntl_space_for_bars -
  250.                      (hrzntl_space_for_bars % spectrum->number_of_bars)) / spectrum->number_of_bars;
  251.             }
  252.             else
  253.             {
  254.                 bar_width = hrzntl_space_for_bars / spectrum->number_of_bars;
  255.             }
  256.         #if 0
  257. /* under construction !*/
  258. /* under construction !*/
  259. /* under construction !*/
  260. /* under construction !*/
  261. /* under construction !*/
  262. /* under construction !*/
  263. /* under construction !*/
  264. /* under construction !*/
  265. /* under construction !*/
  266. /* under construction !*/
  267. /* under construction !*/
  268. /* under construction !*/
  269. /* under construction !*/
  270. /* under construction !*/
  271. /* under construction !*/
  272.         #endif /* 0 */ 
  273.         }
  274.         else    /* if(spectrum->style == STYLE_CIRCLES) */
  275.         {
  276.             unsigned char alpha, r, g, b;
  277.             int center_x, center_y, radius_x, radius_y, ellipse_index;
  278.             int radius_x_dec, radius_y_dec;
  279.             radius_x_dec = radius_y_dec = 1;
  280.             /* check for the minimum space required for making the Circles Style. */
  281.             if ((spectrum->width - SPACE_TO_BE_LEFT_FOR_CIRCLES_STYLE) < (spectrum->number_of_bars * 2) ||
  282.                 (spectrum->height - SPACE_TO_BE_LEFT_FOR_CIRCLES_STYLE) < (spectrum->number_of_bars * 2))
  283.             {
  284.                 MMI_ASSERT(0);
  285.             }
  286.             else    /* here the extra width and height are equally distributed among the circles.and then the separation */
  287.             {       /* between each of the circles is calculated. */
  288.                 int tempx, tempy;
  289.                 tempx = (spectrum->width - SPACE_TO_BE_LEFT_FOR_CIRCLES_STYLE) / (spectrum->number_of_bars * 2);
  290.                 tempy = (spectrum->height - SPACE_TO_BE_LEFT_FOR_CIRCLES_STYLE) / (spectrum->number_of_bars * 2);
  291.                 radius_x_dec += (tempx - 1);
  292.                 radius_y_dec += (tempy - 1);
  293.             }
  294.             center_x = spectrum->start_x + spectrum->width / 2;
  295.             center_y = spectrum->start_y + spectrum->height / 2;
  296.             radius_x = (spectrum->width - SPACE_TO_BE_LEFT_FOR_CIRCLES_STYLE) / 2;
  297.             radius_y = (spectrum->height - SPACE_TO_BE_LEFT_FOR_CIRCLES_STYLE) / 2;
  298.             alpha = 50;
  299.             r = 255;
  300.             b = 0;
  301.             g = 0;
  302.             gdi_draw_solid_rect(
  303.                 spectrum->start_x,
  304.                 spectrum->start_y,
  305.                 spectrum->start_x + spectrum->width,
  306.                 spectrum->start_y + spectrum->height,
  307.                 GDI_COLOR_TRANSPARENT /* gdi_act_color_from_rgb(0xFF,0,0,0) */ );
  308.             GDI_LOCK;
  309.             for (ellipse_index = spectrum->number_of_bars; ellipse_index > 0; ellipse_index--)
  310.             {
  311.                 gd_draw_ellipse16(
  312.                     (U16*) gdi_act_layer->buf_ptr,
  313.                     gdi_act_layer->width,
  314.                     center_x,
  315.                     center_y,
  316.                     radius_x,
  317.                     radius_y,
  318.                     gdi_act_layer->clipx1,
  319.                     gdi_act_layer->clipy1,
  320.                     gdi_act_layer->clipx2,
  321.                     gdi_act_layer->clipy2,
  322.                     gdi_act_color_from_rgb(alpha, r, g, b),
  323.                     0);
  324.                 radius_x -= radius_x_dec;
  325.                 radius_y -= radius_y_dec;
  326.                 r -= 10;
  327.                 b += 10;
  328.                 g += 5;
  329.             }
  330.             GDI_UNLOCK;
  331.         }
  332.         switch (spectrum->style)
  333.         {
  334.             case STYLE_BLOCKS:
  335.             {
  336.                 int start_x, start_y, end_x, end_y;
  337.                 start_x = spectrum->start_x;
  338.                 start_y = spectrum->start_y;
  339.                 end_x = spectrum->start_x + spectrum->width - 1;
  340.                 end_y = start_y + spectrum->height - 1;
  341.                 gdi_draw_solid_rect(
  342.                     start_x,
  343.                     start_y,
  344.                     end_x,
  345.                     end_y,
  346.                     GDI_COLOR_TRANSPARENT /* gdi_act_color_from_rgb(0x0,204,230,229) */ );
  347.                 /* calculate the maximum no. of blocks in each column/bar in spectrum */
  348.                 no_of_blocks_in_block_style = spectrum->height / (DIST_BETWEEN_BLOCKS + BLOCK_HEIGHT);
  349.                 /* draw the light colored rectangles */
  350.                 for (col = 0; col < spectrum->number_of_bars; col++)
  351.                 {
  352.                     if (col == 0)
  353.                     {
  354.                         start_x =
  355.                             spectrum->start_x + (hrzntl_space_for_bars % spectrum->number_of_bars) / 2 +
  356.                             DIST_BETWEEN_BARS;
  357.                         end_x = start_x + bar_width - 1;
  358.                     }
  359.                     else
  360.                     {
  361.                         start_x = start_x + bar_width + DIST_BETWEEN_BARS;
  362.                         end_x = start_x + bar_width - 1;
  363.                     }
  364.                     for (row = 0; row < no_of_blocks_in_block_style; row++)
  365.                     {
  366.                         if (row == 0)
  367.                         {
  368.                             start_y =
  369.                                 spectrum->start_y + (spectrum->height - 1) - DIST_BETWEEN_BLOCKS - (BLOCK_HEIGHT -
  370.                                                                                                     1);
  371.                             end_y = start_y + BLOCK_HEIGHT - 1;
  372.                         }
  373.                         else
  374.                         {
  375.                             start_y = (start_y - 1) - DIST_BETWEEN_BLOCKS - (BLOCK_HEIGHT - 1);
  376.                             end_y = start_y + BLOCK_HEIGHT - 1;
  377.                         }
  378.                         gdi_draw_solid_rect(
  379.                             start_x,
  380.                             start_y,
  381.                             end_x,
  382.                             end_y,
  383.                             GDI_COLOR_TRANSPARENT /* SPECTRUM_BKGD_COLOR_BLOCK_STYLE */ );
  384.                     }
  385.                 }
  386.                 break;
  387.             }
  388.             case STYLE_BARS:
  389.             {
  390.                 int start_x, start_y, end_x, end_y;
  391.                 start_x = spectrum->start_x;
  392.                 start_y = spectrum->start_y;
  393.                 end_x = spectrum->start_x + spectrum->width - 1;
  394.                 end_y = start_y + spectrum->height - 1;
  395.                 gdi_draw_solid_rect(
  396.                     start_x,
  397.                     start_y,
  398.                     end_x,
  399.                     end_y,
  400.                     GDI_COLOR_TRANSPARENT /* SPECTRUM_BKGD_COLOR_BAR_STYLE */ );
  401.                 break;
  402.             }
  403.         }
  404.         gdi_layer_pop_clip();
  405.         gdi_layer_unlock_frame_buffer();
  406.         /* check on which lcd we have to show the spectrum */
  407.         gdi_layer_blt_previous(
  408.             spectrum->start_x,
  409.             spectrum->start_y,
  410.             spectrum->start_x + spectrum->width,
  411.             spectrum->start_y + spectrum->height);
  412.     #ifdef __GDI_MEMORY_PROFILE_2__
  413.         if (spectrum->target_layer)
  414.         {
  415.             gdi_layer_pop_and_restore_active();
  416.         }
  417.     #endif /* __GDI_MEMORY_PROFILE_2__ */ 
  418.         if (spectrum->target_lcd == GDI_LCD_SUB_LCD_HANDLE && present_lcd == GDI_LCD_MAIN_LCD_HANDLE)
  419.         {
  420.             UI_set_main_LCD_graphics_context();
  421.         }
  422.         else if (spectrum->target_lcd == GDI_LCD_MAIN_LCD_HANDLE && present_lcd == GDI_LCD_SUB_LCD_HANDLE)
  423.         {
  424.             UI_set_sub_LCD_graphics_context();
  425.         }
  426.         /* save the pointer in the global spectrum array. */
  427.         g_ui_spectrum_list[index] = spectrum;
  428.         return TRUE;    /* return TRUE since the assignment and init of the spectrum are done. */
  429.     }
  430.     return FALSE;   /* return FALSE since there is no room for the new display */
  431. }
  432. /*****************************************************************************
  433.  * FUNCTION
  434.  *  mmi_audio_spectrum_start_display
  435.  * DESCRIPTION
  436.  *  
  437.  * PARAMETERS
  438.  *  spectrum        [?]     
  439.  * RETURNS
  440.  *  void
  441.  *****************************************************************************/
  442. void mmi_audio_spectrum_start_display(spectrum_struct *spectrum)
  443. {
  444.     /*----------------------------------------------------------------*/
  445.     /* Local Variables                                                */
  446.     /*----------------------------------------------------------------*/
  447.     int spectrum_index = 0;
  448.     /*----------------------------------------------------------------*/
  449.     /* Code Body                                                      */
  450.     /*----------------------------------------------------------------*/
  451.     /* get values from l1 audio layer *//* HARDCODE */
  452.     for (spectrum_index = 0; spectrum_index < MAX_NUM_OF_SPECTRUMS; spectrum_index++)
  453.     {
  454.         if (spectrum == g_ui_spectrum_list[spectrum_index])
  455.         {
  456.             mdi_audio_get_spectrum(top, amplitude_val);
  457.             mmi_audio_spectrum_redraw_display(spectrum, amplitude_val, top);
  458.             if (g_ui_spectrum_active_count == 0)
  459.             {
  460.                 gui_start_timer(g_ui_spectrum_timer_interval, mmi_audio_spectrum_display_timer);
  461.             }
  462.             if (!spectrum->active)
  463.             {
  464.                 spectrum->active = TRUE;
  465.                 g_ui_spectrum_active_count++;
  466.             }
  467.             break;
  468.         }
  469.     }
  470. }
  471. /*****************************************************************************
  472.  * FUNCTION
  473.  *  mmi_audio_spectrum_display_timer
  474.  * DESCRIPTION
  475.  *  
  476.  * PARAMETERS
  477.  *  void
  478.  * RETURNS
  479.  *  void
  480.  *****************************************************************************/
  481. void mmi_audio_spectrum_display_timer(void)
  482. {
  483.     /*----------------------------------------------------------------*/
  484.     /* Local Variables                                                */
  485.     /*----------------------------------------------------------------*/
  486.     int spectrum_index = 0;
  487.     spectrum_struct *spectrum;
  488.     /*----------------------------------------------------------------*/
  489.     /* Code Body                                                      */
  490.     /*----------------------------------------------------------------*/
  491.     /* get values from l1 audio layer */
  492.     mdi_audio_get_spectrum(top, amplitude_val);
  493.     g_ui_spectrum_odd_even_identifier = ((g_ui_spectrum_odd_even_identifier == 1) ? 2 : 1);     /* usefule only in case of STYLE_CIRCLES. */
  494.     for (spectrum_index = 0; spectrum_index < MAX_NUM_OF_SPECTRUMS; spectrum_index++)
  495.     {
  496.         if (((spectrum = g_ui_spectrum_list[spectrum_index]) != NULL) && spectrum->active)
  497.         {
  498.             g_ui_spectrum_no_blt_after_clear = TRUE;    /* this indicates that their is no need to BLT after clearing the screen */
  499.             mmi_audio_spectrum_clear_display(spectrum); /* blt should be done only after redrawing to make more efficient...this is only for the case in which after erase redraw is to be done. */
  500.             mmi_audio_spectrum_redraw_display(spectrum, amplitude_val, top);
  501.         }
  502.     }
  503.     gui_start_timer(g_ui_spectrum_timer_interval, mmi_audio_spectrum_display_timer);
  504. }
  505. /*****************************************************************************
  506.  * FUNCTION
  507.  *  mmi_audio_spectrum_redraw_display
  508.  * DESCRIPTION
  509.  *  
  510.  * PARAMETERS
  511.  *  spectrum            [?]     
  512.  *  amplitude_val       [?]     
  513.  *  top                 [?]     
  514.  * RETURNS
  515.  *  void
  516.  *****************************************************************************/
  517. void mmi_audio_spectrum_redraw_display(spectrum_struct *spectrum, U8 *amplitude_val, U8 *top)
  518. {
  519.     /*----------------------------------------------------------------*/
  520.     /* Local Variables                                                */
  521.     /*----------------------------------------------------------------*/
  522.     S32 hrzntl_space_for_bars, no_of_blocks_in_blocks_style, no_of_whole_blocks_in_a_bar;
  523.     S16 bar_width;
  524.     int index, col, color_variation_limit;
  525.     float one_pixel_represents;
  526.     GDI_HANDLE present_lcd;
  527.     int start_x, start_y, end_x, end_y;
  528.     /*----------------------------------------------------------------*/
  529.     /* Code Body                                                      */
  530.     /*----------------------------------------------------------------*/
  531.     if (!spectrum->active)
  532.     {
  533.         return;
  534.     }
  535.     start_x = spectrum->start_x;
  536.     start_y = spectrum->start_y;
  537.     end_x = start_x + spectrum->width - 1;
  538.     end_y = start_y + spectrum->height - 1;
  539.     /* find the bar width ... */
  540.     hrzntl_space_for_bars = spectrum->width - DIST_BETWEEN_BARS * (spectrum->number_of_bars + 1);       /* DIST_BETWEEN_BARS * (spectrum->number_of_bars + 1) 
  541.                                                                                                            is sub. for leaving 2 pixel space between the various bars. */
  542.     if (hrzntl_space_for_bars % spectrum->number_of_bars)
  543.     {
  544.         bar_width =
  545.             (hrzntl_space_for_bars - (hrzntl_space_for_bars % spectrum->number_of_bars)) / spectrum->number_of_bars;
  546.     }
  547.     else
  548.     {
  549.         bar_width = hrzntl_space_for_bars / spectrum->number_of_bars;
  550.     }
  551.     gdi_lcd_get_active(&present_lcd);
  552.     if (spectrum->target_lcd == GDI_LCD_SUB_LCD_HANDLE && present_lcd == GDI_LCD_MAIN_LCD_HANDLE)
  553.     {
  554.         UI_set_sub_LCD_graphics_context();  /* switch to sub lcd graphic context */
  555.     }
  556.     else if (spectrum->target_lcd == GDI_LCD_MAIN_LCD_HANDLE && present_lcd == GDI_LCD_SUB_LCD_HANDLE)
  557.     {
  558.         UI_set_main_LCD_graphics_context(); /* switch to sub lcd graphic context */
  559.     }
  560. #ifdef __GDI_MEMORY_PROFILE_2__
  561.     if (spectrum->target_layer)
  562.     {
  563.         gdi_layer_push_and_set_active(spectrum->target_layer);
  564.     }
  565. #endif /* __GDI_MEMORY_PROFILE_2__ */ 
  566.     /* draw the display spectrum... */
  567.     gdi_layer_lock_frame_buffer();
  568.     gdi_layer_push_clip();
  569.     gdi_layer_set_clip(start_x, start_y, end_x, end_y);
  570.     /* different handling for different styles */
  571.     switch (spectrum->style)
  572.     {
  573.         case STYLE_BLOCKS:
  574.         {
  575.             /* calculate the maximum no. of blocks in each column/bar in spectrum */
  576.             no_of_blocks_in_blocks_style = spectrum->height / (DIST_BETWEEN_BLOCKS + BLOCK_HEIGHT);
  577.             one_pixel_represents = (float)256 / (float)(no_of_blocks_in_blocks_style * BLOCK_HEIGHT);
  578.             for (col = 0; col < spectrum->number_of_bars; col++)
  579.             {
  580.                 S32 required_height_of_a_bar, required_height_of_top, difference;
  581.                 if (col == 0)
  582.                 {
  583.                     start_x =
  584.                         spectrum->start_x + (hrzntl_space_for_bars % spectrum->number_of_bars) / 2 + DIST_BETWEEN_BARS;
  585.                     end_x = start_x + bar_width - 1;
  586.                 }
  587.                 else
  588.                 {
  589.                     start_x = start_x + bar_width + DIST_BETWEEN_BARS;
  590.                     end_x = start_x + bar_width - 1;
  591.                 }
  592.                 /* draw the bar... */
  593.                 required_height_of_a_bar = (int)(amplitude_val[col] / one_pixel_represents);
  594.                 /* small calculation for the top indicator and the difference between bar height and top indicator height. */
  595.                 required_height_of_top = (int)(top[col] / one_pixel_represents);
  596.                 difference = required_height_of_top - required_height_of_a_bar;
  597.                 /* calculation ends here. */
  598.                 /* calculate the maximum color variation value for the given height */
  599.                 color_variation_limit = amplitude_val[col];
  600.                 /* initialize end_y: which will be the same for all the cases. */
  601.                 end_y = spectrum->start_y + spectrum->height - 1;
  602.                 no_of_whole_blocks_in_a_bar = required_height_of_a_bar / BLOCK_HEIGHT;
  603.                 if (no_of_whole_blocks_in_a_bar)
  604.                 {
  605.                     end_y -= DIST_BETWEEN_BLOCKS;
  606.                     for (index = 0; index < no_of_whole_blocks_in_a_bar; index++)
  607.                     {
  608.                         start_y = end_y - (BLOCK_HEIGHT - 1);
  609.                         gdi_draw_solid_rect(
  610.                             start_x,
  611.                             start_y,
  612.                             end_x,
  613.                             end_y,
  614.                             gdi_act_color_from_rgb(0xFF, SPECTRUM_BLOCK_RED_COMPONENT, color_variation_limit, SPECTRUM_BLOCK_BLUE_COMPONENT));
  615.                         end_y = (start_y - 1) - DIST_BETWEEN_BLOCKS;
  616.                         color_variation_limit -= (int)(BLOCK_HEIGHT * one_pixel_represents);
  617.                     }
  618.                     end_y += DIST_BETWEEN_BLOCKS;
  619.                 }
  620.                 if (required_height_of_a_bar % BLOCK_HEIGHT)
  621.                 {
  622.                     end_y -= DIST_BETWEEN_BLOCKS;
  623.                     start_y = end_y - ((required_height_of_a_bar % BLOCK_HEIGHT) - 1);
  624.                     gdi_draw_solid_rect(
  625.                         start_x,
  626.                         start_y,
  627.                         end_x,
  628.                         end_y,
  629.                         gdi_act_color_from_rgb(0xFF, SPECTRUM_BLOCK_RED_COMPONENT, color_variation_limit, SPECTRUM_BLOCK_BLUE_COMPONENT));
  630.                     end_y = start_y - 1;
  631.                     /* drawing the bar is complete */
  632.                     /* draw the top indicator */
  633.                     //now the start_y is to be moved to the top indicator position.
  634.                     //first check that difference is morethan or equal to the unfilled block height...
  635.                     //if it is then simply subtract the unfilled height from start_y and difference
  636.                     //and bring the start_y to the top of block.
  637.                     if (difference)
  638.                     {
  639.                         if (difference >= (BLOCK_HEIGHT - (required_height_of_a_bar % BLOCK_HEIGHT)))
  640.                         {
  641.                             end_y -= (BLOCK_HEIGHT - (required_height_of_a_bar % BLOCK_HEIGHT));
  642.                             difference -= (BLOCK_HEIGHT - (required_height_of_a_bar % BLOCK_HEIGHT));
  643.                         }
  644.                         else
  645.                         {   /* else simply subtract the difference from start_y and nullify the difference. */
  646.                             end_y -= difference;
  647.                             difference = 0;
  648.                         }
  649.                     }
  650.                 }
  651.                 while (difference)  /* no if still the difference is left then subtarct it (by comparing it's value with BLOCK_HEIGHT from start_x */
  652.                 {
  653.                     if (difference > BLOCK_HEIGHT)
  654.                     {
  655.                         end_y -= (DIST_BETWEEN_BLOCKS + BLOCK_HEIGHT);
  656.                         difference -= BLOCK_HEIGHT;
  657.                     }
  658.                     else
  659.                     {
  660.                         end_y -= (DIST_BETWEEN_BLOCKS + difference);
  661.                         difference = 0;
  662.                     }
  663.                 }
  664.                 end_y++;
  665.                 start_y = end_y;
  666.                 /* draw the top indicator. */
  667.                 gdi_draw_solid_rect(start_x, start_y, end_x, end_y, SPECTRUM_TOP_INDICATOR_COLOR_BLOCK_STYLE);
  668.             }
  669.             break;
  670.         }
  671.         case STYLE_BARS:
  672.         {
  673.             int start_x = 0, start_y, end_x, end_y;
  674.             /* calculate the maximum no. of blocks in each column/bar in spectrum */
  675.             no_of_blocks_in_blocks_style = spectrum->height / BLOCK_HEIGHT;
  676.             one_pixel_represents = (float)256 / (float)(no_of_blocks_in_blocks_style * BLOCK_HEIGHT);
  677.             for (col = 0; col < spectrum->number_of_bars; col++)
  678.             {
  679.                 S32 required_height_of_a_bar, required_height_of_top, difference;
  680.                 if (col == 0)
  681.                 {
  682.                     start_x =
  683.                         spectrum->start_x + (hrzntl_space_for_bars % spectrum->number_of_bars) / 2 + DIST_BETWEEN_BARS;
  684.                     end_x = start_x + bar_width - 1;
  685.                 }
  686.                 else
  687.                 {
  688.                     start_x = start_x + bar_width + DIST_BETWEEN_BARS;
  689.                     end_x = start_x + bar_width - 1;
  690.                 }
  691.                 /* draw the bar... */
  692.                 required_height_of_a_bar = (int)(amplitude_val[col] / one_pixel_represents);
  693.                 /* small calculation for the top indicator and the difference between bar height and top indicator height. */
  694.                 required_height_of_top = (int)(top[col] / one_pixel_represents);
  695.                 difference = required_height_of_top - required_height_of_a_bar;
  696.                 /* calculation ends here. */
  697.                 /* calculate the maximum color variation value for the given height */
  698.                 color_variation_limit = amplitude_val[col];
  699.                 /* initialize end_y: which will be the same for all the cases. */
  700.                 end_y = spectrum->start_y + spectrum->height - 1;
  701.                 no_of_whole_blocks_in_a_bar = required_height_of_a_bar / BLOCK_HEIGHT;
  702.                 if (no_of_whole_blocks_in_a_bar)
  703.                 {
  704.                     for (index = 0; index < no_of_whole_blocks_in_a_bar; index++)
  705.                     {
  706.                         start_y = end_y - (BLOCK_HEIGHT - 1);
  707.                         gdi_draw_solid_rect(
  708.                             start_x,
  709.                             start_y,
  710.                             end_x,
  711.                             end_y,
  712.                             gdi_act_color_from_rgb(0xFF, SPECTRUM_BLOCK_RED_COMPONENT, color_variation_limit, SPECTRUM_BLOCK_BLUE_COMPONENT));
  713.                         end_y = start_y - 1;
  714.                         color_variation_limit -= (int)(BLOCK_HEIGHT * one_pixel_represents);
  715.                     }
  716.                 }
  717.                 if (required_height_of_a_bar % BLOCK_HEIGHT)
  718.                 {
  719.                     start_y = end_y - ((required_height_of_a_bar % BLOCK_HEIGHT) - 1);
  720.                     gdi_draw_solid_rect(
  721.                         start_x,
  722.                         start_y,
  723.                         end_x,
  724.                         end_y,
  725.                         gdi_act_color_from_rgb(0xFF, SPECTRUM_BLOCK_RED_COMPONENT, color_variation_limit, SPECTRUM_BLOCK_BLUE_COMPONENT));
  726.                     end_y = start_y - 1;
  727.                 }
  728.                 if (difference)
  729.                 {
  730.                     end_y -= (difference - 1);
  731.                 }
  732.                 start_y = end_y;
  733.                 /* draw the top indicator. */
  734.                 if(start_y != spectrum->start_y + spectrum->height - 1 )
  735.                 {
  736.                     gdi_draw_solid_rect(start_x, start_y, end_x, end_y, SPECTRUM_TOP_INDICATOR_COLOR_BAR_STYLE);
  737.                 }
  738.             }
  739.             break;
  740.         }
  741.         case STYLE_CIRCLES:
  742.         {
  743.             {
  744.                 unsigned char alpha, color_index, color_array[NUM_OF_COLOR_COMPONENTS];
  745.                 int center_x, center_y, radius_x, radius_y, ellipse_index, radius_x_dec, radius_y_dec, tempx, tempy;
  746.                 BOOL toggle_fill_draw = FALSE;
  747.                 color_index = 1;
  748.                 center_x = spectrum->start_x + (spectrum->width) / 2;
  749.                 center_y = spectrum->start_y + (spectrum->height) / 2;
  750.                 radius_x = (spectrum->width - SPACE_TO_BE_LEFT_FOR_CIRCLES_STYLE) / 2;
  751.                 radius_y = (spectrum->height - SPACE_TO_BE_LEFT_FOR_CIRCLES_STYLE) / 2;
  752.                 radius_x_dec = radius_y_dec = 1;
  753.                 tempx = (spectrum->width - SPACE_TO_BE_LEFT_FOR_CIRCLES_STYLE) / (spectrum->number_of_bars * 2);
  754.                 tempy = (spectrum->height - SPACE_TO_BE_LEFT_FOR_CIRCLES_STYLE) / (spectrum->number_of_bars * 2);
  755.                 radius_x_dec += (tempx - 1);
  756.                 radius_y_dec += (tempy - 1);
  757.                 alpha = 50;
  758.                 color_array[0] = 45;    /* red component */
  759.                 color_array[1] = 255;   /* blue component */
  760.                 GDI_LOCK;
  761.                 /* this if statement is for showing the odd positioned values once and then the even posotioned values */
  762.                 for (ellipse_index = spectrum->number_of_bars; ellipse_index >= 1; ellipse_index--)
  763.                 {
  764.                     /* the 2 components have values 45 and 255 and the 3rd one has the val from the amplitude_val array. */
  765.                     color_array[(color_index + 1) % NUM_OF_COLOR_COMPONENTS] =
  766.                         amplitude_val[(ellipse_index * 2) - g_ui_spectrum_odd_even_identifier];
  767.                     if (color_array[(color_index + 1) % 3])
  768.                     {
  769.                         if (toggle_fill_draw)
  770.                         {
  771.                             /* draw the ellipse */
  772.                             gd_draw_ellipse16(
  773.                                 (U16*) gdi_act_layer->buf_ptr,
  774.                                 gdi_act_layer->width,
  775.                                 center_x,
  776.                                 center_y,
  777.                                 radius_x,
  778.                                 radius_y,
  779.                                 gdi_act_layer->clipx1,
  780.                                 gdi_act_layer->clipy1,
  781.                                 gdi_act_layer->clipx2,
  782.                                 gdi_act_layer->clipy2,
  783.                                 gdi_act_color_from_rgb(alpha, color_array[0], color_array[1], color_array[2]),
  784.                                 0);
  785.                             toggle_fill_draw = FALSE;
  786.                         }
  787.                         else
  788.                         {
  789.                             /* fill the ellipse */
  790.                             gd_fill_ellipse16(
  791.                                 (U16*) gdi_act_layer->buf_ptr,
  792.                                 gdi_act_layer->width,
  793.                                 center_x,
  794.                                 center_y,
  795.                                 radius_x,
  796.                                 radius_y,
  797.                                 gdi_act_layer->clipx1,
  798.                                 gdi_act_layer->clipy1,
  799.                                 gdi_act_layer->clipx2,
  800.                                 gdi_act_layer->clipy2,
  801.                                 gdi_act_color_from_rgb(alpha, color_array[0], color_array[1], color_array[2]));
  802.                             toggle_fill_draw = TRUE;
  803.                         }
  804.                     }
  805.                     /* shuffle the colors for better visual affect; */
  806.                     color_array[(color_index + 1) % NUM_OF_COLOR_COMPONENTS] = color_array[color_index];
  807.                     color_array[color_index] =
  808.                         color_array[(NUM_OF_COLOR_COMPONENTS - 1 + color_index) % NUM_OF_COLOR_COMPONENTS];
  809.                     color_index = (color_index + 1) % NUM_OF_COLOR_COMPONENTS;
  810.                     radius_x -= radius_x_dec;
  811.                     radius_y -= radius_y_dec;
  812.                 }
  813.                 GDI_UNLOCK;
  814.             }
  815.             break;
  816.         }
  817.     }
  818.     gdi_layer_pop_clip();
  819.     gdi_layer_unlock_frame_buffer();
  820.     /* check on which lcd we have to show the spectrum */
  821.     gdi_layer_blt_previous(
  822.         spectrum->start_x,
  823.         spectrum->start_y,
  824.         spectrum->start_x + spectrum->width - 1,
  825.         spectrum->start_y + spectrum->height - 1);
  826. #ifdef __GDI_MEMORY_PROFILE_2__
  827.     if (spectrum->target_layer)
  828.     {
  829.         gdi_layer_pop_and_restore_active();
  830.     }
  831. #endif /* __GDI_MEMORY_PROFILE_2__ */ 
  832.     if (spectrum->target_lcd == GDI_LCD_SUB_LCD_HANDLE && present_lcd == GDI_LCD_MAIN_LCD_HANDLE)
  833.     {
  834.         UI_set_main_LCD_graphics_context();
  835.     }
  836.     else if (spectrum->target_lcd == GDI_LCD_MAIN_LCD_HANDLE && present_lcd == GDI_LCD_SUB_LCD_HANDLE)
  837.     {
  838.         UI_set_sub_LCD_graphics_context();
  839.     }
  840. }
  841. /*****************************************************************************
  842.  * FUNCTION
  843.  *  mmi_audio_spectrum_clear_display
  844.  * DESCRIPTION
  845.  *  
  846.  * PARAMETERS
  847.  *  spectrum        [?]     
  848.  * RETURNS
  849.  *  void
  850.  *****************************************************************************/
  851. void mmi_audio_spectrum_clear_display(spectrum_struct *spectrum)
  852. {
  853.     /*----------------------------------------------------------------*/
  854.     /* Local Variables                                                */
  855.     /*----------------------------------------------------------------*/
  856.     GDI_HANDLE present_lcd;
  857.     int row, col;
  858.     int start_x, start_y, end_x, end_y;
  859.     int x1 = 0, y1 = 0, x2, y2;
  860.     /*----------------------------------------------------------------*/
  861.     /* Code Body                                                      */
  862.     /*----------------------------------------------------------------*/
  863.     start_x = spectrum->start_x;
  864.     start_y = spectrum->start_y;
  865.     end_x = start_x + spectrum->width - 1;
  866.     end_y = start_y + spectrum->height - 1;
  867.     gdi_lcd_get_active(&present_lcd);
  868.     if (spectrum->target_lcd == GDI_LCD_SUB_LCD_HANDLE && present_lcd == GDI_LCD_MAIN_LCD_HANDLE)
  869.     {
  870.         UI_set_sub_LCD_graphics_context();  /* switch to sub lcd graphic context */
  871.     }
  872.     else if (spectrum->target_lcd == GDI_LCD_MAIN_LCD_HANDLE && present_lcd == GDI_LCD_SUB_LCD_HANDLE)
  873.     {
  874.         UI_set_main_LCD_graphics_context(); /* switch to sub lcd graphic context */
  875.     }
  876. #ifdef __GDI_MEMORY_PROFILE_2__
  877.     if (spectrum->target_layer)
  878.     {
  879.         gdi_layer_push_and_set_active(spectrum->target_layer);
  880.     }
  881. #endif /* __GDI_MEMORY_PROFILE_2__ */ 
  882.     gdi_layer_lock_frame_buffer();
  883.     gdi_layer_push_clip();
  884.     gdi_layer_set_clip(start_x, start_y, end_x, end_y);
  885.     switch (spectrum->style)
  886.     {
  887.         case STYLE_BLOCKS:
  888.         {
  889.             S32 hrzntl_space_for_bars, bar_width, no_of_blocks_in_block_style;
  890.             gdi_draw_solid_rect(
  891.                 start_x,
  892.                 start_y,
  893.                 end_x,
  894.                 end_y,
  895.                 GDI_COLOR_TRANSPARENT /* gdi_act_color_from_rgb(0x0,204,230,229) */ );
  896.             /* find the bar width ... */
  897.             hrzntl_space_for_bars = spectrum->width - DIST_BETWEEN_BARS * (spectrum->number_of_bars + 1);       /* DIST_BETWEEN_BARS * (spectrum->number_of_bars + 1) 
  898.                                                                                                                    is sub. for leaving 2 pixel space between the various bars. */
  899.             if (hrzntl_space_for_bars % spectrum->number_of_bars)
  900.             {
  901.                 bar_width =
  902.                     (hrzntl_space_for_bars -
  903.                      (hrzntl_space_for_bars % spectrum->number_of_bars)) / spectrum->number_of_bars;
  904.             }
  905.             else
  906.             {
  907.                 bar_width = hrzntl_space_for_bars / spectrum->number_of_bars;
  908.             }
  909.             /* calculate the maximum no. of blocks in each column/bar in spectrum */
  910.             no_of_blocks_in_block_style = spectrum->height / (DIST_BETWEEN_BLOCKS + BLOCK_HEIGHT);
  911.             /* draw the light colored rectangles */
  912.             for (col = 0; col < spectrum->number_of_bars; col++)
  913.             {
  914.                 if (col == 0)
  915.                 {
  916.                     x1 = spectrum->start_x + (hrzntl_space_for_bars % spectrum->number_of_bars) / 2 + DIST_BETWEEN_BARS;
  917.                 }
  918.                 else
  919.                 {
  920.                     x1 = x1 + bar_width + DIST_BETWEEN_BARS;
  921.                 }
  922.                 x2 = x1 + (bar_width - 1);
  923.                 for (row = 0; row < no_of_blocks_in_block_style; row++)
  924.                 {
  925.                     if (row == 0)
  926.                     {
  927.                         y1 = (spectrum->start_y + spectrum->height - 1) - DIST_BETWEEN_BLOCKS - (BLOCK_HEIGHT - 1);
  928.                     }
  929.                     else
  930.                     {
  931.                         y1 = (y1 - 1) - DIST_BETWEEN_BLOCKS - (BLOCK_HEIGHT - 1);
  932.                     }
  933.                     y2 = y1 + (BLOCK_HEIGHT - 1);
  934.                     gdi_draw_solid_rect(x1, y1, x2, y2, GDI_COLOR_TRANSPARENT /* SPECTRUM_BKGD_COLOR_BLOCK_STYLE */ );
  935.                 }
  936.             }
  937.             break;
  938.         }
  939.         case STYLE_BARS:
  940.         {
  941.             gdi_draw_solid_rect(
  942.                 start_x,
  943.                 start_y,
  944.                 end_x,
  945.                 end_y,
  946.                 GDI_COLOR_TRANSPARENT /* SPECTRUM_BKGD_COLOR_BAR_STYLE */ );
  947.             break;
  948.         }
  949.         case STYLE_CIRCLES:
  950.         {
  951.             gdi_draw_solid_rect(
  952.                 start_x,
  953.                 start_y,
  954.                 end_x,
  955.                 end_y,
  956.                 GDI_COLOR_TRANSPARENT /* SPECTRUM_BKGD_COLOR_BAR_STYLE */ );
  957.             break;
  958.         }
  959.     }
  960.     gdi_layer_pop_clip();
  961.     gdi_layer_unlock_frame_buffer();
  962.     if (!g_ui_spectrum_no_blt_after_clear)
  963.     {
  964.         gdi_layer_blt_previous(start_x, start_y, end_x, end_y);
  965.     }
  966.     else
  967.     {
  968.         g_ui_spectrum_no_blt_after_clear = FALSE;
  969.     }
  970. #ifdef __GDI_MEMORY_PROFILE_2__
  971.     if (spectrum->target_layer)
  972.     {
  973.         gdi_layer_pop_and_restore_active();
  974.     }
  975. #endif /* __GDI_MEMORY_PROFILE_2__ */ 
  976.     if (spectrum->target_lcd == GDI_LCD_SUB_LCD_HANDLE && present_lcd == GDI_LCD_MAIN_LCD_HANDLE)
  977.     {
  978.         UI_set_main_LCD_graphics_context();
  979.     }
  980.     else if (spectrum->target_lcd == GDI_LCD_MAIN_LCD_HANDLE && present_lcd == GDI_LCD_SUB_LCD_HANDLE)
  981.     {
  982.         UI_set_sub_LCD_graphics_context();
  983.     }
  984. }
  985. /*****************************************************************************
  986.  * FUNCTION
  987.  *  mmi_audio_spectrum_stop_display
  988.  * DESCRIPTION
  989.  *  
  990.  * PARAMETERS
  991.  *  spectrum        [?]     
  992.  * RETURNS
  993.  *  void
  994.  *****************************************************************************/
  995. void mmi_audio_spectrum_stop_display(spectrum_struct *spectrum)
  996. {
  997.     /*----------------------------------------------------------------*/
  998.     /* Local Variables                                                */
  999.     /*----------------------------------------------------------------*/
  1000.     int index;
  1001.     /*----------------------------------------------------------------*/
  1002.     /* Code Body                                                      */
  1003.     /*----------------------------------------------------------------*/
  1004.     for (index = 0; index < MAX_NUM_OF_SPECTRUMS; index++)
  1005.     {
  1006.         if (spectrum == g_ui_spectrum_list[index])
  1007.         {
  1008.             /* stop this particular spectrum if it's active */
  1009.             if (spectrum->active)
  1010.             {
  1011.                 mmi_audio_spectrum_clear_display(spectrum);
  1012.                 spectrum->active = FALSE;
  1013.                 g_ui_spectrum_active_count--;
  1014.             }
  1015.             g_ui_spectrum_list[index] = NULL;   /* added by PANKAJ for removal of Black Patch problem on Idle Screen...in case the song is being played and the user reaches the IDLE screen. */
  1016.             break;
  1017.         }
  1018.     }
  1019.     if (g_ui_spectrum_active_count == 0)
  1020.     {
  1021.         gui_cancel_timer(mmi_audio_spectrum_display_timer);
  1022.     }
  1023. }
  1024. #endif /* __MMI_AUDIO_SPECTRUM_DISPLAY__ */