comparison src/aci2/bmi/mmiSounds.c @ 120:3c2acfa1a72f

src/aci2/bmi: file renames to make filename case consistent
author Mychaela Falconia <falcon@freecalypso.org>
date Fri, 07 Oct 2016 03:46:05 +0000
parents src/aci2/bmi/MmiSounds.c@93999a60b835
children
comparison
equal deleted inserted replaced
119:b92a33c204b6 120:3c2acfa1a72f
1 /*******************************************************************************
2
3 CONDAT (UK)
4
5 ********************************************************************************
6
7 This software product is the property of Condat (UK) Ltd and may not be
8 disclosed to any third party without the express permission of the owner.
9
10 ********************************************************************************
11
12 $Project name: Basic MMI
13 $Project code: BMI (6349)
14 $Module: Sounds
15 $File: MmiSounds.c
16 $Revision: 1.0
17
18 $Author: Condat(UK)
19 $Date: 25/10/00
20
21 ********************************************************************************
22
23 Description:
24
25 This provides the implementation of the sounds for the basic MMI
26
27 1. Playing various system sounds such as the paging ring,
28 new sms message etc.
29 2. The menus used to enable or disable the system sounds
30 3. The menu used to select the paging ring tone
31 4. The menu used to select the volume.
32 5. The menu used to select the key press tone or dtmf
33
34 The mmi should play system sounds by calling soundExec with the appropriate
35 SoundsXXXX message it is possible to go directly to the audio driver to play
36 a sound but this will bypass any user settings to turn sounds on or off.
37
38 The MelodySelect and SettingXXXX messages are used to control the key events
39 during menu handling, entry to the sounds menus is through the soundsXXXX
40 functions. These display the appropriate menu and handle the keypad events.
41
42 The settings are read from PCM on startup and saved whenever a setting menu
43 is selected.
44
45 ********************************************************************************
46 $History: MmiSounds.c
47
48 25/10/00 Original Condat(UK) BMI version.
49
50 Nov 23, 2005 REF : DR OMAPS00057378 x0039928
51 Bug: All MIDI files are not displayed in MMI in locosto-lite
52 Fix: Buffer memory allocated to copy the file contents is freed
53 properly and copying file from FFS to LFS is not terminated if error is
54 returned for just any one file, instead it tries to copy other files.
55
56 Nov 21, 2005 REF:ER OMAPS00057430 nekkareb
57 Description: AAC Ringer Implementation
58 Solution: The Midi Ringer application has been enhanced to support AAC as ringer.
59
60 Nov 04, 2005 REF:DRT OMAPS00053737 xdeepadh
61 Description: MIDI Ringer Linear Flash Support.
62 Solution: The Midi Ringer application has been enhanced to loadand play the midi files from LFS.
63
64 Nov 02, 2005 REF:ER OMAPS00039044 xdeepadh
65 Description: Mp3 Ringer Implementation
66 Solution: The Midi Ringer application has been enhanced to support mp3 as ringer.
67 The interface function names have been modified.
68
69 Sep 12, 2005 REF: SPR 33977 xdeepadh
70 Description: Midi Application does not support Mobile XMF file formats
71 Solution: Mobile XMF format has been supported
72
73 Aug 30, 2005 REF: SPR 34018 xdeepadh
74 Description: Silent Mode: Silent mode is not activated with the sequence, 'Menu, '#''
75 Solution: When the silent mode is set through the key sequence, the volume is set to silent.
76
77
78 Jul 20, 2005 REF: SPR 30772 xdeepadh
79 Description: Midi File formats to be supported by different variants of locosto program
80 Solution: The supported midi file formats for a particular variant will be loaded.
81
82 Aug 05, 2005 xdeepadh
83 Description: Configuring the audio path for midi
84
85 Apr 05, 2005 REF: ENH 29994 xdeepadh
86 Description: Implementation of Generic Midi Ringer and Modification of existing Midi Test Application
87 Solution: Generic Midi Ringer and Midi Test Application were implemented.
88
89 Nov 29, 2004 REF: CRR 25051 xkundadu
90 Description: INCALL SCREEN – ADJUSTING THE VOLUME
91 Fix: Added volume level list linked to up/down keys.
92 User can select the speaker volume among those levels.
93 Dec 23, 2005 REF: SR13873 x0020906
94 Description: Selection configurable ring tones. Added for NEPTUNE
95 Fix: When moving cursor in menu, stop old and play new ringtone.
96 When press of back / clear / hang up stop playing the ringtone.
97 Initially when the get into list, start playing first ringtone - As cursor is positioned.
98
99 $End
100
101 *******************************************************************************/
102
103
104 /*******************************************************************************
105
106 Include Files
107
108 *******************************************************************************/
109
110 #define ENTITY_MFW
111
112 /* includes */
113 #include <string.h>
114 #include <stdio.h>
115 #include <stdlib.h>
116
117 #if defined (NEW_FRAME)
118
119 #include "typedefs.h"
120 #include "vsi.h"
121 #include "pei.h"
122 #include "custom.h"
123 #include "gsm.h"
124
125 #else
126
127 #include "STDDEFS.H"
128 #include "custom.h"
129 #include "gsm.h"
130 #include "vsi.h"
131
132 #endif
133 #include "mfw_sys.h"
134
135 #include "mfw_mfw.h"
136 #include "mfw_kbd.h"
137 #include "mfw_tim.h"
138 #include "mfw_lng.h"
139 #include "mfw_win.h"
140 #include "mfw_icn.h"
141 #include "mfw_sim.h"
142 #include "mfw_nm.h"
143 /* SPR#1428 - SH - New Editor changes */
144 #ifndef NEW_EDITOR
145 #include "mfw_edt.h"
146 #endif
147 #include "mfw_mnu.h"
148 #include "mfw_phb.h"
149 #include "mfw_sms.h"
150
151 //Apr 05, 2005 REF: ENH 29994 xdeepadh
152 #ifdef FF_MIDI_RINGER
153 #include "mfw_midi.h"
154 #include "bae/bae_options.h" //Jul 20, 2005 REF: SPR 30772 xdeepadh
155 #endif
156
157 #include "dspl.h"
158
159
160 #include "p_mmi.h"
161 #include "message.h"
162 #include "prim.h"
163 #include "aci_cmh.h"
164 #include "mfw_mme.h"
165
166 #include "MmiMmi.h"
167
168 #include "Mmiicons.h"
169 #include "MmiPins.h"
170 #include "MmiMain.h"
171 #include "MmiDialogs.h"
172 #include "MmiIdle.h"
173 #include "MmiStart.h"
174 #include "mmiCall.h"
175 #include "MmiSimToolkit.h"
176 #include "gdi.h"
177 #include "audio.h"
178 #include "MmiLists.h"
179 #include "MmiSounds.h"
180 #include "MmiResources.h"
181 #include "MmiTimeDate.h"
182
183 #include "cus_aci.h"
184 #include "prim.h"
185 #ifndef PCM_2_FFS
186 #include "pcm.h"
187 #endif
188
189 #include "MmiTimers.h"
190
191 #include "mmiColours.h"
192 //Apr 05, 2005 REF: ENH 29994 xdeepadh
193 #ifdef FF_MIDI_RINGER
194 #include "mmisamplemidifiles.h"
195 #endif
196 extern char* MelodyTable[];
197 extern T_call call_data;
198
199 // Aug 05, 2005 xdeepadh
200 #ifdef FF_MMI_AUDIO_PROFILE
201 extern UBYTE mfwAudPlay;//flag for audio
202 #endif
203
204 /*******************************************************************************
205
206 Constant Definitions
207
208 *******************************************************************************/
209
210
211 /* Control FLUSH mechanism to PCM
212 */
213 #define FLUSH 1
214 #define NO_FLUSH 0
215
216
217 /* Timer constants, pretty self explanatory
218 */
219 #define TIMHALFSECOND 200
220 #define TIMSECOND 1000
221 #define TIM4SECOND 4000
222
223 #define VIBRATOR_TIME 2000 /* two second timer on the vibrator*/
224
225 /* Define a generic trace mechanism
226 */
227 #define PTRACE(prn) { char buf[64]; ## prn ## TRACE_EVENT(buf); }
228
229
230 /* Define maximum counter for vibrator
231 */
232 #define VIBRATOR_COUNTER_MAX 4
233 #define NOT_VIBRATING 0
234
235 #ifdef NEPTUNE_BOARD
236 /* RAVI - 20-1-2005 */
237 /* Volume Control Definition */
238 #define SILENT_SETTING 0
239 #define MAX_VOLUME_SETTING 4
240 /* END - RAVI - 20-1-2005 */
241 #endif
242
243 #define SILENT_VOLUME 0
244 #define LOW_VOLUME 5
245 #define MEDIUM_VOLUME 25
246 #define HIGH_VOLUME 175
247 #define INCREASE_VOLUME 5
248
249
250 /* define an invalid tone marker
251 */
252 #define INVALID_TONE -1
253
254 //Define to indicate the Size of the file where the melody must start
255 #ifdef FF_MP3_RINGER
256 #define MP3_PLAY_FROM_START 0
257 #endif //FF_MP3_RINGER
258
259 //Nov 22, 2005 REF: ENH OMAPS00057430 nekkareb
260 //Define to indicate the Size of the file where the melody must start
261 #ifdef FF_AAC_RINGER
262 #define AAC_PLAY_FROM_START 0
263 #endif //FF_AAC_RINGER
264
265
266 //Apr 05, 2005 REF: ENH 29994 xdeepadh
267 #ifdef FF_MIDI_RINGER
268 UBYTE IsMidiInit = 0;//Flag to enable the Midi file populating once
269 extern UBYTE mfw_player_exit_flag;//Flag to check the playall option
270 extern int mfw_player_currently_playing_idx;//The current playing file index
271 #define MT_INFO_SCRN_TIMEOUT 1500//Timeout for InfoDialog
272 int selected_tone=0;
273
274 /* ADDED BY RAVI - 28-11-2005 */
275 int resource_GetListCount(res_ResourceID_type res);
276 /* END RAVI - 28-11-2005 */
277
278 static int playCurrentMelody( MfwEvt e, MfwTim *tc );
279 static void soundsPlayMidiPlayer( int melody_id );
280 void startPlayerTimer();
281 static void stopPlayerTimer( void );
282 static int playCurrentVolumeTone( MfwEvt e, MfwTim *tc );
283 void startVolumeTimer();
284 void stopVolumeTimer(void);
285 static void soundsPlayVolumeMelody();
286 #endif
287
288 /*Defintion for First tone being played - RAVI - 23-12-2005 */
289 #ifdef NEPTUNE_BOARD
290 #define FIRST_TONE_PLAYED 1
291 #endif
292 /*END RAVI */
293
294 /*******************************************************************************
295
296 Local Function prototypes
297
298 *******************************************************************************/
299
300 static int winEvent( MfwEvt e, MfwWin *w );
301 static int keyEvent( MfwEvt e, MfwKbd *kc );
302 static int keyEventLong( MfwEvt e, MfwKbd *kc );
303
304 static void ( *show )( void );
305
306 //Apr 05, 2005 REF: ENH 29994 xdeepadh
307 #ifndef FF_MIDI_RINGER
308 static int playCurrentSound( MfwEvt e, MfwTim *tc );
309 #endif
310 static int getCallingMenu( MfwEvt e, MfwTim *tc );
311 static int setSelection( MfwEvt e, MfwWin *w );
312
313 static void delayThenPlayMelody( void );
314 static void stopPlayingMelody( void );
315
316 static void readSettingsFromPCM( void );
317 static void writeSettingsToPCM( UBYTE flush );
318
319 static void soundsCreate( MfwHnd parent );
320 static int VibratorTimerEvent( MfwEvt e, MfwTim *t );
321
322
323 void sounds (T_MFW_HND win, USHORT event, SHORT value, void * parameter);
324 void sounds_dialog_cb(T_MFW_HND win, UBYTE identifier, UBYTE reason);
325 static void sounds_dialog(void);
326 static int sounds_win_cb (T_MFW_EVENT event, T_MFW_WIN * win);
327 static int melody_win_cb (MfwEvt e, MfwWin *w);
328 void melody_exec_cb (T_MFW_HND win, USHORT event, SHORT value, void * parameter);
329 void sounds_destroy (T_MFW_HND own_window);
330 T_MFW_HND sounds_create (T_MFW_HND parent_window);
331 void sounds_Exit (T_MFW_HND own_window);
332 T_MFW_HND sounds_Init (T_MFW_HND parent_window);
333 void MelodyList_cb(T_MFW_HND * Parent, ListMenuData * ListData);
334 static void melody_destroy(MfwHnd own_window);
335 static MfwHnd sounds_show_info(T_MFW_HND parent, int str1, int str2, T_VOID_FUNC callback);
336
337 #define SHOW_CONFIRM 3
338 #define ACTIVATE_CONFIRM 4
339 #define DEACTIVATE_CONFIRM 5
340
341 /*******************************************************************************
342
343 Local typedefs
344
345 *******************************************************************************/
346
347 /* Define the types of volume we cater for
348 */
349 typedef enum {
350 silent = (UBYTE)0,
351 volLow,
352 volMedium,
353 volHigh,
354 increasing
355 } VOL_ENUM;
356
357
358 /* And the key tones
359 */
360 typedef enum
361 {
362 KEYTONE_NONE,
363 KEYTONE_BEEP,
364 KEYTONE_DTMF
365 } SoundsKeyTones;
366
367
368 /* The following definition provides a structure to control the
369 ringing operation
370 */
371
372 typedef struct MMI_CURRENT_RINGER_STRUCT {
373 /* variable to browse a list */
374 UBYTE ringer; // index of permanent active tune in soundlist and ringerItem
375 UBYTE vibrator; // vibrator
376 UBYTE volumeSetting; // values (0 = silent, 4= loud, 5 = increasing)
377 UBYTE keypadOn; // on/off values
378 UBYTE AlarmOn;
379 UBYTE OrganiserAlert;
380 UBYTE CreditLow;
381 UBYTE SMSTone;
382 UBYTE VoiceTone; /*CQ 10586 - API - 19/06/03 - Add this ID*/
383 UBYTE SMSBroadcast;
384 UBYTE battLow;
385 UBYTE earpiece;
386 UBYTE language;
387 UBYTE Equalizer;
388 } RINGER_STRUCT_BROWSER;
389
390 /* ------------- Variables --------------- */
391
392 static SoundSettingState soundReason=SoundsNone;
393 // Change behavior of menu scroll up/down, meni item selected on scrolling.
394 static BOOL scrollSelectMenuItem= FALSE;
395 static BOOL volumeSetting2Pcm =FALSE;
396 static RINGER_STRUCT_BROWSER current =
397 { // default settings.
398 AUDIO_MEL_TUNES, // ringer
399 0, // vibrator - off by default
400 volMedium, // volumeSetting
401 2, // keypadOn dtmf
402 1, // AlarmOn
403 1, // OrganiserAlert
404 1, // CreditLow
405 1, // SMSTone
406 1, // SMSBroadcast
407 1, // battLow
408 3, // earpiece
409 1, // language
410 1 // Equalizer
411 };
412
413 typedef enum
414 {
415 E_INIT = 0x0801,
416 E_BACK,
417 E_ABORT,
418 E_EXIT,
419 E_RETURN,
420 E_OK
421 } e_M_events;
422
423 T_MELODY_INFO sounds_data;
424
425
426
427 /*******************************************************************************
428
429 Module local variables
430
431 *******************************************************************************/
432 /* RAVI - 20-1-2006 */
433 /* Store the volume settings */
434 #ifdef NEPTUNE_BOARD
435 static UBYTE lastVolumeSetting;
436 static UBYTE scrollVolumeSetting;
437 #endif
438 /* END RAVI */
439 static UBYTE oldVolumeSetting; /* Previous setting of the volume */
440 static MfwHnd win; /* our window */
441 static MfwHnd kbd; /* our keyboard handler */
442 static MfwHnd kbdLong; /* our keyboard handler for Long pressed */
443 static MfwHnd hRingerStartTimer; /* timeout till start of melody */
444 //Apr 05, 2005 REF: ENH 29994 xdeepadh
445 #ifdef FF_MIDI_RINGER
446 MfwHnd hPlayerStartTimer; /* timeout till start of midi file */
447 #endif
448 static MfwHnd hRingerVolSettingTimeOut; /* 4 second timeout for volume setting menu */
449
450 static MfwHnd hWinDispTimer; /* timer to show result windows */
451
452 /* Maintain vibrator state information here
453 */
454 static MfwHnd VibratorTimer;
455 static UBYTE Vibrating = NOT_VIBRATING;
456 static UBYTE vibrator_counter=0;
457
458 /* General state information
459 */
460 static MmiState nextState;
461 static MfwHnd lastFocus;
462
463
464
465 /* Tune details
466 */
467 static int CurrentTune = 0;
468 static int LastTune = 0;
469
470 static const MfwMnuAttr melody_menuAttrib =
471 {
472 &melody_menuArea,
473 MNU_LEFT | MNU_LIST | MNU_CUR_LINE, /* centered page menu */
474 -1, /* use default font */
475 NULL, /* with these items */
476 0, /* number of items */
477 COLOUR_LIST_XX, TxtNull, NULL, MNUATTRSPARE
478
479 };
480
481 /*******************************************************************************
482
483 Private Methods
484
485 *******************************************************************************/
486
487 /******************************************************************************
488 *$Function: setDefaultSound
489 *
490 *$Description: This function will read from Flash during boot up and updated the
491 * current ringer structure. So after reset the stored tones will get
492 * played.
493 *
494 *$Returns: none
495 *
496 *$Arguments: none
497 *$Author : RAVI - 23-12-2005
498 ******************************************************************************/
499 #ifdef NEPTUNE_BOARD
500 void setDefaultSound()
501 {
502 if (flash_read() >= EFFS_OK)
503 {
504 /* Assign the current structure with FFS stored value */
505 current.ringer = FFS_flashData.ringer;
506 current.SMSTone = FFS_flashData.SMSTone;
507 current.AlarmOn = FFS_flashData.AlarmOn;
508 current.volumeSetting = FFS_flashData.volumeSetting;
509 }
510 /* RAVI - 20-1-2006 */
511 /* Store the initial volume settings done by user */
512 lastVolumeSetting = current.volumeSetting;
513 scrollVolumeSetting = 0;
514 /* END RAVI */
515 }
516 #endif
517
518 USHORT getSoundsReason(void)
519 {
520 return soundReason;
521 }
522 /*******************************************************************************
523
524 $Function: setSoundsReason
525
526 $Description: Set the reason why the volume settings was invoked. Called to indicated
527 that the volume settings is being invoked from Idle or from the incoming
528 call screens.
529
530 $Returns: none
531
532 $Arguments: none
533
534 *******************************************************************************/
535 void setSoundsReason(USHORT reason)
536 {
537
538 switch(reason)
539 {
540 case SettingVolume:
541 soundReason = SettingVolume;
542 break;
543 case SoundsNone:
544 default:
545 soundReason = SoundsNone;
546 break;
547 }
548 }
549 /*******************************************************************************
550
551 $Function: volMenuItemSelected
552
553 $Description: A volume menu item has been selected, store the setting into PCM.
554
555 $Returns: none
556
557 $Arguments: none
558
559 *******************************************************************************/
560 void volMenuItemSelected(void)
561 {
562
563 TRACE_FUNCTION("volMenuItemSelected");
564 volumeSetting2Pcm =TRUE;
565 /* Apr 05, 2005 REF: ENH 29994 xdeepadh */
566 #ifdef FF_MIDI_RINGER
567 /* Save the volume for a given ringer mode */
568 TRACE_EVENT_P1("Volume set is %d",current.volumeSetting);
569 mfw_ringer_set_volume(get_ringer_mode(),(T_AS_VOLUME)getCurrentVoulmeSettings());
570 #endif
571 }
572 /*******************************************************************************
573
574 $Function: getScrollSelectMenuItem
575
576 $Description: get the scroll/select menu status.
577
578 $Returns: Status
579
580 $Arguments: none
581
582 *******************************************************************************/
583 BOOL getScrollSelectMenuItem(void)
584 {
585 TRACE_FUNCTION("getScrollSelectMenuItem");
586 if (scrollSelectMenuItem == TRUE)
587 return TRUE;
588 else
589 return FALSE;
590 }
591 /*******************************************************************************
592
593 $Function: clearScrollSelectMenuItem
594
595 $Description: Reset the scroll/select menu behavior.
596
597 $Returns: none
598
599 $Arguments: none
600
601 *******************************************************************************/
602 void clearScrollSelectMenuItem(void)
603 {
604 TRACE_FUNCTION("clearScrollSelectMenuItem");
605 scrollSelectMenuItem=FALSE;
606 // soundReason = SoundsNone; MZ this flag cleared when user exits the melody/Volume menu.
607 //Apr 05, 2005 REF: ENH 29994 xdeepadh
608 #ifdef FF_MIDI_RINGER
609 mfw_player_stop(sounds_midi_player_stop_cb);
610 #else
611 stopPlayingMelody();
612 #endif
613 }
614
615 /*******************************************************************************
616
617 $Function: soundsSetVolume
618
619 $Description: Function determines if user is in the Melody/SMS/Alarm ringer menu
620 and has selected the vloume settings option.
621
622 $Returns: none
623
624 $Arguments: none
625
626 *******************************************************************************/
627 void soundsSetVolume(void)
628 {
629
630 TRACE_FUNCTION("soundsSetVolume");
631 //Apr 05, 2005 REF: ENH 29994 xdeepadh
632 #ifdef FF_MIDI_RINGER
633 //Create 0.5 second ringer delay timer.
634 hPlayerStartTimer = timCreate( 0, TIMHALFSECOND, (MfwCb)playCurrentVolumeTone);
635 //Set the audiopath to speaker.
636 mfw_ringer_set_audiopath();
637 //Set the voice limit to 32 and channel to stereo in idle mode
638 mfw_player_midi_set_params(FF_MIDI_VOICE_LIMIT,MIDI_CHANNEL_STEREO);
639 //Nov 02, 2005 REF:ER OMAPS00039044 xdeepadh
640 //Set the Mp3 Parameters .Size of the file where the melody must start is set 0(from beginning)
641 //and channel is set to stereo.
642 #ifdef FF_MP3_RINGER
643 mfw_player_mp3_set_params(MP3_PLAY_FROM_START,MP3_CHANNEL_STEREO);
644 #endif //FF_MP3_RINGER
645
646 //Nov 21, 2005 REF:ER OMAPS00057430 nekkareb
647 //Set the AAC Parameters .Size of the file where the melody must start is set 0(from beginning)
648 //and channel is set to stereo.
649 #ifdef FF_AAC_RINGER
650 mfw_player_aac_set_params(AAC_PLAY_FROM_START,AAC_CHANNEL_STEREO);
651 #endif //FF_AAC_RINGER
652
653 #endif
654
655 if(soundReason == MelodySelect || soundReason == SettingSMSTone ||
656 soundReason == SettingAlarm || soundReason == SettingVolume)
657 {
658 // Menu items will be selected on scrolling.
659 scrollSelectMenuItem = TRUE;
660 // store the setting to PCM if volume setting is selected.
661 volumeSetting2Pcm=FALSE;
662 }
663 else
664 {
665 scrollSelectMenuItem = FALSE;
666 }
667
668 }
669
670
671
672 /*******************************************************************************
673
674 $Function: IdleScreenVolumeTimer
675
676 $Description: Function creates the volume timer for idle screen.
677
678 $Returns: none
679
680 $Arguments: none
681
682 *******************************************************************************/
683
684 void IdleScreenVolumeTimer()
685 {
686 TRACE_FUNCTION("IdleScreenVolumeTimer");
687 //Apr 05, 2005 REF: ENH 29994 xdeepadh
688 #ifdef FF_MIDI_RINGER
689 //Create 0.5 second ringer delay timer.
690 hPlayerStartTimer = timCreate( 0, TIMHALFSECOND, (MfwCb)playCurrentVolumeTone);
691 //Set the audiopath to speaker.
692 mfw_ringer_set_audiopath();
693 //Set the voice limit to 32 and channel to stereo in idle mode
694 mfw_player_midi_set_params(FF_MIDI_VOICE_LIMIT,MIDI_CHANNEL_MONO);
695 //Nov 02, 2005 REF:ER OMAPS00039044 xdeepadh
696 //Set the Mp3 Parameters .Size of the file where the melody must start is set 0(from beginning)
697 //and channel is set to Mono.
698 #ifdef FF_MP3_RINGER
699 mfw_player_mp3_set_params(MP3_PLAY_FROM_START,MP3_CHANNEL_MONO);
700 #endif //FF_MP3_RINGER
701
702 //Nov 21, 2005 REF:ER OMAPS00057430 nekkareb
703 //Set the AAC Parameters .Size of the file where the melody must start is set 0(from beginning)
704 //and channel is set to Mono.
705 #ifdef FF_AAC_RINGER
706 mfw_player_aac_set_params(AAC_PLAY_FROM_START,AAC_CHANNEL_MONO);
707 #endif //FF_AAC_RINGER
708
709 #endif
710 }
711
712 /*******************************************************************************
713
714 $Function: setSilentModeVolumeOn
715
716 $Description:
717
718 $Returns: none
719
720 $Arguments: none
721
722 *******************************************************************************/
723 void setSilentModeVolume(void)
724 {
725
726 // Aug 30, 2005 REF: SPR 34018 xdeepadh
727 #ifdef FF_MIDI_RINGER
728
729 T_AS_RINGER_INFO * ringer_info;
730 T_AS_RINGER_INFO temp_ringer_info;
731 TRACE_FUNCTION("setSilentModeVolume");
732 // Save the volume for incoming call
733 ringer_info = mfw_ringer_get_info(AS_RINGER_MODE_IC,&temp_ringer_info);
734 oldVolumeSetting = ringer_info->volume ;
735 TRACE_EVENT_P1("Volume set in silent mode is %d",oldVolumeSetting);
736 //Set the volume to silent
737 current.volumeSetting = (UBYTE)AS_VOLUME_SILENT;
738 TRACE_EVENT_P1("Volume set is %d",current.volumeSetting);
739 mfw_ringer_set_volume(AS_RINGER_MODE_IC,(T_AS_VOLUME)getCurrentVoulmeSettings());
740 #else
741 stopPlayingMelody();
742 oldVolumeSetting = current.volumeSetting;
743 current.volumeSetting = SILENT_VOLUME;
744 audio_SetAmplf (AUDIO_BUZZER, current.volumeSetting);
745 #endif
746 }
747
748 /*******************************************************************************
749
750 $Function: setSilentModeVolumeOn
751
752 $Description:
753
754 $Returns: none
755
756 $Arguments: none
757
758 *******************************************************************************/
759 void restoreSilentModeVolume(void)
760 {
761
762 TRACE_FUNCTION("restoreSilentModeVolume");
763 // Aug 30, 2005 REF: SPR 34018 xdeepadh
764 #ifdef FF_MIDI_RINGER
765 //Set the volume back to the old one
766 TRACE_EVENT_P1("oldVolumeSetting set is %d",oldVolumeSetting);
767 mfw_ringer_set_volume(AS_RINGER_MODE_IC,(T_AS_VOLUME)oldVolumeSetting);
768 #else
769 stopPlayingMelody();
770 current.volumeSetting =oldVolumeSetting;
771 audio_SetAmplf (AUDIO_BUZZER, current.volumeSetting);
772 #endif
773 }
774
775 /*******************************************************************************
776
777 $Function: soundsVolSilent
778
779 $Description: set voulme level to silent.
780
781 $Returns: none
782
783 $Arguments: none
784
785 *******************************************************************************/
786 void soundsVolSilent(void)
787 {
788 //Apr 05, 2005 REF: ENH 29994 xdeepadh
789 #ifdef FF_MIDI_RINGER
790 //Display silent mode in the idle screen only for the incoming call volume.
791 if(soundReason == MelodySelect || soundReason == SettingVolume)
792 {
793 FFS_flashData.settings_status |= SettingsSilentMode;
794 flash_write();
795 }
796 #else
797 FFS_flashData.settings_status |= SettingsSilentMode;
798 flash_write();
799 #endif
800
801 TRACE_EVENT("soundsVolSilent");
802 //Apr 05, 2005 REF: ENH 29994 xdeepadh
803 #ifdef FF_MIDI_RINGER
804 current.volumeSetting =(UBYTE)AS_VOLUME_SILENT;
805 stopVolumeTimer();
806 startVolumeTimer();
807 #else
808 /* RAVI - 20-1-2006 */
809 #ifdef NEPTUNE_BOARD
810 current.volumeSetting =SILENT_VOLUME;
811 #endif
812 /* END - RAVI */
813 stopPlayingMelody();
814
815 if(volumeSetting2Pcm != TRUE)
816 {
817 current.volumeSetting =SILENT_VOLUME;
818 audio_SetAmplf (AUDIO_BUZZER, current.volumeSetting);
819
820 #ifdef FF_MMI_RINGTONE /* MSL Ring tone play */
821 audio_PlaySoundID(AUDIO_BUZZER, CALLTONE_SELECT, 0, AUDIO_PLAY_ONCE);
822 #else
823
824 /* RAVI - 20-1-2006 */
825 #ifdef NEPTUNE_BOARD
826 /* Store the currently stored volume content */
827 audio_PlaySoundID(AUDIO_BUZZER, current.ringer, current.volumeSetting, AUDIO_PLAY_ONCE);
828 #else
829 /* API - 04/09/03 - SPR2447 - Remove the call to AUDIO_PLAY_INFINITE and replace with AUDIO_PLAY_ONCE*/
830 audio_PlaySoundID(AUDIO_BUZZER, current.ringer, 0, AUDIO_PLAY_ONCE);
831 /* API - 04/09/03 - SPR2447 - END*/
832 #endif
833 /* END RAVI */
834 #endif
835
836 }
837 else
838 {
839 //store setting into PCM
840 volumeSetting2Pcm=FALSE;
841 }
842 #endif
843
844
845 }
846 /*******************************************************************************
847
848 $Function: soundsVolLow
849
850 $Description: set voulme level to low.
851
852 $Returns: none
853
854 $Arguments: none
855
856 *******************************************************************************/
857 void soundsVolLow(void)
858 {
859
860 FFS_flashData.settings_status &= ~SettingsSilentMode;
861 flash_write();
862 TRACE_EVENT("soundsVolLow");
863 //Apr 05, 2005 REF: ENH 29994 xdeepadh
864 #ifdef FF_MIDI_RINGER
865 current.volumeSetting =(UBYTE)AS_VOLUME_LOW;
866 stopVolumeTimer();
867 startVolumeTimer();
868 #else
869 /* RAVI - 20-1-2006 */
870 #ifdef NEPTUNE_BOARD
871 current.volumeSetting = LOW_VOLUME;
872 #endif
873 /*END RAVI */
874 stopPlayingMelody();
875 if(volumeSetting2Pcm != TRUE)
876 {
877 current.volumeSetting = LOW_VOLUME;
878 audio_SetAmplf (AUDIO_BUZZER, current.volumeSetting);
879
880 #ifdef FF_MMI_RINGTONE /* MSL Ring tone play */
881 audio_PlaySoundID(AUDIO_BUZZER, CALLTONE_SELECT, 0, AUDIO_PLAY_ONCE);
882 #else
883
884 /* RAVI - 20-1-2006 */
885 #ifdef NEPTUNE_BOARD
886 audio_PlaySoundID(AUDIO_BUZZER, current.ringer, current.volumeSetting, AUDIO_PLAY_ONCE);
887 #else
888 /* API - 04/09/03 - SPR2447 - Remove the call to AUDIO_PLAY_INFINITE and replace with AUDIO_PLAY_ONCE*/
889 audio_PlaySoundID(AUDIO_BUZZER, current.ringer, 0, AUDIO_PLAY_ONCE);
890 /* API - 04/09/03 - SPR2447 - END*/
891 #endif
892 /* END RAVI */
893 #endif
894
895 }
896 else
897 {
898 //store setting into PCM
899 volumeSetting2Pcm=FALSE;
900 }
901 #endif
902
903
904 }
905 /*******************************************************************************
906
907 $Function: soundsVolMedium
908
909 $Description: set voulme level to Medium
910
911 $Returns: none
912
913 $Arguments: none
914
915 *******************************************************************************/
916 void soundsVolMedium(void)
917 {
918
919 FFS_flashData.settings_status &= ~SettingsSilentMode;
920 flash_write();
921 TRACE_EVENT("soundsVolMedium");
922 //Apr 05, 2005 REF: ENH 29994 xdeepadh
923 #ifdef FF_MIDI_RINGER
924 current.volumeSetting =(UBYTE)AS_VOLUME_MEDIUM;
925 stopVolumeTimer();
926 startVolumeTimer();
927 #else
928 /* RAVI - 20-1-2006 */
929 #ifdef NEPTUNE_BOARD
930 current.volumeSetting = MEDIUM_VOLUME;
931 #endif
932 /* END RAVI */
933 stopPlayingMelody();
934 if(volumeSetting2Pcm != TRUE)
935 {
936 current.volumeSetting = MEDIUM_VOLUME;
937 audio_SetAmplf (AUDIO_BUZZER, current.volumeSetting);
938
939 #ifdef FF_MMI_RINGTONE /* MSL Ring Tone Play */
940 audio_PlaySoundID(AUDIO_BUZZER, CALLTONE_SELECT, 0, AUDIO_PLAY_ONCE);
941 #else
942
943 /* RAVI - 20-1-2006 */
944 #ifdef NEPTUNE_BOARD
945 audio_PlaySoundID(AUDIO_BUZZER, current.ringer, current.volumeSetting, AUDIO_PLAY_ONCE);
946 #else
947 /* API - 04/09/03 - SPR2447 - Remove the call to AUDIO_PLAY_INFINITE and replace with AUDIO_PLAY_ONCE*/
948 audio_PlaySoundID(AUDIO_BUZZER, current.ringer, 0, AUDIO_PLAY_ONCE);
949 /* API - 04/09/03 - SPR2447 - END*/
950 #endif
951 /* END RAVI */
952 #endif
953
954 }
955 else
956 {
957 //store setting into PCM
958 volumeSetting2Pcm=FALSE;
959 }
960 #endif
961
962
963
964 }
965 /*******************************************************************************
966
967 $Function: soundsVolHigh
968
969 $Description: set voulme level to High
970
971 $Returns: none
972
973 $Arguments: none
974
975 *******************************************************************************/
976 void soundsVolHigh(void)
977 {
978
979 FFS_flashData.settings_status &= ~SettingsSilentMode;
980 flash_write();
981
982 TRACE_EVENT("soundsVolHigh");
983 //Apr 05, 2005 REF: ENH 29994 xdeepadh
984 #ifdef FF_MIDI_RINGER
985 current.volumeSetting =(UBYTE)AS_VOLUME_HIGH;
986 stopVolumeTimer();
987 startVolumeTimer();
988
989 #else
990 /* RAVI - 20-1-2006 */
991 #ifdef NEPTUNE_BOARD
992 current.volumeSetting = HIGH_VOLUME;
993 #endif
994
995 stopPlayingMelody();
996 if(volumeSetting2Pcm != TRUE)
997 {
998 current.volumeSetting =HIGH_VOLUME;
999 audio_SetAmplf (AUDIO_BUZZER, current.volumeSetting);
1000
1001 #ifdef FF_MMI_RINGTONE /* MSL Ring Tone Play */
1002 audio_PlaySoundID(AUDIO_BUZZER, CALLTONE_SELECT, 0, AUDIO_PLAY_ONCE);
1003 #else
1004
1005 /* RAVI - 20-1-2006 */
1006 #ifdef NEPTUNE_BOARD
1007 audio_PlaySoundID(AUDIO_BUZZER, current.ringer, current.volumeSetting, AUDIO_PLAY_ONCE);
1008 #else
1009 /* API - 04/09/03 - SPR2447 - Remove the call to AUDIO_PLAY_INFINITE and replace with AUDIO_PLAY_ONCE*/
1010 audio_PlaySoundID(AUDIO_BUZZER, current.ringer, 0, AUDIO_PLAY_ONCE);
1011 /* API - 04/09/03 - SPR2447 - END*/
1012 #endif
1013 /* END RAVI */
1014 #endif
1015
1016 }
1017 else
1018 {
1019 //store setting into PCM
1020 volumeSetting2Pcm=FALSE;
1021 }
1022 #endif
1023
1024
1025 }
1026 /*******************************************************************************
1027
1028 $Function: soundsVolInc
1029
1030 $Description: set voulme level to increasing
1031
1032 $Returns: none
1033
1034 $Arguments: none
1035
1036 *******************************************************************************/
1037 //Apr 05, 2005 REF: ENH 29994 xdeepadh
1038 #ifndef FF_MIDI_RINGER
1039 void soundsVolInc(void)
1040 {
1041 FFS_flashData.settings_status &= ~SettingsSilentMode;
1042 flash_write();
1043 /* RAVI - 20-1-2006 */
1044 #ifdef NEPTUNE_BOARD
1045 current.volumeSetting = INCREASE_VOLUME;
1046 #endif
1047 /* END RAVI */
1048 stopPlayingMelody();
1049 if(volumeSetting2Pcm != TRUE)
1050 {
1051 current.volumeSetting = INCREASE_VOLUME;
1052 audio_SetAmplf (AUDIO_BUZZER, current.volumeSetting);
1053
1054 #ifdef FF_MMI_RINGTONE /* MSL Ring Tone Play */
1055 audio_PlaySoundID(AUDIO_BUZZER, CALLTONE_SELECT, 0, AUDIO_PLAY_ONCE);
1056 #else
1057
1058 /* RAVI - 20-1-2006 */
1059 #ifdef NEPTUNE_BOARD
1060 audio_PlaySoundID(AUDIO_BUZZER, current.ringer, current.volumeSetting, AUDIO_PLAY_ONCE);
1061 #else
1062 /* API - 04/09/03 - SPR2447 - Remove the call to AUDIO_PLAY_INFINITE and replace with AUDIO_PLAY_ONCE*/
1063 audio_PlaySoundID(AUDIO_BUZZER, current.ringer, 0, AUDIO_PLAY_ONCE);
1064 /* API - 04/09/03 - SPR2447 - END*/
1065 #endif
1066 /* END RAVI */
1067 #endif
1068
1069 }
1070 else
1071 {
1072 //store setting into PCM
1073 volumeSetting2Pcm=FALSE;
1074
1075 }
1076
1077
1078 }
1079
1080 #endif
1081 /*******************************************************************************
1082
1083 $Function: soundReasonRinger
1084
1085 $Description: setup the soundReason to be Ringer Melody settings.
1086
1087 $Returns: none
1088
1089 $Arguments: none
1090
1091 *******************************************************************************/
1092 void soundReasonRinger(void)
1093 {
1094 soundReason = MelodySelect;
1095 }
1096 /*******************************************************************************
1097
1098 $Function: soundReasonSmsTone
1099
1100 $Description: Setup the soundReason to be SMS tones settings.
1101
1102 $Returns: none
1103
1104 $Arguments: none
1105
1106 *******************************************************************************/
1107 void soundReasonSmsTone(void)
1108 {
1109 soundReason = SettingSMSTone;
1110 }
1111 /*******************************************************************************
1112
1113 $Function: soundReasonAlarm
1114
1115 $Description: Setup the soundReason to be Alarm settings.
1116
1117 $Returns: none
1118
1119 $Arguments: none
1120
1121 *******************************************************************************/
1122 void soundReasonAlarm(void)
1123 {
1124 soundReason = SettingAlarm;
1125 }
1126 /*******************************************************************************
1127
1128 $Function: getcurrentSMSTone
1129
1130 $Description: Access function for the current SMS Tone.
1131 $Returns: Tone Id
1132
1133 $Arguments: None
1134
1135 *******************************************************************************/
1136 UBYTE getcurrentSMSTone(void)
1137 {
1138 return current.SMSTone;
1139 }/*******************************************************************************
1140
1141 $Function: getcurrentVoiceTone
1142
1143 $Description: Access function for the current SMS Tone.
1144 $Returns: Tone Id
1145
1146 $Arguments: None
1147
1148 *******************************************************************************/
1149 /*CQ 10586 - API - 19/06/03 - Add this function to return the curret sound for Voice mail notification*/
1150 UBYTE getcurrentVoiceTone(void)
1151 {
1152 return current.SMSTone; // At present return the SMS tone untill settings have been updated
1153 }
1154 /*******************************************************************************
1155
1156 $Function: getcurrentSMSTone
1157
1158 $Description: Access function for the current SMS Tone.
1159 $Returns: Tone Id
1160
1161 $Arguments: None
1162
1163 *******************************************************************************/
1164 UBYTE getcurrentAlarmTone(void)
1165 {
1166 return current.AlarmOn;
1167 }
1168 /*******************************************************************************
1169
1170 $Function: getCurrentRingerSettings
1171
1172 $Description: Access function for the current ringer settings data.
1173 $Returns: Ringer Id.
1174
1175 $Arguments: None
1176
1177 *******************************************************************************/
1178 UBYTE getCurrentRingerSettings(void)
1179 {
1180 return current.ringer;
1181 }
1182 /*******************************************************************************
1183
1184 $Function: getCurrentVoulmeSettings
1185
1186 $Description: Access function for the current ringer volume settings data.
1187 $Returns: volume
1188
1189 $Arguments: None
1190
1191 *******************************************************************************/
1192 UBYTE getCurrentVoulmeSettings(void)
1193 {
1194 TRACE_EVENT_P1("getCurrentVoulmeSettings is %d",current.volumeSetting);
1195 return current.volumeSetting;
1196 }
1197 /*******************************************************************************
1198
1199 $Function: getMelodyListStatus
1200
1201 $Description: Status flag indicating if a melody selection menu is active.
1202 $Returns: status
1203
1204 $Arguments: None
1205
1206 *******************************************************************************/
1207 BOOL getMelodyListStatus(void)
1208 {
1209 if(soundReason == MelodySelect ||
1210 soundReason == SettingSMSTone ||
1211 soundReason == SettingAlarm )
1212 return TRUE;
1213 else
1214 return FALSE;
1215 }
1216
1217
1218 /*******************************************************************************
1219
1220 $Function: stopPlayingMelody
1221
1222 $Description: stop currently played ringer melody
1223
1224 $Returns: None
1225
1226 $Arguments: None
1227
1228 *******************************************************************************/
1229 static void stopPlayingMelody( void )
1230 {
1231 TRACE_FUNCTION( "stopPlayingMelody" );
1232
1233 /* If a timer event is running we want to stop that as well,
1234 since we don't really want to turn the tune off and have
1235 it start again when the timer expires
1236 */
1237 if ( hRingerStartTimer != NULL )
1238 timStop( hRingerStartTimer );
1239
1240 /* Are we playing a tune
1241 */
1242 if ( LastTune )
1243 {
1244 /* To stop playing the previous ring tone - RAVI - 23-12-2005 */
1245 #ifdef NEPTUNE_BOARD
1246 #ifdef FF_MMI_RINGTONE /*MSL Stop */
1247 audio_StopSoundbyID( AUDIO_BUZZER, CALLTONE_SELECT);
1248 #else
1249 audio_StopSoundbyID( AUDIO_BUZZER, LastTune - 1 );
1250 #endif
1251 #else
1252 audio_StopSoundbyID( AUDIO_BUZZER, LastTune );
1253 #endif
1254 }
1255
1256 /* Need to wait for the tune to stop before trying to
1257 set up the next tune, so wait always
1258 */
1259 vsi_t_sleep( 0, 5 );
1260 }
1261
1262 /*******************************************************************************
1263
1264 $Function: startPlayingMelody
1265
1266 $Description: Start played the ringer melody
1267
1268 $Returns: None
1269
1270 $Arguments: Melody_id
1271
1272 *******************************************************************************/
1273 //Apr 05, 2005 REF: ENH 29994 xdeepadh
1274 #ifndef FF_MIDI_RINGER
1275 static void startPlayingMelody(UBYTE melody_id)
1276 {
1277 #ifdef NEPTUNE_BOARD
1278 BYTE bVolumeSetting;
1279 #endif
1280
1281 if ( hRingerStartTimer != NULL )
1282 timStop( hRingerStartTimer );
1283
1284 #ifdef FF_MMI_RINGTONE /* MSL Ring tone play */
1285 audio_PlaySoundID(AUDIO_BUZZER, CALLTONE_SELECT, (BYTE)current.volumeSetting, AUDIO_PLAY_ONCE);
1286 #else
1287
1288 /* RAVI - 20-1-2006 */
1289 #ifdef NEPTUNE_BOARD
1290 if (soundReason == SettingVolume)
1291 {
1292 switch (scrollVolumeSetting)
1293 {
1294 case 0:
1295 bVolumeSetting = SILENT_VOLUME;
1296 break;
1297 case 1:
1298 bVolumeSetting = LOW_VOLUME;
1299 break;
1300 case 2:
1301 bVolumeSetting = MEDIUM_VOLUME;
1302 break;
1303 case 3:
1304 bVolumeSetting = HIGH_VOLUME;
1305 break;
1306 case 4:
1307 bVolumeSetting = INCREASE_VOLUME;
1308 break;
1309 default:
1310 bVolumeSetting = LOW_VOLUME;
1311 break;
1312 }
1313 audio_PlaySoundID(AUDIO_BUZZER, melody_id, (BYTE)bVolumeSetting,
1314 AUDIO_PLAY_ONCE);
1315 }
1316 else
1317 {
1318 audio_PlaySoundID(AUDIO_BUZZER, melody_id, (BYTE)current.volumeSetting,
1319 AUDIO_PLAY_ONCE);
1320 }
1321 #else
1322 audio_PlaySoundID(AUDIO_BUZZER, melody_id, (BYTE)current.volumeSetting,
1323 AUDIO_PLAY_ONCE);
1324 #endif
1325 /* END - RAVI - 20-1-2006 */
1326 #endif
1327
1328 }
1329 #endif
1330
1331 /*******************************************************************************
1332
1333 $Function: soundsPlayRinger
1334
1335 $Description: Play the tune selected by melody_id, stopping any currently
1336 playing tunes if necessary. Remember to take into account the
1337 volume setting and provide a crescendo if requested
1338
1339 $Returns: None
1340
1341 $Arguments: melody_id, selects the melody to be played
1342
1343 *******************************************************************************/
1344 //Apr 05, 2005 REF: ENH 29994 xdeepadh
1345 #ifndef FF_MIDI_RINGER
1346 static void soundsPlayRinger( int melody_id )
1347 {
1348 CurrentTune = melody_id;
1349 if (LastTune)
1350 {
1351 #ifdef FF_MMI_RINGTONE /*MSL Stop */
1352 audio_StopSoundbyID( AUDIO_BUZZER, CALLTONE_SELECT);
1353 #else
1354 audio_StopSoundbyID (AUDIO_BUZZER,LastTune );
1355 #endif
1356 }
1357 vsi_t_sleep(0, 5);
1358
1359 if (current.volumeSetting == increasing)
1360 {
1361
1362 #ifdef FF_MMI_RINGTONE /* MSL Ring Tone Play */
1363 audio_PlaySoundID ( AUDIO_BUZZER, CALLTONE_SELECT, 0 , AUDIO_PLAY_CRESCENDO );
1364 #else
1365
1366 /* RAVI - 20-1-2006 */
1367 #ifdef NEPTUNE_BOARD
1368 audio_PlaySoundID(AUDIO_BUZZER, CurrentTune, current.volumeSetting, AUDIO_PLAY_ONCE);
1369 #else
1370 audio_PlaySoundID ( AUDIO_BUZZER,CurrentTune, 0 , AUDIO_PLAY_CRESCENDO );
1371 #endif
1372 /* END RAVI */
1373 #endif
1374
1375 }
1376 else
1377 {
1378
1379 #ifdef FF_MMI_RINGTONE /* MSL Ring Tone Play */
1380 audio_PlaySoundID ( AUDIO_BUZZER, CALLTONE_SELECT, 0, AUDIO_PLAY_ONCE );
1381 #else
1382
1383 /* RAVI - 20-1-2006 */
1384 #ifdef NEPTUNE_BOARD
1385 audio_PlaySoundID(AUDIO_BUZZER, CurrentTune, current.volumeSetting, AUDIO_PLAY_ONCE);
1386 #else
1387 audio_PlaySoundID ( AUDIO_BUZZER,CurrentTune, 0, AUDIO_PLAY_ONCE );
1388 #endif
1389 /* END RAVI */
1390 #endif
1391
1392 }
1393 LastTune = CurrentTune;
1394 }
1395 #endif
1396
1397 /*******************************************************************************
1398
1399 $Function: destroyDynaMenu
1400
1401 $Description: frees the memory allocated to a dynamenu (Refer to the
1402 buildMelodyMenu routine below
1403
1404 $Returns: None.
1405
1406 $Arguments: None.
1407
1408 *******************************************************************************/
1409
1410 static void destroyDynaMenu( void )
1411 {
1412
1413 }
1414
1415
1416 /*******************************************************************************
1417
1418 $Function: buildMelodyMenu
1419
1420 $Description: Builds the melody menu dynamenu from the melodies supplied
1421 by the resource manager
1422
1423 $Returns: None
1424
1425 $Arguments: None
1426
1427 *******************************************************************************/
1428 static T_MFW_HND buildMelodyMenu( MfwHnd parent_window)
1429 {
1430 T_MELODY_INFO * data = (T_MELODY_INFO *)ALLOC_MEMORY (sizeof (T_MELODY_INFO));
1431 T_MFW_WIN * win;
1432
1433 TRACE_FUNCTION (">>>> buildMelodyMenu()");
1434
1435 /*
1436 * Create window handler
1437 */
1438
1439 data->sounds_win = win_create (parent_window, 0, E_WIN_VISIBLE, (T_MFW_CB)melody_win_cb);
1440 if (data->sounds_win EQ NULL)
1441 {
1442 return NULL;
1443 }
1444
1445 TRACE_EVENT(">>>> Melody window created: " );
1446 /*
1447 * connect the dialog data to the MFW-window
1448 */
1449
1450 data->mmi_control.dialog = (T_DIALOG_FUNC)melody_exec_cb;
1451 data->mmi_control.data = data;
1452 win = ((T_MFW_HDR *)data->sounds_win)->data;
1453 win->user = (void *)data;
1454 data->parent = parent_window;
1455 winShow(data->sounds_win);
1456 /*
1457 * return window handle
1458 */
1459
1460 return data->sounds_win;
1461 }
1462
1463 /*******************************************************************************
1464
1465 $Function: melody_exec_cb
1466
1467 $Description: Exec callback function of the SMS read window (dynamic list of
1468 all the SMS)
1469
1470 $Returns: none
1471
1472 $Arguments: win - window handler
1473 event - mfw event
1474 parameter - optional data.
1475
1476 *******************************************************************************/
1477 void melody_exec_cb (T_MFW_HND win, USHORT event, SHORT value, void * parameter)
1478 {
1479 T_MFW_WIN * win_data = ((T_MFW_HDR *) win)->data;
1480 T_MELODY_INFO * data = (T_MELODY_INFO *)win_data->user;
1481 UBYTE i;
1482 UBYTE numberOfMelodies=0;
1483 #ifdef FF_MIDI_RINGER
1484 UBYTE file_count=0;
1485 #endif
1486 ListWinInfo * mnu_data = (ListWinInfo *)parameter;
1487
1488 TRACE_FUNCTION (">>>>> melody_exec_cb()");
1489
1490 switch (event)
1491 {
1492 case E_INIT:
1493
1494 TRACE_EVENT(">>>> melody_exec_cb() Event:E_INIT");
1495
1496 /* initialization of administrative data */
1497
1498 data->menu_list_data = (ListMenuData *)ALLOC_MEMORY(sizeof(ListMenuData));
1499
1500 if(data->menu_list_data == 0)
1501 {
1502 TRACE_EVENT("Failed memory alloc 1 ");
1503 return;
1504 }
1505 /*Apr 05, 2005 REF: ENH 29994 xdeepadh */
1506 #ifdef FF_MIDI_RINGER
1507 numberOfMelodies = sounds_midi_return_file_number();
1508 TRACE_EVENT_P1("numberOfMelodies is %d",numberOfMelodies);
1509 /*In case no files have been loaded display info message */
1510 if(numberOfMelodies <= 0)
1511 {
1512 sounds_show_info(0, TxtMidiFileNotLoaded, TxtNull, NULL);
1513 return;
1514
1515 }
1516 #else
1517 numberOfMelodies = resource_GetListCount(RES_MELODY);
1518 #endif
1519
1520 data->menu_list_data->List = (T_MFW_MNU_ITEM *)ALLOC_MEMORY( numberOfMelodies * sizeof(T_MFW_MNU_ITEM) );
1521
1522 if(data->menu_list_data->List == 0)
1523 {
1524 TRACE_EVENT("Failed memory alloc 2");
1525 return;
1526 }
1527
1528 for (i = 0; i < numberOfMelodies ; i++)
1529 {
1530 mnuInitDataItem(&data->menu_list_data->List[i]);
1531 data->menu_list_data->List[i].flagFunc = item_flag_none;
1532
1533 /* Display the midi file names in the list */
1534 /*Apr 05, 2005 REF: ENH 29994 xdeepadh */
1535 #ifdef FF_MIDI_RINGER
1536 data->menu_list_data->List[i].str = (char *)sounds_midi_return_file_name(file_count++);
1537 #else
1538 data->menu_list_data->List[i].str = (char *)MelodyTable[i];
1539 #endif
1540 }
1541
1542 data->menu_list_data->ListLength =numberOfMelodies;
1543 data->menu_list_data->ListPosition = 1;
1544 data->menu_list_data->CursorPosition = 1;
1545 data->menu_list_data->SnapshotSize = numberOfMelodies;
1546 data->menu_list_data->Font = 0;
1547 data->menu_list_data->LeftSoftKey = TxtSoftSelect;
1548 data->menu_list_data->RightSoftKey = TxtSoftBack;
1549 data->menu_list_data->KeyEvents = KEY_ALL;
1550 data->menu_list_data->Reason = 0;
1551 data->menu_list_data->Strings = TRUE;
1552 data->menu_list_data->Attr = (MfwMnuAttr*)&melody_menuAttrib;
1553 /* Apr 05, 2005 REF: ENH 29994 xdeepadh */
1554 #ifdef FF_MIDI_RINGER
1555 data->menu_list_data->Attr->hdrId = TxtMidiFileTitle;
1556 #endif
1557 data->menu_list_data->autoDestroy = FALSE;
1558 listDisplayListMenu(win, data->menu_list_data,(ListCbFunc)MelodyList_cb,0);
1559 /*#ifdef FF_MIDI_RINGER
1560 selected_tone=data->menu_list_data->ListPosition-1;
1561 stopPlayerTimer();
1562 startPlayerTimer();
1563 #endif*/
1564 /* Start playing first ringtone on initial list display - RAVI - 23-12-2005 */
1565 #ifdef NEPTUNE_BOARD
1566 if(getMelodyListStatus()== TRUE)
1567 {
1568 stopPlayingMelody ();
1569 startPlayingMelody(0); /* Play the first menu item which is being selected */
1570 LastTune = FIRST_TONE_PLAYED; /* First Menu Item - Ringer is selected */
1571 }
1572 #endif
1573 /* RAVI - 23-12-2005 */
1574
1575 break;
1576
1577 case E_START_MELODY:
1578 /* Apr 05, 2005 REF: ENH 29994 xdeepadh */
1579 /* Play the midi file when the user has scrolled */
1580 #ifdef FF_MIDI_RINGER
1581 selected_tone=mnu_data->MenuData.ListPosition;
1582 stopPlayerTimer();
1583 startPlayerTimer();
1584 #else
1585
1586 /* When cursor moved - Stop playing old and start playing new - RAVI - 23-12-2005 */
1587 #ifndef NEPTUNE_BOARD
1588 startPlayingMelody(mnu_data->MenuData.ListPosition);
1589 #else
1590 stopPlayingMelody();
1591 startPlayingMelody(mnu_data->MenuData.ListPosition);
1592 LastTune = mnu_data->MenuData.ListPosition+1; /* Store the late tune in global variable */
1593 #endif /* END RAVI */
1594 #endif
1595
1596 break;
1597
1598 case E_RETURN:
1599 break;
1600 default:
1601 break;
1602 }
1603 }
1604 /*******************************************************************************
1605
1606 $Function: MelodyList_cb
1607
1608 $Description: Callback function for the melody list.
1609
1610 $Returns: none
1611
1612 $Arguments: Parent - parent window.
1613 ListData - Menu item list
1614 *******************************************************************************/
1615
1616 void MelodyList_cb(T_MFW_HND * Parent, ListMenuData * ListData)
1617 {
1618 T_MFW_WIN * win_data = ((T_MFW_HDR *)Parent)->data;
1619 T_MELODY_INFO * data = (T_MELODY_INFO *)win_data->user;
1620 T_MFW_HND * l_parent;
1621 /*Apr 05, 2005 REF: ENH 29994 xdeepadh */
1622 #ifdef FF_MIDI_RINGER
1623 T_DISPLAY_DATA DisplayInfo;
1624 T_AS_PLAYER_TYPE player_type;
1625
1626 #ifdef FF_MIDI_LOAD_FROM_MEM
1627 T_MELODY memory_pointer;
1628 #else
1629 char * filename;
1630 #endif
1631 #endif
1632
1633 if ((ListData->Reason EQ LISTS_REASON_BACK) || (ListData->Reason EQ LISTS_REASON_CLEAR)
1634 || (ListData->Reason EQ LISTS_REASON_HANGUP)) /* sbh - added hangup key */
1635 {
1636 l_parent = data->parent;
1637
1638 /*Stop playing ringtone on press of BACK/ CLEAR/ HANGUP - RAVI - 23-12-2005 - SR 13873 */
1639 #ifdef NEPTUNE_BOARD
1640 stopPlayingMelody();
1641 #endif
1642 /* END RAVI - 23-12-2005 */
1643
1644 }
1645 else if(ListData->Reason EQ LISTS_REASON_SELECT)
1646 {
1647 switch(soundReason)
1648 {
1649 case MelodySelect:
1650 TRACE_EVENT("selecting file");
1651 #ifdef FF_MIDI_RINGER /*Use Midi Player*/
1652 #ifdef FF_MIDI_LOAD_FROM_MEM/*If Loc ULC */
1653 memory_pointer=sounds_midi_return_memory_location(ListData->ListPosition);
1654 player_type=mfw_ringer_deduce_player_type(memory_pointer.melody_name);
1655 mfw_ringer_set_memory(player_type,AS_RINGER_MODE_IC,(UINT32*)memory_pointer.melody,(UINT32)memory_pointer.melody_size);
1656 #else
1657 filename =sounds_midi_return_file_name(ListData->ListPosition);
1658 player_type=mfw_ringer_deduce_player_type(filename);
1659 mfw_ringer_set_file(player_type,AS_RINGER_MODE_IC,filename);
1660 #endif
1661
1662 #else //Use Buzzer
1663 stopPlayingMelody();
1664 current.ringer = ListData->ListPosition;
1665 #endif
1666
1667 break;
1668
1669 case SettingSMSTone:
1670
1671 #ifdef FF_MIDI_RINGER //Use Midi Player
1672 #ifdef FF_MIDI_LOAD_FROM_MEM //If ULC
1673 memory_pointer=sounds_midi_return_memory_location(ListData->ListPosition);
1674 player_type=mfw_ringer_deduce_player_type(memory_pointer.melody_name);
1675 mfw_ringer_set_memory(player_type,AS_RINGER_MODE_SMS,(UINT32*)memory_pointer.melody,(UINT32)memory_pointer.melody_size);
1676 #else
1677 filename =sounds_midi_return_file_name(ListData->ListPosition);
1678 player_type=mfw_ringer_deduce_player_type(filename);
1679 mfw_ringer_set_file(player_type,AS_RINGER_MODE_SMS,filename);
1680 #endif
1681 #else/*Use Buzzer*/
1682 stopPlayingMelody();
1683 current.SMSTone = ListData->ListPosition; /* For SMS tones - starting from 40 */
1684 /* Store in FFS - RAVI - 23-12-2005 - SR 13873 */
1685 #ifdef NEPTUNE_BOARD
1686 FFS_flashData.SMSTone= current.SMSTone;
1687 flash_write();
1688 #endif
1689 /* END RAVI - 23-12-2005 */
1690 #endif
1691
1692 break;
1693
1694 case SettingAlarm:
1695 #ifdef FF_MIDI_RINGER /* Use Midi Player */
1696 #ifdef FF_MIDI_LOAD_FROM_MEM
1697 memory_pointer=sounds_midi_return_memory_location(ListData->ListPosition);
1698 player_type=mfw_ringer_deduce_player_type(memory_pointer.melody_name);
1699 mfw_ringer_set_memory(player_type,AS_RINGER_MODE_ALARM,(UINT32*)memory_pointer.melody,(UINT32)memory_pointer.melody_size);
1700 #else
1701 filename =sounds_midi_return_file_name(ListData->ListPosition);
1702 player_type=mfw_ringer_deduce_player_type(filename);
1703 mfw_ringer_set_file(player_type,AS_RINGER_MODE_ALARM,filename);
1704 #endif
1705 #else/*Use Buzzer*/
1706 // need to check alarm status MZ.
1707 current.AlarmOn = ListData->ListPosition;
1708 /* Store in FFS - RAVI - 23-12-2005 - SR 13873 */
1709 #ifdef NEPTUNE_BOARD
1710 FFS_flashData.AlarmOn= current.AlarmOn;
1711 flash_write();
1712 #endif
1713 /* END RAVI - 23-12-2005 */
1714 #endif
1715
1716 default:
1717 break;
1718 }
1719 /* Apr 05, 2005 REF: ENH 29994 xdeepadh */
1720 /* Store selected melody in PCM storage. */
1721 #ifdef FF_MIDI_RINGER
1722 sounds_show_info(0, TxtSelected, TxtNull, NULL);
1723 #endif
1724 }
1725
1726 #ifdef FF_MIDI_RINGER
1727 stopPlayerTimer();
1728 mfw_player_stop(sounds_midi_player_stop_cb);
1729 #else
1730 stopPlayingMelody();
1731 #endif
1732 listsDestroy(ListData->win);
1733 melody_destroy(data->sounds_win);
1734
1735 }
1736
1737 /*******************************************************************************
1738
1739 $Function: melody_destroy
1740
1741 $Description: Destroy the melody window.
1742
1743 $Returns: none
1744
1745 $Arguments: own_window- current window
1746 *******************************************************************************/
1747
1748 static void melody_destroy(MfwHnd own_window)
1749 {
1750 T_MFW_WIN * win_data;
1751 T_MELODY_INFO * data;
1752 UBYTE numberOfMelodies;
1753
1754 TRACE_FUNCTION ("melody_destroy()");
1755
1756 if (own_window)
1757 {
1758 win_data = ((T_MFW_HDR *)own_window)->data;
1759 data = (T_MELODY_INFO *)win_data->user;
1760
1761 if (data)
1762 {
1763 /*
1764 * Delete WIN handler
1765 */
1766 win_delete (data->sounds_win);
1767
1768 /*
1769 * Free Memory
1770 */
1771 //Apr 05, 2005 REF: ENH 29994 xdeepadh
1772 #ifdef FF_MIDI_RINGER
1773 numberOfMelodies = sounds_midi_return_file_number();
1774 #else
1775 numberOfMelodies = resource_GetListCount(RES_MELODY);
1776 #endif
1777
1778 if (data->menu_list_data != NULL)
1779 {
1780 FREE_MEMORY ((void *)data->menu_list_data->List, numberOfMelodies * sizeof (T_MFW_MNU_ITEM));
1781 FREE_MEMORY ((void *)data->menu_list_data, sizeof (ListMenuData));
1782 }
1783 FREE_MEMORY ((void *)data, sizeof (T_MELODY_INFO));
1784 //Apr 05, 2005 REF: ENH 29994 xdeepadh
1785 #ifdef FF_MIDI_RINGER
1786 //Delete the timer used for scrolling
1787 if(hPlayerStartTimer!=NULL)
1788 timDelete(hPlayerStartTimer);
1789 #endif
1790
1791 }
1792 else
1793 {
1794 TRACE_EVENT ("melody_destroy() called twice");
1795 }
1796 }
1797 }
1798
1799 /*******************************************************************************
1800
1801 $Function: melody_win_cb
1802
1803 $Description: Window callback function for the melody window.
1804
1805 $Returns: none
1806
1807 $Arguments: w - mfw window handler
1808 e - mfw event
1809
1810 *******************************************************************************/
1811
1812 static int melody_win_cb (MfwEvt e, MfwWin *w) /* yyy window event handler */
1813 {
1814 TRACE_FUNCTION ("melody_win_cb()");
1815 switch (e)
1816 {
1817 case MfwWinVisible: /* window is visible */
1818 break;
1819 case MfwWinFocussed: /* input focus / selected */
1820 case MfwWinDelete: /* window will be deleted */
1821
1822 default:
1823 return MFW_EVENT_REJECTED;
1824 }
1825 return MFW_EVENT_CONSUMED;
1826 }
1827
1828 /*******************************************************************************
1829
1830 $Function: melody_menu_cb
1831
1832 $Description: Call back function for the melody menu.
1833
1834 $Returns:
1835
1836 $Arguments:
1837 *******************************************************************************/
1838
1839 static int melody_menu_cb (MfwEvt e, MfwMnu *m){
1840
1841 /* T_MFW_HND win = mfwParent(mfw_header()); */ /* RAVI */
1842 /* T_MFW_WIN * win_data = ((T_MFW_HDR *)win)->data; */ /* RAVI */
1843
1844 switch (e)
1845 {
1846 case E_MNU_ESCAPE:
1847 break;
1848 default:
1849 return 0;
1850 }
1851 return 1;
1852 }
1853
1854 /*******************************************************************************
1855
1856 $Function: resource_GetListCount
1857
1858 $Description: Returns the number of entries in resource table.
1859
1860 $Returns: Number of entries in Melody table.
1861
1862 $Arguments: res - Resource Id.
1863
1864 *******************************************************************************/
1865 int resource_GetListCount(res_ResourceID_type res)
1866 // Returns the number of the resource type available in the phone.
1867 {
1868 int index=0;
1869 switch (res)
1870 {
1871 case RES_MELODY:
1872 while(MelodyTable[index] !=0)
1873 index++;
1874 return index;
1875 /* break; */ /* RAVI */
1876
1877 case RES_LANGUAGE:
1878
1879 break;
1880 case RES_STRING:
1881
1882 break;
1883 default:
1884
1885 break;
1886
1887 }
1888 return index;
1889 }
1890
1891 /*******************************************************************************
1892
1893 $Function: buildOnOffMenu
1894
1895 $Description: builds an on/off menu and associates it with a context
1896
1897 $Returns: None
1898
1899 $Arguments: count, number of elements in menu
1900 id3, prompt string
1901 active, context into which the menu should be associated
1902
1903 *******************************************************************************/
1904
1905 static void buildOnOffMenu( int count, int id3, int active )
1906 {
1907 }
1908
1909 /*******************************************************************************
1910
1911 $Function: buildVolumeMenu
1912
1913 $Description: builds the volume menu and associates it with the volume
1914 context
1915
1916 $Returns: None
1917
1918 $Arguments: volume, the context to be associated with
1919
1920 *******************************************************************************/
1921
1922 static void buildVolumeMenu( VOL_ENUM volume )
1923 {
1924 }
1925
1926 /*******************************************************************************
1927
1928 $Function: displayDynaMenu
1929
1930 $Description: show one page of the ringer list, determined by item.
1931
1932 $Returns: None
1933
1934 $Arguments: None
1935
1936 *******************************************************************************/
1937
1938 static void displayDynamenu( void )
1939 {
1940
1941 }
1942
1943 /*******************************************************************************
1944
1945 $Function: displayRingerVolume
1946
1947 $Description: shows the volume setting determined by cVolume
1948
1949 $Returns: None
1950
1951 $Arguments: None
1952
1953 *******************************************************************************/
1954
1955 static void displayRingerVolume( void )
1956 {
1957 }
1958
1959 /*******************************************************************************
1960
1961 $Function: displayOnOffList
1962
1963 $Description: show the On Off (3rd) list, determined by item.
1964
1965 $Returns: None
1966
1967 $Arguments: None
1968
1969 *******************************************************************************/
1970
1971 static void displayOnOffList( void )
1972 {
1973 }
1974 /*******************************************************************************
1975
1976 $Function: buildLanguageMenu
1977
1978 $Description: builds the dynamenu for the RES_LANGUAGE resource type
1979
1980 $Returns: None
1981
1982 $Arguments: None
1983
1984 *******************************************************************************/
1985
1986 static void buildLanguageMenu(void)
1987 {
1988
1989 }
1990
1991 /*******************************************************************************
1992
1993 $Function: delayThenPlayMelody
1994
1995 $Description: play selected ringer melody after short delay
1996
1997 $Returns: None
1998
1999 $Arguments: None
2000
2001 *******************************************************************************/
2002
2003 static void delayThenPlayMelody( void )
2004 {
2005
2006 /* start timer for half a second and on timeout start everlasting play
2007 */
2008 timStart( hRingerStartTimer );
2009 }
2010
2011 /*******************************************************************************
2012
2013 $Function: playCurrentSound
2014
2015 $Description: play tune which is temporarily selected, this event handler
2016 is invoked when the hRingerStartTimer event completes
2017
2018 $Returns: MFW_EVENT_CONSUMED always
2019
2020 $Arguments: e, event, tc timer context
2021
2022 *******************************************************************************/
2023 //Apr 05, 2005 REF: ENH 29994 xdeepadh
2024 #ifndef FF_MIDI_RINGER
2025 static int playCurrentSound( MfwEvt e, MfwTim *tc )
2026 {
2027 soundsPlayRinger(current.ringer);
2028
2029 // stop running timer (One shot mode only)
2030 if (hRingerStartTimer != NULL ) {
2031 timStop(hRingerStartTimer);
2032 }
2033
2034 return MFW_EVENT_CONSUMED;
2035 }
2036
2037 #endif
2038 /*******************************************************************************
2039
2040 $Function: setSelection
2041
2042 $Description: reactivates calling menu after confirming setting
2043
2044 $Returns: MFW_EVENT_PASSED always
2045
2046 $Arguments: e, event, m, window handle
2047
2048 *******************************************************************************/
2049
2050 static int setSelection( MfwEvt e, MfwWin *m )
2051 {
2052 //int UpdatePCM = 0; // RAVI
2053 // int SoundToPlay = -1; // RAVI
2054
2055 TRACE_FUNCTION("setSelection");
2056
2057 /* This implements a state machine, the next setting depends
2058 on the reason we have been invoked
2059
2060 Note the following is still pending implementation
2061 USSD TONE, SVC TONE, MANPLMN TONE
2062 */
2063 switch (soundReason)
2064 {
2065 case MelodySelect:
2066 {
2067 }
2068 break;
2069
2070 case SettingVolume:
2071 {
2072 }
2073 break;
2074
2075 default:
2076 {
2077 /* No action required
2078 */
2079 }
2080 break;
2081 }
2082
2083
2084 /* redisplay sub menu showing changed position of active marker.
2085 */
2086 winShow( win );
2087
2088 return MFW_EVENT_PASSED;
2089 }
2090
2091 /*******************************************************************************
2092
2093 $Function: writeSettingsToPCM
2094
2095 $Description: writes contents of global vars of sounds to PCM or
2096 sets default values
2097
2098 $Returns: None
2099
2100 $Arguments: flush, dictates whether or not flushing should be
2101 performed on the write operation
2102
2103 *******************************************************************************/
2104 static void writeSettingsToPCM( U8 flush )
2105 {
2106 }
2107 /*******************************************************************************
2108
2109 $Function: readSettingsFromPCM
2110
2111 $Description: inits global vars of sounds from PCM or
2112 sets default values
2113
2114 $Returns: None
2115
2116 $Arguments: None
2117
2118 *******************************************************************************/
2119
2120 static void readSettingsFromPCM(void)
2121 {
2122 }
2123
2124 /*******************************************************************************
2125
2126 $Function: soundsCreate
2127
2128 $Description: Create a sounds context, with a window, keyboards, timers
2129 etc.
2130
2131 $Returns: None
2132
2133 $Arguments: parent, handle of the parent window
2134
2135 *******************************************************************************/
2136
2137 static void soundsCreate(MfwHnd parent)
2138 {
2139
2140 }
2141
2142
2143 /*******************************************************************************
2144
2145 $Function: soundsDestroy
2146
2147 $Description: cleans up a context
2148
2149 $Returns: None
2150
2151 $Arguments: None
2152
2153 *******************************************************************************/
2154
2155 static void soundsDestroy(void)
2156 {
2157
2158 }
2159
2160
2161 /*******************************************************************************
2162
2163 $Function: getCallingMenu
2164
2165 $Description: handles transition to calling menu
2166 a) on timeout,
2167 b) during running timer when Clear, SoftKeyLeft
2168 or SoftKeyRight is pressed
2169
2170 $Returns: MFW_EVENT_PASSED
2171
2172 $Arguments: e, event, tc, timer context
2173
2174 *******************************************************************************/
2175
2176 static int getCallingMenu(MfwEvt e, MfwTim *tc)
2177 {
2178 TRACE_FUNCTION( "BACK to invocating Menu" );
2179
2180 return 0;
2181 }
2182
2183 /*******************************************************************************
2184
2185 $Function: winEvent
2186
2187 $Description: window event handler, only deals with the win visible
2188 event, all others are ignored
2189
2190 $Returns: MFW_EVENT_PASSED or MFW_EVENT_CONSUMED depending on the
2191 event
2192
2193 $Arguments: e, event, w, window handle
2194
2195 *******************************************************************************/
2196
2197 static int winEvent (MfwEvt e, MfwWin *w)
2198 {
2199 return MFW_EVENT_CONSUMED;
2200 }
2201
2202
2203 /*******************************************************************************
2204
2205 $Function: keyEventLong
2206
2207 $Description: keyboard event handler Long press
2208
2209 $Returns: MFW_EVENT_PASSED or MFW_EVENT_CONSUMED depending on the
2210 event
2211
2212 $Arguments: e, event, k, keyboard handle
2213
2214 *******************************************************************************/
2215
2216 static int keyEventLong (MfwEvt e, MfwKbd *k)
2217 {
2218 PTRACE( sprintf( buf, "keycode in SOUND keyEvtLong %d", (int) k->code ); )
2219 PTRACE( sprintf( buf, "mfwEvt in SOUND Long 0x%10x", e ); )
2220
2221
2222 return MFW_EVENT_PASSED; /* give other handlers a chance */
2223 }
2224
2225 /*******************************************************************************
2226
2227 $Function: keyEvent
2228
2229 $Description: keyboard event handler
2230
2231 $Returns: MFW_EVENT_PASSED or MFW_EVENT_CONSUMED depending on the
2232 event
2233
2234 $Arguments: e, event, k, keyboard handle
2235
2236 *******************************************************************************/
2237
2238 static int keyEvent (MfwEvt e, MfwKbd *k)
2239 {
2240
2241 PTRACE( sprintf( buf, "keycode in SOUND keyEvt %d", (int) k->code ); )
2242 PTRACE( sprintf( buf, "mfwEvt in SOUND 0x%10x", e ); )
2243
2244 return MFW_EVENT_CONSUMED;
2245 }
2246
2247 /*******************************************************************************
2248
2249 $Function: stepVibrator
2250
2251 $Description: Changes the state of the vibrator from vibrating to
2252 not vibrating and then restarts the vibration timer
2253
2254 $Returns: None
2255
2256 $Arguments: None
2257
2258 *******************************************************************************/
2259
2260 static void stepVibrator( void )
2261 {
2262 TRACE_FUNCTION("Vibrator Ringing");
2263
2264 }
2265
2266 /*******************************************************************************
2267
2268 $Function: ringVibrator
2269
2270 $Description: generates the ringing vibrations as configured
2271
2272 $Returns: New setting of the vibrator counter
2273
2274 $Arguments: c, pointer to a vibrator counter
2275
2276 *******************************************************************************/
2277
2278 static int ringVibrator( UBYTE *c )
2279 {
2280 return 0;
2281 }
2282
2283
2284 /*******************************************************************************
2285
2286 $Function: VibratorTimerEvent
2287
2288 $Description: Vibrator timer event
2289
2290 $Returns: Event consumed, always
2291
2292 $Arguments: e, event, t, timer
2293
2294 *******************************************************************************/
2295
2296 static int VibratorTimerEvent ( MfwEvt e, MfwTim *t )
2297 {
2298
2299 return MFW_EVENT_CONSUMED;
2300 }
2301
2302 /*******************************************************************************
2303
2304 $Function: volumeSettingTimeOut
2305
2306 $Description: The Ringer volume settings time out has occured and used has not selected
2307 a volume setting.
2308
2309 $Returns: MFW_EVENT_CONSUMED always
2310
2311 $Arguments: e, event, tc timer context
2312
2313 *******************************************************************************/
2314 static int volumeSettingTimeOut( MfwEvt e, MfwTim *tc )
2315 {
2316 T_MFW_HND win = mfw_parent(mfw_header());
2317 T_MFW_WIN * win_data = ((T_MFW_HDR *)win)->data;
2318 T_idle * idle_data = (T_idle *)win_data->user;
2319
2320 TRACE_EVENT(">>>> volumeSettingTimeOut(), Vol Setiing Time out. ");
2321
2322 // stop running timer.
2323 if (hRingerVolSettingTimeOut != NULL ) {
2324 timStop(hRingerVolSettingTimeOut);
2325 }
2326 //When the timer times out, stop the song and the timer.
2327 #ifdef FF_MIDI_RINGER //Use Midi Player
2328 if(soundReason==SettingVolume)
2329 {
2330 // Are we playing a tune
2331 if ( hPlayerStartTimer!= NULL )
2332 timStop( hPlayerStartTimer );
2333 mfw_player_stop(sounds_midi_player_stop_cb);
2334 }
2335 #endif
2336
2337 if(call_data.win_menu !=NULL && (call_data.call_direction == MFW_CM_MTC))
2338 {
2339 bookMenuDestroy(call_data.win_menu);
2340 /*
2341 If volume settings dialog timed out while in the incoming call, allow the
2342 ringer to continue ringing. MZ 9/4/01
2343 */
2344 #ifdef FF_MIDI_RINGER
2345 mfw_ringer_start(AS_RINGER_MODE_IC,true,sounds_midi_ringer_start_cb);
2346 #else
2347 /* Volume Setting for Silent */
2348 startPlayingMelody(getCurrentRingerSettings());
2349 #endif
2350
2351
2352 }
2353 else if (idle_data->info_win != NULL )
2354 {
2355 bookMenuDestroy(idle_data->info_win);
2356 }
2357
2358 return MFW_EVENT_CONSUMED;
2359 }
2360
2361 /*******************************************************************************
2362
2363 Public Methods
2364
2365 *******************************************************************************/
2366 /* RAVI - 20-1-2006 */
2367 #ifdef NEPTUNE_BOARD
2368 /* ===========================================================*/
2369 /**
2370 * restorePreviousVolumeSetting () will restore the previous volume setting once the menu has
2371 * been scrolled.
2372 *
2373 * @param None.
2374 *
2375 * @return None
2376 *
2377 * @see
2378 */
2379 /* =========================================================== */
2380
2381 void restorePreviousVolumeSetting()
2382 {
2383 current.volumeSetting = lastVolumeSetting;
2384 }
2385
2386 /* ===========================================================*/
2387 /**
2388 * volumeMenuScrollUp () when menu button is moved up then this function will get called which
2389 * decrements value for the global variable used to maintain the volume setting while scrolling
2390 * through the menu.
2391 *
2392 * @param None.
2393 *
2394 * @return None
2395 *
2396 * @see
2397 */
2398 /* =========================================================== */
2399 void volumeMenuScrollUp ()
2400 {
2401 /* Decrement Volume setting when scroll up */
2402 scrollVolumeSetting = scrollVolumeSetting - 1 ;
2403
2404 if (scrollVolumeSetting < SILENT_SETTING)
2405 {
2406 scrollVolumeSetting = MAX_VOLUME_SETTING;
2407 }
2408
2409 /* current.volumeSetting = scrollVolumeSetting; */
2410 vsi_t_sleep(0,20);
2411 }
2412
2413
2414 /* ===========================================================*/
2415 /**
2416 * volumeMenuScrollDown () when menu button is moved down then this function will get called which
2417 * increments value for the global variable used to maintain the volume setting while scrolling
2418 * through the menu.
2419 *
2420 * @param None.
2421 *
2422 * @return None
2423 *
2424 * @see
2425 */
2426 /* =========================================================== */
2427 void volumeMenuScrollDown ()
2428 {
2429 /* Increment Volume setting when scroll down */
2430 scrollVolumeSetting = scrollVolumeSetting + 1;
2431
2432 if (scrollVolumeSetting > MAX_VOLUME_SETTING)
2433 {
2434 scrollVolumeSetting = SILENT_SETTING;
2435 }
2436
2437 /* current.volumeSetting = scrollVolumeSetting; */
2438 vsi_t_sleep(0,20);
2439 }
2440
2441 /* ===========================================================*/
2442 /**
2443 * volumeMenuStartPlaying () Will start playing the default melody with the specified volume
2444 * control.
2445 *
2446 * @param None.
2447 *
2448 * @return None
2449 *
2450 * @see
2451 */
2452 /* =========================================================== */
2453 void volumeMenuStartPlaying()
2454 {
2455 if(soundReason == SettingVolume)
2456 {
2457 stopPlayingMelody ();
2458 startPlayingMelody(current.ringer); /* Play the first menu item which is being selected */
2459 }
2460 }
2461
2462 /* ===========================================================*/
2463 /**
2464 * volumeMenuStopPlaying () Will stop playing the default melody with the specified volume
2465 * control.
2466 *
2467 * @param None.
2468 *
2469 * @return None
2470 *
2471 * @see
2472 */
2473 /* =========================================================== */
2474 void volumeMenuStopPlaying()
2475 {
2476 if(soundReason == SettingVolume)
2477 {
2478 stopPlayingMelody ();
2479 }
2480 }
2481 #endif
2482 /* END RAVI */
2483
2484 /*******************************************************************************
2485
2486 $Function: restartVolSettingInactivityTimer
2487
2488 $Description: Restart the Volume settings timer.
2489
2490 $Returns: none
2491
2492 $Arguments: none
2493
2494 *******************************************************************************/
2495 void restartVolSettingInactivityTimer(void)
2496 {
2497 if ( hRingerVolSettingTimeOut != NULL )
2498 timStop( hRingerVolSettingTimeOut );
2499
2500 timStart(hRingerVolSettingTimeOut);
2501
2502 }
2503 /*******************************************************************************
2504
2505 $Function: stopRingerVolTimeOut
2506
2507 $Description: Stop the ringer volume settings timer.
2508
2509 $Returns: none
2510
2511 $Arguments: none
2512
2513 *******************************************************************************/
2514 void stopRingerVolSettingInactivityTimer(void)
2515 {
2516
2517 if ( hRingerVolSettingTimeOut != NULL )
2518 timStop( hRingerVolSettingTimeOut );
2519 //Apr 05, 2005 REF: ENH 29994 xdeepadh
2520 #ifdef FF_MIDI_RINGER //Use Midi Player
2521 //Stop the Timer and stop the song before timeout
2522 if ( hPlayerStartTimer!= NULL )
2523 timStop( hPlayerStartTimer );
2524 mfw_player_stop(sounds_midi_player_stop_cb);
2525 #endif
2526 }
2527 /*******************************************************************************
2528
2529 $Function: startRingerVolumeSettingTimer
2530
2531 $Description: Create and start the ringer voulme inactivity timer.
2532
2533 $Returns: none
2534
2535 $Arguments: none
2536
2537 *******************************************************************************/
2538 void startRingerVolSettingInactivityTimer(T_MFW_HND parent_win)
2539 {
2540 T_MFW_HND win = mfw_parent(mfw_header());
2541 T_MFW_WIN * win_data = ((T_MFW_HDR *)win)->data;
2542 T_idle * idle_data = (T_idle *)win_data->user;
2543
2544 TRACE_FUNCTION(">>>> startRingerVolSettingInactivityTime, Create and Start Vol timer ");
2545 //Create 4 second ringer delay timer.
2546 if(hRingerVolSettingTimeOut == NULL )
2547 {
2548 if(call_data.call_direction == MFW_CM_MTC)
2549 {
2550 /* RAVI - 20-1-2006 */
2551 #ifdef NEPTUNE_BOARD
2552 ; /* do nothing */
2553 #else
2554 hRingerVolSettingTimeOut = timCreate(call_data.win, TIM4SECOND, (MfwCb)volumeSettingTimeOut);
2555 #endif
2556 /* END RAVI */
2557 }
2558 else
2559 {
2560 /* RAVI - 20-1-2006 */
2561 #ifdef NEPTUNE_BOARD
2562 ; /* do nothing */
2563 #else
2564 hRingerVolSettingTimeOut = timCreate(idle_data->win, TIM4SECOND, (MfwCb)volumeSettingTimeOut);
2565 #endif
2566 /* END RAVI */
2567 }
2568 }
2569
2570 if ( hRingerVolSettingTimeOut != NULL )
2571 timStop( hRingerVolSettingTimeOut );
2572
2573 #ifdef NEPTUNE_BOARD
2574 /* RAVI - 20-1-2006 */
2575 /* Initialize the scrolling variable - When volume menu is activated */
2576 scrollVolumeSetting = 0;
2577 lastVolumeSetting = current.volumeSetting;
2578 #endif
2579
2580
2581 #ifndef NEPTUNE_BOARD
2582 timStart(hRingerVolSettingTimeOut);
2583 #endif
2584 /* END RAVI */
2585
2586
2587 }
2588 /*******************************************************************************
2589
2590 $Function: soundsRinger
2591
2592 $Description: prepares Ringer setting screen
2593
2594 $Returns: MFW_EVENT_CONSUMED always
2595
2596 $Arguments: m, menu, i, item
2597
2598 *******************************************************************************/
2599
2600 int soundsRinger( MfwMnu *m, MfwMnuItem *i )
2601 {
2602 T_MFW_HND win;
2603 T_MFW_HND parent_win = mfw_parent(mfw_header());
2604 /*Apr 05, 2005 REF: ENH 29994 xdeepadh */
2605 #ifdef FF_MIDI_RINGER
2606 int numberOfMelodies=0;
2607 T_DISPLAY_DATA DisplayInfo;
2608
2609 TRACE_EVENT("soundsRinger");
2610 if(IsMidiInit==0)
2611 {
2612 TRACE_EVENT("populating files");
2613 sounds_midi_init();
2614 IsMidiInit = 1;
2615 }
2616
2617 numberOfMelodies = sounds_midi_return_file_number();
2618 TRACE_EVENT_P1("numberOfMelodies is %d",numberOfMelodies);
2619
2620 if(numberOfMelodies <= 0)
2621 {
2622 sounds_show_info(0, TxtMidiFileNotLoaded, TxtNull, NULL);
2623 return MFW_EVENT_CONSUMED;
2624 }
2625 else
2626 {
2627 //Set the voice limit to 32 and channel to stereo in idle mode
2628 //Set the audiopath to speaker.
2629 mfw_ringer_set_audiopath();
2630 mfw_player_midi_set_params(FF_MIDI_VOICE_LIMIT,MIDI_CHANNEL_STEREO);
2631 //Nov 02, 2005 REF:ER OMAPS00039044 xdeepadh
2632 //Set the Mp3 Parameters .Size of the file where the melody must start is set 0(from beginning)
2633 //and channel is set to stereo.
2634 #ifdef FF_MP3_RINGER
2635 mfw_player_mp3_set_params(MP3_PLAY_FROM_START,MP3_CHANNEL_STEREO);
2636 #endif //FF_MP3_RINGER
2637
2638 //Nov 21, 2005 REF:ER OMAPS00057430 nekkareb
2639 //Set the AAC Parameters .Size of the file where the melody must start is set 0(from beginning)
2640 //and channel is set to stereo.
2641 #ifdef FF_AAC_RINGER
2642 mfw_player_aac_set_params(AAC_PLAY_FROM_START,AAC_CHANNEL_STEREO);
2643 #endif //FF_AAC_RINGER
2644
2645
2646 hPlayerStartTimer = timCreate( 0, TIMHALFSECOND, (MfwCb)playCurrentMelody);
2647 win = buildMelodyMenu(parent_win);
2648
2649 if (win NEQ NULL)
2650 {
2651 SEND_EVENT (win, E_INIT, 0, 0);
2652 }
2653 return MFW_EVENT_CONSUMED;
2654 }
2655 #else
2656 /*recources_Init (win);*/
2657
2658 /* Timer not requried for Neptune - RAVI 23-12-2005 */
2659 #ifndef NEPTUNE_BOARD
2660 /* Create 0.5 second ringer delay timer. */
2661 hRingerStartTimer = timCreate( 0, TIMHALFSECOND, (MfwCb)playCurrentSound);
2662 #endif
2663 /* END ADD BY RAVI - 23-12-2005 */
2664
2665 win = buildMelodyMenu(parent_win);
2666
2667 if (win NEQ NULL)
2668 {
2669 SEND_EVENT (win, E_INIT, 0, 0);
2670 }
2671
2672 /* For Neptune Not Required - RAVI - 23-12-2005 */
2673 #ifndef NEPTUNE_BOARD
2674 /* Start the 0.5 second ringer delay timer. */
2675 delayThenPlayMelody();
2676 #endif
2677 /* END ADD BY RAVI - 23-12-2005 */
2678
2679 return MFW_EVENT_CONSUMED;
2680 #endif
2681 }
2682
2683
2684 /*******************************************************************************
2685
2686 $Function: soundsVolume
2687
2688 $Description: prepares Volume setting screen
2689
2690 $Returns: MFW_EVENT_CONSUMED always
2691
2692 $Arguments: m, menu, i, item
2693
2694 *******************************************************************************/
2695
2696 int soundsVolume( MfwMnu *m, MfwMnuItem *i )
2697 {
2698
2699 return MFW_EVENT_CONSUMED;
2700 }
2701
2702
2703 /*******************************************************************************
2704
2705 $Function: settingsVibrator
2706
2707 $Description: prepares Vibrator settings screen
2708
2709 $Returns: MFW_EVENT_CONSUMED always
2710
2711 $Arguments: m, menu, i, item
2712
2713 *******************************************************************************/
2714
2715 int settingsVibrator( MfwMnu *m, MfwMnuItem *i )
2716 {
2717
2718 return MFW_EVENT_CONSUMED;
2719 }
2720 /*******************************************************************************
2721
2722 $Function: settingsLanguages
2723
2724 $Description: prepares languages screen
2725
2726 $Returns: MFW_EVENT_CONSUMED always
2727
2728 $Arguments: m, menu, i, item
2729
2730 *******************************************************************************/
2731
2732 int settingsLanguages( MfwMnu *m, MfwMnuItem *i )
2733 {
2734 return MFW_EVENT_CONSUMED;
2735 }
2736
2737 /*******************************************************************************
2738
2739 $Function: soundsNewMessage
2740
2741 $Description: prepares NewMessage setting screen
2742
2743 $Returns: MFW_EVENT_CONSUMED always
2744
2745 $Arguments: m, menu, i, item
2746
2747 *******************************************************************************/
2748
2749 int soundsNewMessage( MfwMnu *m, MfwMnuItem *i )
2750 {
2751
2752 return MFW_EVENT_CONSUMED;
2753 }
2754
2755 /*******************************************************************************
2756
2757 $Function: soundsNewBroadcast
2758
2759 $Description: prepares Broadcast setting screen
2760
2761 $Returns: MFW_EVENT_CONSUMED always
2762
2763 $Arguments: m, menu, i, item
2764
2765 *******************************************************************************/
2766
2767 int soundsNewBroadcast( MfwMnu *m, MfwMnuItem *i )
2768 {
2769
2770 return MFW_EVENT_CONSUMED;
2771 }
2772
2773 /*******************************************************************************
2774
2775 $Function: soundsBatteryLow
2776
2777 $Description: prepares BatteryLow setting screen
2778
2779 $Returns: MFW_EVENT_CONSUMED always
2780
2781 $Arguments: m, menu, i, item
2782
2783 *******************************************************************************/
2784
2785 int soundsBatteryLow( MfwMnu *m, MfwMnuItem *i )
2786 {
2787
2788 return MFW_EVENT_CONSUMED;
2789 }
2790
2791
2792 /*******************************************************************************
2793
2794 $Function: soundsCreditLow
2795
2796 $Description: prepares Credit setting screen
2797
2798 $Returns: MFW_EVENT_CONSUMED always
2799
2800 $Arguments: m, menu, i, item
2801
2802 *******************************************************************************/
2803
2804 int soundsCreditLow( MfwMnu *m, MfwMnuItem *i )
2805 {
2806
2807 return MFW_EVENT_CONSUMED;
2808 }
2809 /*******************************************************************************
2810
2811 $Function: soundsOrganiser
2812
2813 $Description: prepares Organiser setting screen
2814
2815 $Returns: MFW_EVENT_CONSUMED always
2816
2817 $Arguments: m, menu, i, item
2818
2819 *******************************************************************************/
2820
2821 int soundsOrganiser( MfwMnu *m, MfwMnuItem *i )
2822 {
2823
2824 return MFW_EVENT_CONSUMED;
2825 }
2826
2827 /*******************************************************************************
2828
2829 $Function: soundsAlarm
2830
2831 $Description: prepares Alarm setting screen
2832
2833 $Returns: MFW_EVENT_CONSUMED always
2834
2835 $Arguments: m, menu, i, item
2836
2837 *******************************************************************************/
2838
2839 int soundsAlarm( MfwMnu *m, MfwMnuItem *i )
2840 {
2841
2842 return MFW_EVENT_CONSUMED;
2843 }
2844
2845
2846 /*******************************************************************************
2847
2848 $Function: soundInit
2849
2850 $Description: init sounds handling
2851
2852 $Returns: None
2853
2854 $Arguments: parent, handle of parent window
2855
2856 *******************************************************************************/
2857
2858 void soundInit( MfwHnd parent )
2859 {
2860
2861
2862 }
2863
2864
2865 /*******************************************************************************
2866
2867 $Function: soundExit
2868
2869 $Description: exit sounds handling
2870
2871 $Returns: None
2872
2873 $Arguments: None
2874
2875 *******************************************************************************/
2876
2877 void soundExit (void)
2878 {
2879
2880 }
2881
2882
2883 /*******************************************************************************
2884
2885 $Function: soundExec
2886
2887 $Description: sends messages to soundExec to get the various melodies to play
2888
2889 $Returns: None
2890
2891 $Arguments: reason, for invocation, next, state
2892
2893 *******************************************************************************/
2894
2895 void soundExec (int reason, MmiState next)
2896
2897 {
2898
2899 }
2900
2901
2902 /*******************************************************************************
2903
2904 $Function: soundsKeypadSilent
2905
2906 $Description: prepares KeypadTones setting screen
2907
2908 $Returns: MFW_EVENT_CONSUMED always
2909
2910 $Arguments: m, menu, i, item
2911
2912 *******************************************************************************/
2913
2914 int soundsKeypadSilent(MfwMnu* m, MfwMnuItem* i)
2915 {
2916
2917 T_MFW_HND win = mfw_parent(mfw_header());
2918
2919 sounds_Init(win);
2920
2921 if (FFS_flashData.settings_status & SettingsKeypadClick)
2922 {
2923 FFS_flashData.settings_status &= ~SettingsKeypadClick;
2924 }
2925 else if (FFS_flashData.settings_status & SettingsKeypadDTMF)
2926 {
2927 FFS_flashData.settings_status &= ~SettingsKeypadDTMF;
2928 }
2929 flash_write();
2930 sounds_data.local_status = ACTIVATE_CONFIRM;
2931
2932 SEND_EVENT (sounds_data.sounds_win, SHOW_CONFIRM, 0, 0);
2933
2934 return 0;
2935 }
2936 /*******************************************************************************
2937
2938 $Function: soundsKeypadClick
2939
2940 $Description: prepares KeypadTones setting screen
2941
2942 $Returns: MFW_EVENT_CONSUMED always
2943
2944 $Arguments: m, menu, i, item
2945
2946 *******************************************************************************/
2947 int soundsKeypadClick(MfwMnu* m, MfwMnuItem* i)
2948 {
2949
2950 T_MFW_HND win = mfw_parent(mfw_header());
2951
2952 sounds_Init(win);
2953
2954
2955
2956 if (FFS_flashData.settings_status & SettingsKeypadDTMF)
2957 {
2958 FFS_flashData.settings_status &= ~SettingsKeypadDTMF;
2959 }
2960
2961 FFS_flashData.settings_status |= SettingsKeypadClick;
2962
2963 /* RAVI - 20-1-2006 */
2964 /* play KeypadClick */
2965 #ifdef NEPTUNE_BOARD
2966 audio_PlaySoundID(0, TONES_KEYBEEP, current.volumeSetting, AUDIO_PLAY_ONCE);
2967 #else
2968 audio_PlaySoundID(0, TONES_KEYBEEP, 5, AUDIO_PLAY_ONCE ); /* GW#2355 /CQ11341 */
2969 #endif
2970 /* END RAVI */
2971
2972 sounds_data.local_status = ACTIVATE_CONFIRM;
2973
2974 SEND_EVENT (sounds_data.sounds_win, SHOW_CONFIRM, 0, 0);
2975 flash_write();
2976 return 0;
2977 }
2978
2979 /*******************************************************************************
2980
2981 $Function: soundsKeypadDTMF
2982
2983 $Description: prepares KeypadTones setting screen
2984
2985 $Returns: MFW_EVENT_CONSUMED always
2986
2987 $Arguments: m, menu, i, item
2988
2989 *******************************************************************************/
2990 int soundsKeypadDTMF(MfwMnu* m, MfwMnuItem* i)
2991 {
2992
2993 T_MFW_HND win = mfw_parent(mfw_header());
2994
2995 sounds_Init(win);
2996
2997 if (FFS_flashData.settings_status & SettingsKeypadClick)
2998 {
2999 FFS_flashData.settings_status &= ~SettingsKeypadClick;
3000 }
3001
3002
3003
3004 FFS_flashData.settings_status |= SettingsKeypadDTMF;
3005 flash_write();
3006
3007 sounds_data.local_status = ACTIVATE_CONFIRM;
3008
3009 SEND_EVENT (sounds_data.sounds_win, SHOW_CONFIRM, 0, 0);
3010
3011 return 0;
3012 }
3013
3014
3015
3016 /*******************************************************************************
3017
3018 $Function: sounds_Init
3019
3020 $Description:
3021
3022 $Returns:
3023
3024 $Arguments:
3025
3026 *******************************************************************************/
3027 T_MFW_HND sounds_Init (T_MFW_HND parent_window)
3028 {
3029 return (sounds_create (parent_window));
3030 }
3031 /*******************************************************************************
3032
3033 $Function: confirm_Exit
3034
3035 $Description:
3036
3037 $Returns:
3038
3039 $Arguments:
3040
3041 *******************************************************************************/
3042 void sounds_Exit (T_MFW_HND own_window)
3043 {
3044
3045 T_MFW_WIN * win_data = ((T_MFW_HDR *)own_window)->data;
3046 T_MELODY_INFO * data = (T_MELODY_INFO *)win_data->user;
3047
3048 sounds_destroy (data->sounds_win);
3049 }
3050
3051 /*******************************************************************************
3052
3053 $Function: sounds_create
3054
3055 $Description:
3056
3057 $Returns:
3058
3059 $Arguments:
3060
3061 *******************************************************************************/
3062 T_MFW_HND sounds_create (T_MFW_HND parent_window)
3063 {
3064 T_MELODY_INFO * data = &sounds_data;
3065 T_MFW_WIN * win;
3066
3067 TRACE_FUNCTION ("sounds_create()");
3068
3069 data->sounds_win = win_create (parent_window, 0, 0, (T_MFW_CB)sounds_win_cb);
3070
3071 if (data->sounds_win EQ 0)
3072 return 0;
3073
3074 /*
3075 * Create window handler
3076 */
3077 data->mmi_control.dialog = (T_DIALOG_FUNC)sounds;
3078 data->mmi_control.data = data;
3079 win = ((T_MFW_HDR *)data->sounds_win)->data;
3080 win->user = (void *) data;
3081
3082
3083 winShow(data->sounds_win);
3084 /*
3085 * return window handle
3086 */
3087 return data->sounds_win;
3088 }
3089
3090 /*******************************************************************************
3091
3092 $Function: sounds_destroy
3093
3094 $Description:
3095
3096 $Returns:
3097
3098 $Arguments:
3099
3100 *******************************************************************************/
3101 void sounds_destroy (T_MFW_HND own_window)
3102 {
3103 T_MFW_WIN * win;
3104 T_MELODY_INFO * data;
3105
3106 TRACE_FUNCTION ("sounds_destroy()");
3107
3108 if (own_window)
3109 {
3110 win = ((T_MFW_HDR *)own_window)->data;
3111 data = (T_MELODY_INFO *)win->user;
3112
3113 if (data)
3114 {
3115
3116 /*
3117 * Delete WIN handler
3118 */
3119 win_delete (data->sounds_win);
3120 data->sounds_win = 0;
3121 }
3122 }
3123 }
3124 /*******************************************************************************
3125
3126 $Function: sounds_win_cb
3127
3128 $Description:
3129
3130 $Returns:
3131
3132 $Arguments:
3133
3134 *******************************************************************************/
3135 static int sounds_win_cb (T_MFW_EVENT event, T_MFW_WIN * win)
3136 {
3137 /*
3138 * Top Window has no output
3139 */
3140 return 1;
3141 }
3142
3143
3144 /*******************************************************************************
3145
3146 $Function: sounds_dialog
3147
3148 $Description:
3149
3150 $Returns:
3151
3152 $Arguments:
3153
3154 *******************************************************************************/
3155 static void sounds_dialog(void)
3156 {
3157 T_DISPLAY_DATA display_info;
3158
3159 TRACE_FUNCTION ("sounds_dialog()");
3160
3161 dlg_initDisplayData_TextId( &display_info, TxtNull, TxtNull, TxtNull, TxtNull , COLOUR_STATUS);
3162 dlg_initDisplayData_events( &display_info, (T_VOID_FUNC)sounds_dialog_cb, THREE_SECS, KEY_CLEAR | KEY_RIGHT );
3163 if (sounds_data.local_status EQ ACTIVATE_CONFIRM)
3164 {
3165 display_info.TextId = TxtActivated;
3166 }
3167 else
3168 {
3169 display_info.TextId = TxtDeActivated;
3170 }
3171
3172 /*
3173 * Call Info Screen
3174 */
3175 info_dialog (sounds_data.sounds_win, &display_info);
3176
3177 }
3178 /*******************************************************************************
3179
3180 $Function: confirm_dialog_cb
3181
3182 $Description:
3183
3184 $Returns:
3185
3186 $Arguments:
3187
3188 *******************************************************************************/
3189 void sounds_dialog_cb(T_MFW_HND win, UBYTE identifier, UBYTE reason)
3190 {
3191 TRACE_FUNCTION ("sounds_dialog_cb()");
3192
3193 switch (reason)
3194 {
3195 case INFO_TIMEOUT:
3196 /* no break; */
3197 case INFO_KCD_HUP:
3198 /* no break; */
3199 case INFO_KCD_LEFT:
3200 /* no break; */
3201 case INFO_KCD_RIGHT:
3202 /* no break; */
3203 case INFO_KCD_CLEAR:
3204 sounds_Exit(win);
3205 break;
3206 }
3207 }
3208
3209 /*******************************************************************************
3210
3211 $Function: sounds
3212
3213 $Description:
3214
3215 $Returns:
3216
3217 $Arguments:
3218
3219 *******************************************************************************/
3220 void sounds (T_MFW_HND win, USHORT event, SHORT value, void * parameter)
3221 {
3222 // T_MFW_WIN * win_data = ((T_MFW_HDR *) win)->data; // RAVI
3223 // T_MELODY_INFO * data = (T_MELODY_INFO *)win_data->user; // RAVI
3224
3225 TRACE_FUNCTION("sounds()");
3226
3227 switch (event)
3228 {
3229 case SHOW_CONFIRM:
3230 sounds_dialog();
3231 break;
3232 }
3233
3234 }
3235
3236 // Nov 29, 2004 REF: CRR 25051 xkundadu
3237 // Description: INCALL SCREEN – ADJUSTING THE VOLUME
3238 // Fix: Added these functions to set the speaker volume to various levels.
3239
3240 void SetVolumeLevel1(void)
3241 {
3242
3243
3244 FFS_flashData.output_volume = OutVolumeLevel1;
3245 // Set the volume
3246 mmeSetVolume (1, FFS_flashData.output_volume);
3247 //write the value to the FFS
3248 flash_write();
3249
3250 }
3251 void SetVolumeLevel2(void)
3252 {
3253
3254
3255 FFS_flashData.output_volume = OutVolumeLevel2;
3256 // Set the volume
3257 mmeSetVolume (1, FFS_flashData.output_volume);
3258 //write the value to the FFS
3259 flash_write();
3260
3261 }
3262 void SetVolumeLevel3(void)
3263 {
3264
3265
3266 FFS_flashData.output_volume = OutVolumeLevel3;
3267 // Set the volume
3268 mmeSetVolume (1, FFS_flashData.output_volume);
3269 //write the value to the FFS
3270 flash_write();
3271
3272 }
3273 void SetVolumeLevel4(void)
3274 {
3275
3276
3277 FFS_flashData.output_volume = OutVolumeLevel4;
3278 // Set the volume
3279 mmeSetVolume (1, FFS_flashData.output_volume);
3280 //write the value to the FFS
3281 flash_write();
3282
3283 }
3284 void SetVolumeLevel5(void)
3285 {
3286
3287
3288 FFS_flashData.output_volume = OutVolumeLevel5;
3289 // Set the volume
3290 mmeSetVolume (1, FFS_flashData.output_volume);
3291 //write the value to the FFS
3292 flash_write();
3293
3294 }
3295 //Apr 05, 2005 REF: ENH 29994 xdeepadh
3296 #ifdef FF_MIDI_RINGER
3297 /*******************************************************************************
3298
3299 $Function: sounds_midi_init
3300
3301 $Description:Function to initialise the Midi files.
3302
3303 $Returns: None
3304
3305 $Arguments: None
3306
3307 *******************************************************************************/
3308 void sounds_midi_init(void)
3309 {
3310 TRACE_FUNCTION("sounds_init");
3311 #ifdef FF_MIDI_RINGER
3312 #ifdef FF_MIDI_LOAD_FROM_MEM
3313 midi_files_count=MIDI_MAX_FILES;
3314 #else
3315 //Nov 04, 2005 REF:DRT OMAPS00053737 xdeepadh
3316 #ifdef FF_MIDI_LOAD_FROM_LFS
3317 //Populate midi files from LFS
3318 TRACE_EVENT("LFS");
3319 //Load the midi files from FFS into LFS
3320 midi_files_count=sounds_load_lfs_midi_files(MIDI_MAX_FILES);
3321 //Populate the list of midi files from LFS
3322 midi_files_count=sounds_populate_midi_files(midi_file_names,MIDI_MAX_FILES,LFS_CONTENT_DIR);
3323 #else
3324 TRACE_EVENT("FFS");
3325 midi_files_count=sounds_populate_midi_files(midi_file_names,MIDI_MAX_FILES,RINGER_CONTENT_DIR);
3326 #endif //FF_MIDI_LOAD_FROM_LFS
3327 #endif //FF_MIDI_LOAD_FROM_MEM
3328 #endif //FF_MIDI_RINGER
3329 }
3330
3331 /*******************************************************************************
3332
3333 $Function: sounds_midi_exit
3334
3335 $Description:Function to uninitialise the Midi files.
3336
3337 $Returns: None
3338
3339 $Arguments: None
3340
3341 *******************************************************************************/
3342
3343 void sounds_midi_exit(void)
3344 {
3345 TRACE_FUNCTION("sounds_exit");
3346 #ifndef FF_MIDI_LOAD_FROM_MEM
3347 sounds_unpopulate_midi_files(midi_file_names);
3348 IsMidiInit = 0;
3349 #endif
3350 }
3351
3352 /*******************************************************************************
3353
3354 $Function: sounds_populate_midi_files
3355
3356 $Description:Populates the MIDI file names into the array
3357
3358 $Returns: The count of the files in the directory
3359
3360 $Arguments: file_names:Pointer to the arrayto store file names
3361 max_files_count:Max file counts to be stored in array
3362 *******************************************************************************/
3363
3364 int sounds_populate_midi_files(char **file_names, int max_files_count,char* dir_name_p)
3365 {
3366 T_FFS_FD fd = 0;
3367 T_FFS_DIR dir = {0};
3368 char dest_name_p[100] = "";
3369 int i, files_count = 0;
3370 char *fileExt;
3371
3372 TRACE_FUNCTION("sounds_populate_midi_files");
3373
3374 if (ffs_opendir (dir_name_p, &dir) <= 0)
3375 {
3376 files_count = 0;
3377 }
3378
3379 //read the file names
3380 //Nov 02, 2005 REF:ER OMAPS00039044 xdeepadh
3381 //file_count will be used to populate the array index
3382 for (i = 0; ffs_readdir (&dir, dest_name_p, 100) > 0x0; i++)
3383 {
3384 (file_names[files_count]) = (char*)mfwAlloc(strlen(dest_name_p) + 1);
3385 if(file_names[files_count] != NULL)
3386 {
3387 //Jul 20, 2005 REF: SPR 30772 xdeepadh
3388 //Retrieve file extension.Store only the supported file formats in array
3389 fileExt =sounds_midi_GetExtension(dest_name_p);
3390 //Oct 25, 2005 MP3 Ringer xdeepadh
3391 //List the MP3 files also.Mp3 files hsould not be listed or ULC
3392 #ifdef FF_MP3_RINGER
3393 if ( (strcmp(fileExt, "mp3") == 0))
3394 {
3395 strcpy (file_names[files_count], dest_name_p);
3396 files_count++;
3397 }
3398 else
3399 #endif //FF_MP3_RINGER
3400
3401 //Nov 21, 2005 ER: OMAPS00057430, AAC Ringer support nekkareb
3402 //List the AAC files also.
3403 #ifdef FF_AAC_RINGER
3404 if ( (strcmp(fileExt, "aac") == 0))
3405 {
3406 strcpy (file_names[files_count], dest_name_p);
3407 files_count++;
3408 }
3409 else
3410 #endif //FF_AAC_RINGER
3411
3412 //If XMF is supported
3413 #ifdef PAL_ENABLE_XMF
3414 if ( (strcmp(fileExt, "xmf") == 0))
3415 {
3416 strcpy (file_names[files_count], dest_name_p);
3417 files_count++;
3418 }
3419 else
3420 #endif //PAL_ENABLE_XMF
3421
3422 //If IMELODY is supported
3423 #ifdef PAL_ENABLE_IMELODY
3424 if ( (strcmp(fileExt, "imy") == 0))
3425 {
3426 strcpy (file_names[files_count], dest_name_p);
3427 files_count++;
3428 }
3429 else
3430 #endif //PAL_ENABLE_IMELODY
3431
3432 //If SMAF is supported
3433 #ifdef PAL_ENABLE_SMAF_MA3
3434 if ( (strcmp(fileExt, "mmf") == 0))
3435 {
3436 strcpy (file_names[files_count], dest_name_p);
3437 files_count++;
3438 }
3439 else
3440 #endif ////PAL_ENABLE_SMAF_MA3
3441
3442 //If MIDI is supported
3443 #ifdef PAL_ENABLE_MIDI_NORMALIZER
3444 if ( (strcmp(fileExt, "mid") == 0))
3445 {
3446 strcpy (file_names[files_count], dest_name_p);
3447 files_count++;
3448 }
3449 else
3450 #endif ////PAL_ENABLE_MIDI_NORMALIZER
3451 //Sep 12, 2005 REF: SPR 33977 xdeepadh
3452 //mxmf file format has been supported
3453 #ifdef PAL_ENABLE_SMAF_MA3
3454 if ( (strcmp(fileExt, "mxmf") == 0))
3455 {
3456 strcpy (file_names[files_count], dest_name_p);
3457 files_count++;
3458 }
3459 else
3460 #endif //PAL_ENABLE_SMAF_MA3
3461 ;
3462 if(files_count >= max_files_count)
3463 break;
3464 }
3465 else
3466 {
3467 //files_count = 0;
3468 }
3469
3470 }
3471 TRACE_EVENT_P1("read files_count is %d",files_count);
3472 return files_count;
3473 }
3474
3475 //Nov 04, 2005 REF:DRT OMAPS00053737 xdeepadh
3476 #ifdef FF_MIDI_LOAD_FROM_LFS
3477 /*******************************************************************************
3478
3479 $Function: sounds_load_lfs_midi_files
3480
3481 $Description: Loads the midi files from FFS to LFS.
3482 This function should be used as a patch to load the lfs files.
3483 This function should be used only in the absence of ETM.
3484 $Returns: None
3485 $Arguments: max_files_count:Max file counts to be stored in array
3486
3487 *******************************************************************************/
3488 int sounds_load_lfs_midi_files( int max_files_count)
3489 {
3490 char dir_name_p[] = RINGER_CONTENT_DIR;
3491 T_FFS_DIR dir = {0};
3492 char dest_name_p[100] = "";
3493 char dest_full_path[100] = "";
3494 int i, files_count = 0;
3495 char *fileExt;
3496 T_RAM_FILE* ram_file = NULL;
3497
3498 TRACE_FUNCTION("sounds_load_lfs_midi_files");
3499
3500 if (ffs_opendir (dir_name_p, &dir) <= 0)
3501 {
3502 TRACE_EVENT( "FFS open dir failure: OK");
3503
3504 }
3505
3506 //read the file names
3507 for (i = 0; ffs_readdir (&dir, dest_name_p, 100) > 0x0; i++)
3508 {
3509 TRACE_EVENT_P1( "dest name is %s",dest_name_p);
3510 if(dest_name_p != NULL)
3511 {
3512 //Jul 20, 2005 REF: SPR 30772 xdeepadh
3513 //Retrieve file extension.Store only the supported file formats in array
3514 fileExt =sounds_midi_GetExtension(dest_name_p);
3515 //If XMF is supported
3516 #ifdef PAL_ENABLE_XMF
3517 if ( (strcmp(fileExt, "xmf") == 0))
3518 {
3519 strcpy(dest_full_path,RINGER_CONTENT_DIR);
3520 strcat(dest_full_path,"/");
3521 strcat(dest_full_path,dest_name_p);
3522 ram_file = ram_load_file(dest_full_path);
3523 if (0 != ram_write_lfs(ram_file,dest_name_p))
3524 {
3525 TRACE_EVENT( "LFS write failure: OK");
3526 }
3527
3528 }
3529 else
3530 #endif //PAL_ENABLE_XMF
3531
3532 //If IMELODY is supported
3533 #ifdef PAL_ENABLE_IMELODY
3534 if ( (strcmp(fileExt, "imy") == 0))
3535 {
3536
3537 strcpy(dest_full_path,RINGER_CONTENT_DIR);
3538 strcat(dest_full_path,"/");
3539 strcat(dest_full_path,dest_name_p);
3540 ram_file = ram_load_file(dest_full_path);
3541 if (0 != ram_write_lfs(ram_file,dest_name_p))
3542 {
3543 TRACE_EVENT( "LFS write failure: OK");
3544 }
3545
3546 }
3547 else
3548 #endif //PAL_ENABLE_IMELODY
3549
3550 //If SMAF is supported
3551 #ifdef PAL_ENABLE_SMAF_MA3
3552 if ( (strcmp(fileExt, "mmf") == 0))
3553 {
3554
3555 strcpy(dest_full_path,RINGER_CONTENT_DIR);
3556 strcat(dest_full_path,"/");
3557 strcat(dest_full_path,dest_name_p);
3558 ram_file = ram_load_file(dest_full_path);
3559 if (0 != ram_write_lfs(ram_file,dest_name_p))
3560 {
3561 TRACE_EVENT( "LFS write failure: OK");
3562 }
3563 files_count++;
3564 }
3565 else
3566 #endif ////PAL_ENABLE_SMAF_MA3
3567
3568 //If MIDI is supported
3569 #ifdef PAL_ENABLE_MIDI_NORMALIZER
3570 if ( (strcmp(fileExt, "mid") == 0))
3571 {
3572 strcpy(dest_full_path,RINGER_CONTENT_DIR);
3573 strcat(dest_full_path,"/");
3574 strcat(dest_full_path,dest_name_p);
3575 ram_file = ram_load_file(dest_full_path);
3576 if (0 != ram_write_lfs(ram_file,dest_name_p))
3577 {
3578 TRACE_EVENT( "LFS write failure: OK");
3579 }
3580 files_count++;
3581 }
3582 else
3583 #endif ////PAL_ENABLE_MIDI_NORMALIZER
3584 //Sep 12, 2005 REF: SPR 33977 xdeepadh
3585 //mxmf file format has been supported
3586 #ifdef PAL_ENABLE_SMAF_MA3
3587 if ( (strcmp(fileExt, "mxmf") == 0))
3588 {
3589
3590 strcpy(dest_full_path,RINGER_CONTENT_DIR);
3591 strcat(dest_full_path,"/");
3592 strcat(dest_full_path,dest_name_p);
3593 ram_file = ram_load_file(dest_full_path);
3594 if (0 != ram_write_lfs(ram_file,dest_name_p))
3595 {
3596 TRACE_EVENT( "LFS write failure: OK");
3597 }
3598 files_count++;
3599 }
3600 else
3601 #endif //PAL_ENABLE_SMAF_MA3
3602 ;
3603 if(files_count >= max_files_count)
3604 break;
3605 }
3606 else
3607 {
3608 //files_count = 0;
3609 }
3610
3611 }
3612 TRACE_EVENT_P1("read files_count is %d",files_count);
3613 return files_count;
3614 }
3615 #endif //FF_MIDI_LOAD_FROM_LFS
3616 /*******************************************************************************
3617
3618 $Function: sounds_unpopulate_midi_files
3619
3620 $Description:Frees the memory allocated for the array
3621 $Returns: None
3622
3623 $Arguments: file_names:Pointer to the arrayto store file names
3624
3625 *******************************************************************************/
3626 void sounds_unpopulate_midi_files(char **file_names)
3627 {
3628 T_FFS_FD fd = 0;
3629 char dir_name_p[] = RINGER_CONTENT_DIR;
3630 T_FFS_DIR dir = {0};
3631 char dest_name_p[100] = "";
3632 int i,files_count=0;
3633 TRACE_FUNCTION("sounds_populate_midi_files");
3634
3635 if (ffs_opendir (dir_name_p, &dir) <= 0)
3636 {
3637 files_count = 0;
3638
3639 }
3640
3641 for (i = 0; ffs_readdir (&dir, dest_name_p, 100) > 0x0; i++)
3642 {
3643 mfwFree((U8 *)file_names[i],(U16)strlen(dest_name_p) + 1);
3644
3645 }
3646
3647 }
3648
3649 /*******************************************************************************
3650
3651 $Function: sounds_midi_return_file_number
3652
3653 $Description: returns the file count
3654
3655 $Returns: Count of the Midi files
3656
3657 $Arguments: None
3658
3659 *******************************************************************************/
3660 int sounds_midi_return_file_number(void)
3661 {
3662 TRACE_FUNCTION("sounds_midi_return_file_number");
3663
3664 if(midi_files_count<=0)
3665 return 0;
3666 else
3667 return midi_files_count;
3668
3669 }
3670 /*******************************************************************************
3671
3672 $Function: sounds_midi_return_file_name
3673
3674 $Description: Returns the file name
3675
3676 $Returns: Name of the file
3677
3678 $Arguments: index:The index of the file, whose name has to be retrieved
3679
3680 *******************************************************************************/
3681
3682 char* sounds_midi_return_file_name(UBYTE index)
3683 {
3684
3685 TRACE_FUNCTION("sounds_midi_return_file_name");
3686
3687 #ifdef FF_MIDI_LOAD_FROM_MEM
3688 return (char *)mmi_midi_files[index].melody_name;
3689 #else
3690 TRACE_EVENT_P2("midi_file_names[%d] is %s",index,(char *)midi_file_names[index]);
3691 return (char *) midi_file_names[index];
3692 #endif
3693
3694
3695 }
3696
3697 /*******************************************************************************
3698
3699 $Function: sounds_midi_ringer_start_cb
3700
3701 $Description: Callback function for ringer_start
3702
3703 $Returns: None
3704
3705 $Arguments:
3706
3707 *******************************************************************************/
3708
3709 void sounds_midi_ringer_start_cb(void *parameter)
3710 {
3711 TRACE_EVENT("sounds_midi_ringer_start_cb");
3712
3713 if (((T_AS_STOP_IND *)parameter)->header.msg_id == AS_STOP_IND )
3714 {
3715 // Aug 05, 2005 xdeepadh
3716 #ifdef FF_MMI_AUDIO_PROFILE
3717 //configure the audio to voice path.
3718 mfwAudPlay = FALSE;
3719 mfw_unset_stereo_path(mfw_get_current_audioDevice());
3720 #endif
3721 }
3722
3723 }
3724
3725 /*******************************************************************************
3726
3727 $Function: sounds_midi_ringer_stop_cb
3728
3729 $Description: Callback function for ringer_stop
3730
3731 $Returns: None
3732
3733 $Arguments:
3734
3735 *******************************************************************************/
3736
3737 void sounds_midi_ringer_stop_cb(void *parameter)
3738 {
3739
3740 TRACE_EVENT("sounds_midi_ringer_stop_cb");
3741 // Aug 05, 2005 xdeepadh
3742 #ifdef FF_MMI_AUDIO_PROFILE
3743 //configure the audio to voice path
3744 mfwAudPlay = FALSE;
3745 mfw_unset_stereo_path(mfw_get_current_audioDevice());
3746 #endif
3747 }
3748
3749 /*******************************************************************************
3750
3751 $Function: sounds_midi_player_start_cb
3752
3753 $Description: Callback function for player_start
3754
3755 $Returns: None
3756
3757 $Arguments:
3758
3759 *******************************************************************************/
3760
3761 void sounds_midi_player_start_cb(void *parameter)
3762 {
3763
3764 #ifdef FF_MMI_TEST_MIDI
3765 T_AS_PLAYER_TYPE player_type;
3766 #if FF_MIDI_LOAD_FROM_MEM
3767 T_MELODY melody_data;
3768 #else
3769 char* midi_file;
3770 #endif
3771 TRACE_EVENT("sounds_midi_player_start_cb");
3772 if (((T_AS_STOP_IND *)parameter)->header.msg_id == AS_STOP_IND )
3773 {
3774 if(mfw_player_exit_flag == PLAYER_EXIT_FLAG_FALSE)
3775 {
3776
3777 //if we didn't reach the last file
3778 if(mfw_player_currently_playing_idx<(midi_files_count-1))
3779 {
3780 mfw_player_currently_playing_idx++;
3781 TRACE_EVENT_P1("mfw_player_currently_playing_idx is %d",mfw_player_currently_playing_idx);
3782 mfw_player_save_selected_file_idx(mfw_player_currently_playing_idx);
3783 #ifdef FF_MIDI_RINGER
3784 #ifdef FF_MIDI_LOAD_FROM_MEM
3785 melody_data=sounds_midi_return_memory_location(mfw_player_currently_playing_idx);
3786 player_type=mfw_ringer_deduce_player_type(melody_data.melody_name);
3787 mfw_player_start_memory(player_type,(UINT32*)melody_data.melody,melody_data.melody_size,(UBYTE)AS_VOLUME_HIGH,FALSE,sounds_midi_player_start_cb);
3788 #else
3789 midi_file=sounds_midi_return_file_name(mfw_player_currently_playing_idx);
3790 player_type=mfw_ringer_deduce_player_type(midi_file);
3791 mfw_player_start_file(player_type,midi_file,(UBYTE)AS_VOLUME_HIGH,FALSE,sounds_midi_player_start_cb);
3792 #endif
3793 #endif
3794 }
3795 else
3796 {
3797 //flag set to 1 means we only play the currently selected file
3798 mfw_player_exit_flag = PLAYER_EXIT_FLAG_TRUE;
3799 // Aug 05, 2005 xdeepadh
3800 #ifdef FF_MMI_AUDIO_PROFILE
3801 //configure the audio to voice path
3802 mfwAudPlay = FALSE;
3803 mfw_unset_stereo_path(mfw_get_current_audioDevice());
3804 #endif
3805 }
3806 }
3807
3808 }
3809 #endif//#ifdef FF_MMI_TEST_MIDI
3810 }
3811
3812 /*******************************************************************************
3813
3814 $Function: sounds_midi_player_stop_cb
3815
3816 $Description: Callback function for player_stop
3817
3818 $Returns: None
3819
3820 $Arguments:
3821
3822 *******************************************************************************/
3823
3824 void sounds_midi_player_stop_cb(void *parameter)
3825 {
3826 TRACE_EVENT("sounds_midi_player_stop_cb");
3827 // Aug 05, 2005 xdeepadh
3828 #ifdef FF_MMI_AUDIO_PROFILE
3829 //configure the audio to voice path
3830 mfwAudPlay = FALSE;
3831 mfw_unset_stereo_path(mfw_get_current_audioDevice());
3832 #endif
3833 }
3834
3835
3836 /*******************************************************************************
3837
3838 $Function: sounds_show_info
3839
3840 $Description:Displays a dialog
3841
3842 $Returns:
3843
3844 $Arguments:
3845 *******************************************************************************/
3846 static MfwHnd sounds_show_info(T_MFW_HND parent, int str1, int str2, T_VOID_FUNC callback)
3847 {
3848 T_DISPLAY_DATA display_info;
3849 TRACE_FUNCTION ("sounds_show_info()");
3850
3851 /*
3852 ** Create a timed dialog to display the Message "Failed"
3853 */
3854 dlg_initDisplayData_TextId( &display_info, TxtNull, TxtNull, str1, str2, COLOUR_STATUS);
3855 dlg_initDisplayData_events( &display_info, callback, MT_INFO_SCRN_TIMEOUT, KEY_LEFT | KEY_CLEAR | KEY_HUP);
3856 return info_dialog(parent, &display_info);
3857 }
3858
3859
3860 /*******************************************************************************
3861
3862 $Function: get_ringer_mode
3863
3864 $Description: Returns the current ringer mode based on soundsreason (CALL/SMS/ALARM/Volume setting)
3865 $Returns: the current ringer_mode
3866
3867 $Arguments: None
3868
3869 *******************************************************************************/
3870
3871 int get_ringer_mode(void)
3872 {
3873 T_AS_RINGER_MODE current_mode;
3874
3875 TRACE_FUNCTION("get_ringer_mode");
3876
3877 switch(getSoundsReason())
3878 {
3879 case MelodySelect:
3880 current_mode=AS_RINGER_MODE_IC;
3881 break;
3882
3883 case SettingSMSTone:
3884 current_mode=AS_RINGER_MODE_SMS;
3885 break;
3886
3887 case SettingAlarm:
3888 current_mode=AS_RINGER_MODE_ALARM;
3889 break;
3890
3891 case SettingVolume:
3892 current_mode=AS_RINGER_MODE_IC;
3893 break;
3894
3895 }
3896 return current_mode;
3897 }
3898
3899 /*******************************************************************************
3900
3901 $Function: playCurrentMelody
3902
3903 $Description: play midi file which is temporarily selected, this event handler
3904 is invoked when the hPlayerStartTimer event completes
3905
3906 $Returns: MFW_EVENT_CONSUMED always
3907
3908 $Arguments: e, event, tc timer context
3909
3910 *******************************************************************************/
3911
3912 static int playCurrentMelody( MfwEvt e, MfwTim *tc )
3913 {
3914
3915 TRACE_EVENT_P1("playCurrentMelody. The selected tone is %d",selected_tone);
3916 soundsPlayMidiPlayer(selected_tone);
3917
3918 // stop running timer
3919 if (hPlayerStartTimer != NULL )
3920 {
3921 timStop(hPlayerStartTimer);
3922 }
3923
3924 return MFW_EVENT_CONSUMED;
3925 }
3926
3927
3928 /*******************************************************************************
3929
3930 $Function: soundsPlayMidiPlayer
3931
3932 $Description: Play the tune selected by melody_id, stopping any currently
3933 playing tunes if necessary.
3934 $Returns: None
3935
3936 $Arguments: melody_id, selects the melody to be played
3937
3938 *******************************************************************************/
3939 static void soundsPlayMidiPlayer( int melody_id )
3940 {
3941
3942 #ifdef FF_MIDI_RINGER
3943 T_AS_RINGER_INFO * ringer_info;
3944 T_AS_RINGER_INFO temp_ringer_info;
3945 T_AS_PLAYER_TYPE player_type;
3946 #ifdef FF_MIDI_LOAD_FROM_MEM
3947 T_MELODY melody_data;
3948 #else
3949 char* midi_file;
3950
3951 #endif
3952 #endif
3953
3954 TRACE_EVENT_P1("soundsPlayMidiPlayer.The melody_id is %d",melody_id);
3955 CurrentTune = melody_id;
3956 ringer_info=mfw_ringer_get_info(get_ringer_mode(),&temp_ringer_info);
3957 TRACE_EVENT_P1("ringer_info details volume are %d ",ringer_info->volume);
3958 #ifdef FF_MIDI_LOAD_FROM_MEM
3959 melody_data=sounds_midi_return_memory_location(CurrentTune);
3960 player_type=mfw_ringer_deduce_player_type(melody_data.melody_name);
3961 mfw_player_start_memory(player_type,(UINT32*)melody_data.melody,melody_data.melody_size,ringer_info->volume,FALSE,sounds_midi_player_start_cb);
3962 #else
3963 midi_file=sounds_midi_return_file_name(CurrentTune);
3964 TRACE_EVENT_P1("midi_file is %s",midi_file);
3965 player_type=mfw_ringer_deduce_player_type(midi_file);
3966 mfw_player_start_file(player_type,midi_file,ringer_info->volume,FALSE,sounds_midi_player_start_cb);
3967 #endif
3968
3969
3970 }
3971
3972 /*******************************************************************************
3973
3974 $Function: startPlayerTimer
3975
3976 $Description: Start the timer for Scrolling of Midi files
3977 $Returns: None
3978
3979 $Arguments: None
3980
3981 *******************************************************************************/
3982
3983 void startPlayerTimer()
3984
3985 {
3986 // start timer for 5 milli second and on timeout play the file
3987 timStart( hPlayerStartTimer );
3988 }
3989
3990 /*******************************************************************************
3991
3992 $Function: stopPlayerTimer
3993
3994 $Description: Stop the timer for Scrolling of Midi files.Stop the melody, if anything is playing.
3995 $Returns: None
3996
3997 $Arguments: None
3998
3999 *******************************************************************************/
4000
4001 static void stopPlayerTimer( void )
4002 {
4003 TRACE_FUNCTION( "stopPlayerTimer" );
4004
4005 /* If a timer event is running we want to stop that as well.
4006 since we want to turn the tune off and have
4007 it start again when the timer expires*/
4008
4009 if ( hPlayerStartTimer != NULL )
4010 timStop( hPlayerStartTimer );
4011 // Stop the tone
4012
4013 //mfw_player_stop(sounds_midi_player_stop_cb);
4014
4015
4016 }
4017
4018
4019 /*******************************************************************************
4020
4021 $Function: playCurrentVolumeTone
4022
4023 $Description: play midi file with the volume which is temporarily selected, this event handler
4024 is invoked when the hPlayerStartTimer event completes
4025
4026 $Returns: MFW_EVENT_CONSUMED always
4027
4028 $Arguments: e, event, tc timer context
4029
4030 *******************************************************************************/
4031
4032 static int playCurrentVolumeTone( MfwEvt e, MfwTim *tc )
4033 {
4034
4035 TRACE_EVENT("playCurrentVolumeTone");
4036 soundsPlayVolumeMelody();
4037 // stop running timer
4038 if (hPlayerStartTimer != NULL )
4039 {
4040 timStop(hPlayerStartTimer);
4041 }
4042 return MFW_EVENT_CONSUMED;
4043 }
4044
4045 /*******************************************************************************
4046
4047 $Function: startVolumeTimer
4048
4049 $Description: Start the timer for modifying the volume of Midi files
4050 $Returns: None
4051
4052 $Arguments: None
4053
4054 *******************************************************************************/
4055
4056 void startVolumeTimer()
4057
4058 {
4059 TRACE_EVENT("startVolumeTimer");
4060 // start timer for 5 milli second and on timeout play the file
4061 timStart( hPlayerStartTimer );
4062 }
4063
4064 /*******************************************************************************
4065
4066 $Function: stopVolumeTimer
4067
4068 $Description: Stop the timer for chnaging volume of Midi files.Stop the melody, if anything is playing.
4069 $Returns: None
4070
4071 $Arguments: None
4072
4073 *******************************************************************************/
4074
4075 void stopVolumeTimer(void)
4076 {
4077 TRACE_EVENT("stopVolumeTimer");
4078 if ( hPlayerStartTimer != NULL )
4079 timStop( hPlayerStartTimer );
4080 // Are we playing a tune
4081 //mfw_player_stop(sounds_midi_player_stop_cb);
4082 }
4083
4084 /*******************************************************************************
4085
4086 $Function: soundsPlayVolumeMelody
4087
4088 $Description: Play the ringer tune with the selected volume, stopping any currently
4089 playing tunes if necessary.
4090 $Returns: None
4091
4092 $Arguments: melody_id, selects the melody to be played
4093
4094 *******************************************************************************/
4095
4096 static void soundsPlayVolumeMelody()
4097 {
4098
4099 T_AS_RINGER_INFO * ringer_info;
4100 T_AS_RINGER_INFO temp_ringer_info;
4101 T_AS_PLAYER_TYPE player_type;
4102 TRACE_EVENT("soundsPlayVolumeMelody");
4103 TRACE_EVENT_P1("the current volume now is %d",current.volumeSetting);
4104 #ifdef FF_MIDI_RINGER
4105 //If going to the volume screen from Idle screen,change the incoming call volume.
4106 //mfw_player_stop(sounds_midi_player_stop_cb);
4107 ringer_info=mfw_ringer_get_info(get_ringer_mode(),&temp_ringer_info);
4108 #ifdef FF_MIDI_LOAD_FROM_MEM
4109 mfw_player_start_memory(ringer_info->player_type,ringer_info->data.memory.address,ringer_info->data.memory.size,current.volumeSetting,FALSE,sounds_midi_player_start_cb);
4110 #else
4111 mfw_player_start_file(ringer_info->player_type,ringer_info->data.filename,(T_AS_VOLUME)current.volumeSetting,FALSE,sounds_midi_player_start_cb);
4112 #endif
4113 #endif
4114
4115 }
4116
4117 /*******************************************************************************
4118
4119 $Function: sounds_midi_return_memory_location
4120
4121 $Description: Returns the Melody structure
4122
4123 $Returns: Structure containing the memory location, size and filename
4124
4125 $Arguments: index :index whose memory location has to be retrieved
4126
4127 *******************************************************************************/
4128 T_MELODY sounds_midi_return_memory_location(UBYTE index)
4129 {
4130 #ifdef FF_MIDI_LOAD_FROM_MEM
4131 TRACE_FUNCTION("sounds_midi_return_memory_location");
4132 return mmi_midi_files[index];
4133 #endif
4134 }
4135
4136 //Jul 20, 2005 REF: SPR 30772 xdeepadh
4137 /*******************************************************************************
4138
4139 $Function: sounds_midi_GetExtension
4140
4141 $Description: public function to retrieve the extension of a file
4142
4143 $Returns:Extention of the filename
4144
4145 $Arguments: scr- Filename
4146
4147 *******************************************************************************/
4148 char *sounds_midi_GetExtension(char *src)
4149 {
4150 int i;
4151 TRACE_FUNCTION("sounds_midi_GetExtension");
4152 for(i = 0; i < strlen(src); i++){
4153 if(src[i] == '.'){
4154 return (src+i+1);
4155 }
4156 }
4157 return (src+i);
4158 }
4159
4160 #endif
4161
4162
4163
4164 /*******************************************************************************
4165
4166 End Of File
4167
4168 *******************************************************************************/