comparison src/aci2/bmi/mmiMidiTest.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/MmiMidiTest.c@93999a60b835
children
comparison
equal deleted inserted replaced
119:b92a33c204b6 120:3c2acfa1a72f
1 /*******************************************************************************
2
3 Texas Instruments
4
5 ********************************************************************************
6
7 This software product is the property of Texas Instruments and may not be
8 disclosed to any third party without the express permission of the owner.
9
10 ********************************************************************************
11
12 $Project name: Test MMI
13 $Module: MIDI TEST
14 $File: MmiMidiTest.c
15 $Revision: 1.0
16
17 $Author: Elsa Armanet-Said Texas Instruments Nice
18 $Date: 17/05/04
19
20 ********************************************************************************
21
22 Description:
23
24 This provides the start code for the MMI
25
26 ********************************************************************************
27 $History: MmiMidiTest.c
28
29 Nov 23, 2005 REF : DR OMAPS00057378 x0039928
30 Bug: All MIDI files are not displayed in MMI in locosto-lite
31 Fix: Buffer memory allocated to copy the file contents is freed
32 properly and copying file from FFS to LFS is not terminated if error is
33 returned for just any one file, instead it tries to copy other files.
34
35 Nov 09, 2005 REF:DR OMAPS00049167 x0039928
36 Description: The midi files cannot be heard if the audio channel selected is 'Mono'
37 Solution: Midi Player params are made global so that settings are retained across.
38
39 Nov 02, 2005 REF:ER OMAPS00039044 xdeepadh
40 Description: Mp3 Ringer Implementation
41 Solution: The Midi Ringer application has been enhanced to support mp3 as ringer.
42 The interface function names have been modified.
43
44 Sep 29,2005 REF: SPR 34407 xdeepadh
45 Bug:Back soft key takes more time to return to the previous screen in Midi application
46 Fix:The list creation for Midi files has been modified
47
48 Aug 29, 2005 REF: SPR 33999 xdeepadh
49 Description:Midi Application - Play all files asks for a file to be selected
50 Solution: When the files are not selected, the current playing index is set 0.
51
52 Apr 05, 2005 REF: ENH 29994 xdeepadh
53 Description: Implementation of Generic Midi Ringer and Modification of existing Midi Test Application
54 Solution: Generic Midi Ringer and Midi Test Application were implemented.
55
56 Dec 08, 2004 REF: CRR MMI-SPR-27284
57 Description: MIDI Player: Back Key malfunctions in MIDI application.
58 Solution: A window is created to hold list window. When the user presses Back key, the newly
59 created window is deleted along with list window, bringing the control back to Midi options
60 screen.
61
62 17/05/04
63
64 $End
65
66 *******************************************************************************/
67
68
69
70
71 /*******************************************************************************
72
73 Include files
74
75 *******************************************************************************/
76 #define ENTITY_MFW
77
78 /* includes */
79
80 #include <string.h>
81 #include <stdio.h>
82 #include <stdlib.h>
83
84 #include "typedefs.h"
85 #include "vsi.h"
86 #include "pei.h"
87 #include "custom.h"
88
89 #if defined (NEW_FRAME)
90
91 #include "typedefs.h"
92 #include "vsi.h"
93 #include "pei.h"
94 #include "custom.h"
95 #include "gsm.h"
96 #include "prim.h"
97
98 #else
99
100 #include "STDDEFS.H"
101 #include "custom.h"
102 #include "gsm.h"
103 #include "vsi.h"
104
105 #endif
106
107 #include "message.h" /* included for aci_cmh.h .... */
108 #include "aci_cmh.h" /* included for mfw_sat.h, included for MmiDummy.h, included for MmiMenu.h */
109
110 #include "mfw_mfw.h"
111 #include "mfw_win.h"
112 #include "mfw_icn.h" /* included for mfw_mnu.h */
113 #include "mfw_mnu.h"
114 #include "mfw_tim.h"
115 #include "mfw_kbd.h"
116 #include "mfw_sat.h" /* included for MmiDummy.h, included for MmiMenu.h */
117 #include "mfw_midi.h"
118
119 #include "kpd/kpd_api.h"
120
121 #include "MmiBlkLangDB.h"
122 #include "mmiColours.h"
123 #include "MmiDialogs.h"
124
125 #include "MmiDummy.h" /* included for MmiMenu.h */
126 #include "MmiLists.h"
127 #include "MmiMenu.h"
128 #include "MmiSoftKeys.h"
129 #include "AUIEditor.h"
130 #include "MmiMidiTest.h"
131 #include "MmiMain.h"
132 #include "Mmisounds.h"
133
134 /*******************************************************************************
135
136 internal data
137
138 *******************************************************************************/
139
140 /*
141 * Internal events
142 */
143 #define MT_CREATE_EDITOR 500
144 #define MT_EDITOR_CANCEL 501
145 #define MT_EDITOR_SELECT 502
146 #define MT_NAME_EDITOR 503
147 #define MT_MNU_INIT 504
148
149 /*local defines*/
150
151 #define MT_MAX_EDITOR_LENGTH 4
152 #define MT_INFO_SCRN_TIMEOUT 1500
153 #define MT_MAX_FILES 8
154
155 // Dec 08, 2004 REF: CRR MMI-SPR-27284
156 // Description: MIDI Player: Back Key malfunctions in MIDI application.
157 // E_INIT event definition
158 #define E_INIT 1
159
160 /*editor data structure*/
161 typedef struct{
162 T_MMI_CONTROL mmi_control;
163 MfwHnd win;
164 MfwHnd mt_win_editor;
165 UBYTE mt_buffer[MT_MAX_EDITOR_LENGTH+1];
166 USHORT mt_voice_number;
167 } T_MMI_MT_Editor_Data;
168
169 /*menu data structure definition*/
170 typedef struct
171 {
172 T_MMI_CONTROL mmi_control;
173 T_MFW_HND win;
174 T_MFW_HND kbd;
175 T_MFW_HND kbd_long;
176 T_MFW_HND mt_menu;
177 T_MFW_HND parent; // Dec 08, 2004 REF: CRR MMI-SPR-27284. Member "parent" added
178 T_VOID_FUNC func_cb;
179 T_VOID_FUNC cancel_cb;
180 UBYTE mt_num_file;
181 UBYTE mt_file_count;
182 ListCbFunc mt_list_cb;
183 UBYTE mt_list_idx;
184 UBYTE IsMfwInit;
185 ListMenuData * menu_list_data; //Sep 29,2005 REF: SPR 34407 xdeepadh
186 }T_mt_menu;
187
188 /*global menu data*/
189 T_mt_menu mt_menu_data = {0};
190 extern UBYTE mfw_player_exit_flag;//Flag to check playall is selected.
191 extern int mfw_player_currently_playing_idx;//Stores the index of the current selected file
192 extern UBYTE mfw_player_playback_loop_flag;//Flag to check whether loop is on /off
193 // Nov 23, 2005 REF : DR OMAPS00057378 x0039928
194 // IsMidiInit variable decides whether to copy files from FFS to LFS
195 extern UBYTE IsMidiInit;
196
197 /*******************************************************************************
198
199 Local prototypes
200
201 *******************************************************************************/
202 static void midi_mt_menu_list_listmnu_cb(T_MFW_HND Parent, ListMenuData * ListData);
203 static void mmi_midi_test_editor_cb(T_MFW_HND win, USHORT identifier, SHORT reason);
204 //Sep 29,2005 REF: SPR 34407 xdeepadh
205 static T_MFW_HND mmi_midi_test_build_Menu( MfwHnd parent_window);
206
207
208 /*default static menu*/
209 static MfwMnuAttr menuMtSearchListAttr =
210 {
211 &menuArea,
212 MNU_LEFT | MNU_LIST | MNU_CUR_LINE, /* centered page menu */
213 -1, /* use default font */
214 NULL, /* with these items (filled in later) */
215 0, /* number of items (filled in leter) */
216 COLOUR_LIST_XX, /* Colour */
217 TxtNull, /* Hdr Id */
218 NULL, /* Background */
219 MNUATTRSPARE /* unused */
220 };
221
222 /*******************************************************************************
223
224 $Function: mmi_midi_test_show_info
225
226 $Description: Display the Dialog
227
228 $Returns:
229
230 $Arguments:
231
232 *******************************************************************************/
233 static MfwHnd mmi_midi_test_show_info(T_MFW_HND parent, int str1, int str2, T_VOID_FUNC callback)
234 {
235 T_DISPLAY_DATA display_info;
236
237 TRACE_FUNCTION ("mmi_midi_test_show_info()");
238
239 /*
240 ** Create a timed dialog to display the Message "Failed"
241 */
242 dlg_initDisplayData_TextId( &display_info, TxtNull, TxtNull, str1, str2, COLOUR_STATUS);
243 dlg_initDisplayData_events( &display_info, callback, MT_INFO_SCRN_TIMEOUT, KEY_LEFT | KEY_CLEAR | KEY_HUP);
244
245 return info_dialog(parent, &display_info);
246 }
247
248
249 /*******************************************************************************
250
251 $Function: midi_stop_player
252
253 $Description:Stops the Midi file playing
254
255 $Returns:
256
257 $Arguments:m, menu being activated, i, item in menu
258
259 *******************************************************************************/
260 GLOBAL int midi_stop_player (MfwMnu* m, MfwMnuItem* i)
261 {
262
263 TRACE_FUNCTION ("midi_stop_player()");
264 if(mfw_player_exit_flag == PLAYER_EXIT_FLAG_FALSE)
265 mfw_player_exit_flag = PLAYER_EXIT_FLAG_TRUE;
266 mfw_player_stop(sounds_midi_player_stop_cb);
267 return 1;
268 }
269
270 /*******************************************************************************
271
272 $Function: mmi_mt_add_selected_file
273
274 $Description: display info message to let user know that file was selected
275
276 $Returns: MFW_EVENT_CONSUMED
277
278 $Arguments:
279
280 *******************************************************************************/
281 static int mmi_mt_add_selected_file(MfwMnu* m, MfwMnuItem* i)
282 {
283 mmi_midi_test_show_info(0, TxtMidiFileSelected, TxtNull, NULL);
284 return MFW_EVENT_CONSUMED;
285 }
286
287
288 /*******************************************************************************
289
290 $Function: mmi_midi_test_editor_cb
291
292 $Description: This function provides the callback functionality to an editor for Midi test
293
294 $Returns: None
295
296 $Arguments:
297
298 *******************************************************************************/
299
300 static void mmi_midi_test_editor_cb(T_MFW_HND win, USHORT identifier, SHORT reason)
301 {
302 T_MFW_WIN * win_data = ((T_MFW_HDR *) win)->data;
303 T_MMI_MT_Editor_Data* dev_name_data = (T_MMI_MT_Editor_Data *)win_data->user;
304 UBYTE * editor_buffer = NULL;
305 SHORT max_edit_size = 0;
306 T_MFW_HND editor_win;
307 T_MFW_HND parent;
308
309 TRACE_FUNCTION ("mmi_midi_test_editor_cb()");
310
311 if (identifier == MT_NAME_EDITOR)
312 {
313 editor_buffer = dev_name_data->mt_buffer;
314 max_edit_size = MT_MAX_EDITOR_LENGTH;
315 editor_win = dev_name_data->mt_win_editor;
316 parent = dev_name_data->win;
317 }
318 else
319 {
320 TRACE_FUNCTION ("mmi_midi_test_editor_cb() : Unknown Identifier");
321 /*
322 ** if this isn't one of the "recognised" editors leave now!
323 */
324 return;
325 }
326
327 switch (reason)
328 {
329 case INFO_KCD_LEFT:
330 {
331 /*
332 ** If there is no string entered, treat this as if it was a "Cancel"
333 */
334 if (editor_buffer[0] == 0x00)
335 {
336 /*
337 ** Send a "Cancel" to the Midi test window
338 */
339 SEND_EVENT(parent, MT_EDITOR_CANCEL, identifier, NULL);
340 }
341 else
342 {
343 /*
344 ** Send a "Select" to the Midi test window
345 */
346 SEND_EVENT(parent, MT_EDITOR_SELECT, identifier, NULL);
347 }
348 }
349 break;
350
351 case INFO_KCD_RIGHT:
352 if (strlen((char *)editor_buffer) == 0)
353 {
354
355 /*
356 ** Send a "Cancel" to the Midi test window
357 */
358 SEND_EVENT(parent, MT_EDITOR_CANCEL, identifier, NULL);
359 }
360 break;
361
362 case INFO_KCD_HUP:
363 /*
364 ** Set the buffer to NULLS
365 */
366 memset(editor_buffer, 0x00, max_edit_size);
367
368 /*
369 ** Send a "Cancel" to the Midi test window
370 */
371 SEND_EVENT(parent, MT_EDITOR_CANCEL, identifier, NULL);
372 break;
373
374 default:
375 /* otherwise no action to be performed
376 */
377 break;
378 }
379 }
380
381
382 /*******************************************************************************
383
384 $Function: mmi_midi_test_editor_destroy
385
386 $Description: This function performs the necessary steps to remove the window handling the
387 voice number editor, tidying up all allocated resources.
388
389 $Returns: MfwResOk : Success
390 MfwResIllHnd : Illegal Window Handler provided
391
392 $Arguments: win : Window to be destroyed
393
394 *******************************************************************************/
395 MfwRes mmi_midi_test_editor_destroy(T_MFW_HND win)
396 {
397 T_MFW_WIN * win_data;
398 T_MMI_MT_Editor_Data * data;
399
400 TRACE_FUNCTION ("mmi_midi_test_editor_destroy");
401
402
403 if (win == (void *)0)
404 return MfwResIllHnd;
405
406 win_data = ((T_MFW_HDR *) win)->data;
407 data = (T_MMI_MT_Editor_Data *)win_data->user;
408
409 /*
410 ** Destroy the Window
411 */
412 win_delete(data->win);
413
414 /*
415 ** Free the dynamically allocated memory
416 */
417 mfwFree((U8 *)data, (U16)sizeof(T_MMI_MT_Editor_Data));
418
419 return MfwResOk;
420 }
421
422
423 /*******************************************************************************
424
425 $Function: mmi_midi_test_editor_cntrl
426
427 $Description: This is the dialog control function for the voice number selection Window. It
428 receives the signals from the MFW and determines what action, if any, to take.
429
430 $Returns: None
431
432 $Arguments: win : The pointer to the window handler, so the function can reference the
433 dynamic user data, if any.
434 event : The incoming event
435 value : Generic incoming Parameter, it will be 'event' dependant
436 parameter : Generic incoming Parameter, it will be 'event' dependant
437
438 *******************************************************************************/
439 void mmi_midi_test_editor_cntrl (T_MFW_HND win, USHORT event, SHORT value, void * parameter)
440 {
441 T_MFW_WIN * win_data = ((T_MFW_HDR *) win)->data;
442 T_MMI_MT_Editor_Data * data = (T_MMI_MT_Editor_Data *)win_data->user;
443 T_AUI_EDITOR_DATA editor_data;
444 SHORT mfw_midi_retVal;
445 int voice_limit;
446
447 switch (event)
448 {
449 case MT_CREATE_EDITOR:
450 #ifdef NEW_EDITOR
451 //Clear the editor buffer
452 memset(&editor_data,'\0',sizeof(editor_data));
453
454 /*
455 ** Initialise the editor
456 */
457 AUI_edit_SetDefault(&editor_data);
458 AUI_edit_SetBuffer(&editor_data, ATB_DCS_ASCII, data->mt_buffer, MT_MAX_EDITOR_LENGTH);
459 AUI_edit_SetTextStr(&editor_data, TxtSoftSelect, TxtSoftBack, TxtMidiEnterVoiceNumber, TxtNull);
460 AUI_edit_SetAltTextStr(&editor_data, 1, TxtNull, TRUE, TxtCancel);
461 AUI_edit_SetEvents(&editor_data, MT_NAME_EDITOR, TRUE, FOREVER, (T_AUI_EDIT_CB)mmi_midi_test_editor_cb);
462 data->mt_win_editor = AUI_edit_Start(data->win, &editor_data);
463 #endif
464 break;
465
466 case MT_EDITOR_CANCEL:
467
468 if (value == MT_NAME_EDITOR)
469 {
470 /*
471 ** The editor will have been destroyed. Reset the Window handler
472 */
473 data->mt_win_editor = (void *)0;
474 }
475 else
476 {
477 TRACE_FUNCTION ("mmi_midi_test_editor_cntrl(), MT_EDITOR_CANCEL event received with unexpected value" );
478 }
479
480 /*
481 ** Destroy the editor Window
482 */
483 TRACE_FUNCTION ("mmi_midi_test_editor_cntrl cancel");
484 mmi_midi_test_editor_destroy(data->win);
485 break;
486
487 case MT_EDITOR_SELECT:
488 if (value == MT_NAME_EDITOR)
489 {
490 voice_limit=atoi((char*)data->mt_buffer);
491 TRACE_EVENT_P1("voice_limit is %d",voice_limit);
492 if(voice_limit >32 ||voice_limit <=0)
493 {
494 mmi_midi_test_show_info(0, TxtError, TxtNull, NULL);
495 }
496 else
497 {
498 //translate ASCII format into integer format
499 mfw_midi_retVal = mfw_player_midi_set_voice_limit(voice_limit);
500 if(mfw_midi_retVal != MFW_PLAYER_TEST_OK)
501 {
502 mmi_midi_test_show_info(0, TxtChConfigVoiceLimit, TxtSelected, NULL);
503 }
504 }
505 }
506 else
507 {
508 TRACE_FUNCTION ("mmi_midi_test_editor_cntrl(), MT_EDITOR_SELECT event received with unexpected value");
509 }
510 TRACE_FUNCTION ("mmi_midi_test_editor_cntrl select");
511
512 /*
513 ** Destroy the Editor Window
514 */
515 mmi_midi_test_editor_destroy(data->win);
516 break;
517
518 default:
519 TRACE_FUNCTION ("mmi_midi_test_editor_cntrl(), Unexpected Event!");
520 break;
521 }
522
523 }
524
525
526
527 /*******************************************************************************
528
529 $Function: midi_test_editor_create
530
531 $Description: This function performs the necessary steps to create the a window to enter the number of voices.
532 It will be removed, or rather remove itself on returning the
533 data to the Mfw.
534
535 $Returns: T_MFW_HND : Window Handle to the New Window, Null if failed.
536
537 $Arguments: parent : pointer to the parent window.
538
539 *******************************************************************************/
540 T_MFW_HND midi_test_editor_create(T_MFW_HND parent)
541 {
542 T_MMI_MT_Editor_Data *data;
543 T_MFW_WIN * win;
544
545 TRACE_FUNCTION ("midi_test_editor_create");
546
547 data = (T_MMI_MT_Editor_Data *)mfwAlloc((U16)sizeof(T_MMI_MT_Editor_Data));
548
549 if (data == (void *)0)
550 return data;
551
552 data->win = winCreate(parent, 0, E_WIN_VISIBLE, NULL);
553
554 if (data->win == (void *)0)
555 {
556 /*
557 ** Failed to start : Free Memory, and exit
558 */
559 mfwFree((U8 *)data, (U16)sizeof(T_MMI_MT_Editor_Data));
560 data = (void *)0;
561 return data;
562 }
563 else
564 {
565 /*
566 ** Setup the Dialog control functions
567 */
568 data->mmi_control.dialog = (T_DIALOG_FUNC)mmi_midi_test_editor_cntrl;
569 data->mmi_control.data = data;
570
571 win = ((T_MFW_HDR *)data->win)->data;
572 win->user = (void *)data;
573 }
574
575 return data->win;
576
577 }
578
579
580 /*******************************************************************************
581
582 $Function: mt_menu_win_cb
583
584 $Description: menu window callback (implementation of softkeys)
585
586 $Returns:
587
588 $Arguments:
589
590 *******************************************************************************/
591 static int mt_menu_win_cb (MfwEvt e, MfwWin *w)
592 {
593 T_mt_menu * data = (T_mt_menu *)w->user;
594 MfwMnu * mnu;
595
596 TRACE_FUNCTION ("mt_menu_win_cb ");
597
598 switch (e)
599 {
600 case MfwWinVisible:
601 mnu = (MfwMnu *)mfwControl(data->mt_menu);
602 softKeys_displayId(TxtSoftSelect, TxtSoftBack, 0, mnu->curAttr->mnuColour );
603 break;
604
605 default:
606 return 0;
607 }
608 return 1;
609 }
610
611
612 /*******************************************************************************
613
614 $Function: mt_menu_destroy
615
616 $Description: destroy menu window
617
618 $Returns:
619
620 $Arguments: window to be destroyed
621
622 *******************************************************************************/
623 static void mt_menu_destroy(MfwHnd window)
624 {
625 T_MFW_WIN * win_data = ((T_MFW_HDR *)window)->data;
626 T_mt_menu * data = (T_mt_menu *)win_data->user;
627
628 TRACE_FUNCTION ("mt_menu_destroy");
629
630 if (window == NULL)
631 {
632 return;
633 }
634
635 if (data)
636 {
637 win_delete(data->win);
638
639 /*
640 ** Free Memory
641 */
642 mfwFree((void *)data, sizeof (T_mt_menu));
643 }
644 }
645
646 //Sep 29,2005 REF: SPR 34407 xdeepadh
647 /*******************************************************************************
648
649 $Function: midi_mt_menu_list_listmnu_cb
650
651 $Description: destroy lists and menu in case of back softkey or menu exit
652
653 $Returns:
654
655 $Arguments:
656
657 *******************************************************************************/
658 static void midi_mt_menu_list_listmnu_cb(T_MFW_HND Parent, ListMenuData * ListData)
659 {
660 T_MFW_WIN *win_data = ((T_MFW_HDR *)Parent)->data;
661 T_mt_menu *data = (T_mt_menu *)win_data->user;
662
663 TRACE_FUNCTION ("midi_mt_menu_list_listmnu_cb()");
664
665
666 if ((ListData->Reason EQ LISTS_REASON_BACK) ||
667 (ListData->Reason EQ LISTS_REASON_CLEAR) ||
668 (ListData->Reason EQ LISTS_REASON_HANGUP))
669 {
670 /*
671 ** Destroy the window --- Not sure if this is required! ... leave it out for now
672 */
673 listsDestroy(ListData->win);
674
675 /*
676 ** Free the memory set aside for ALL the devices to be listed.
677 */
678 if (data->menu_list_data != NULL)
679 {
680 FREE_MEMORY ((void *)data->menu_list_data->List, (U16)(data->mt_num_file * sizeof (T_MFW_MNU_ITEM)));
681 FREE_MEMORY ((void *)data->menu_list_data, sizeof (ListMenuData));
682 }
683
684 mt_menu_destroy(data->win);
685
686 }
687 //Sep 29,2005 REF: SPR 34407 xdeepadh
688 else if(ListData->Reason EQ LISTS_REASON_SELECT)
689 {
690 TRACE_EVENT_P1("list position is %d",ListData->ListPosition);
691 mt_menu_data.mt_list_idx = ListData->ListPosition;
692 //call mfw to save selected index
693 mfw_player_save_selected_file_idx(mt_menu_data.mt_list_idx);
694 //display a "file selected" text here
695 mmi_midi_test_show_info(0, TxtMidiFileSelected, TxtNull, NULL);
696 }
697
698 return;
699 }
700
701
702
703 /*******************************************************************************
704
705 $Function: midi_test_set_loop_on
706
707 $Description: set loop on
708
709 $Returns:
710
711 $Arguments:menu, menu item
712
713 *******************************************************************************/
714 GLOBAL int midi_test_set_loop_on (MfwMnu* m, MfwMnuItem* i)
715 {
716 SHORT mfw_midi_retVal;
717
718 TRACE_FUNCTION ("midi_test_set_loop_on()");
719
720 mfw_midi_retVal = mfw_player_set_loop_on();
721 if(mfw_midi_retVal != MFW_PLAYER_TEST_OK)
722 {
723 TRACE_FUNCTION ("midi_test_set_loop_on(): Riviera Failed");
724 mmi_midi_test_show_info(0, TxtMidiOptionNotImplemented, TxtNull, NULL);
725 }
726 else
727 {
728 mmi_midi_test_show_info(0, TxtMidiLoopOn, TxtNull, NULL);
729 }
730 return 1;
731 }
732
733 /*******************************************************************************
734
735 $Function: midi_test_set_loop_off
736
737 $Description: set loop off
738
739 $Returns:
740
741 $Arguments:menu, menu item
742
743 *******************************************************************************/
744 GLOBAL int midi_test_set_loop_off (MfwMnu* m, MfwMnuItem* i)
745 {
746 SHORT mfw_midi_retVal;
747
748 TRACE_FUNCTION ("midi_test_set_loop_off()");
749
750 mfw_midi_retVal = mfw_player_set_loop_off();
751 if(mfw_midi_retVal != MFW_PLAYER_TEST_OK)
752 {
753 TRACE_FUNCTION ("midi_test_set_loop_off(): Riviera Failed");
754 mmi_midi_test_show_info(0, TxtMidiOptionNotImplemented, TxtNull, NULL);
755 }
756 else
757 {
758 mmi_midi_test_show_info(0, TxtMidiLoopOff, TxtNull, NULL);
759 }
760 return 1;
761 }
762
763
764 /*******************************************************************************
765
766 $Function: midi_test_set_channel_mono
767
768 $Description: set channels to mono
769
770 $Returns:
771
772 $Arguments:menu, menu item
773
774 *******************************************************************************/
775 GLOBAL int midi_test_set_channel_mono (MfwMnu* m, MfwMnuItem* i)
776 {
777
778 SHORT mfw_midi_retVal;
779
780 TRACE_FUNCTION ("midi_test_set_channel_mono()");
781 mfw_midi_retVal = mfw_player_set_channel_mono();
782 if(mfw_midi_retVal != MFW_PLAYER_TEST_OK)
783 {
784 TRACE_FUNCTION ("mfw_player_set_channel_mono(): Riviera Failed");
785 mmi_midi_test_show_info(0, TxtMidiOptionNotImplemented, TxtNull, NULL);
786 }
787 else
788 {
789 mmi_midi_test_show_info(0, TxtMidiMonoChannel, TxtNull, NULL);
790 }
791
792 return 1;
793 }
794
795 /*******************************************************************************
796
797 $Function: midi_test_set_channel_stereo
798
799 $Description: set channels to stereo
800
801 $Returns:
802
803 $Arguments:menu, menu item
804
805 *******************************************************************************/
806 GLOBAL int midi_test_set_channel_stereo (MfwMnu* m, MfwMnuItem* i)
807 {
808
809 SHORT mfw_midi_retVal;
810
811 TRACE_FUNCTION ("midi_test_set_channel_stereo()");
812 mfw_midi_retVal = mfw_player_set_channel_stereo();
813 if(mfw_midi_retVal != MFW_PLAYER_TEST_OK)
814 {
815 TRACE_FUNCTION ("mfw_player_set_channel_stereo(): Riviera Failed");
816 mmi_midi_test_show_info(0, TxtMidiOptionNotImplemented, TxtNull, NULL);
817 }
818 else
819 {
820 mmi_midi_test_show_info(0, TxtMidiStereoChannel, TxtNull, NULL);
821 }
822
823 return 1;
824 }
825
826 /*******************************************************************************
827
828 $Function: midi_test_set_speaker
829
830 $Description: set audiopath to speaker
831
832 $Returns:
833
834 $Arguments: menu, menu item
835
836
837 *******************************************************************************/
838 GLOBAL int midi_test_set_speaker (MfwMnu* m, MfwMnuItem* i)
839 {
840
841 SHORT mfw_midi_retVal;
842 TRACE_FUNCTION ("midi_test_set_speaker()");
843
844 mfw_midi_retVal=mfw_player_set_speaker();
845 if(mfw_midi_retVal != MFW_PLAYER_TEST_OK)
846 {
847 TRACE_FUNCTION ("midi_test_set_speaker(): Failed");
848 mmi_midi_test_show_info(0, TxtMidiOptionNotImplemented, TxtNull, NULL);
849 }
850 else
851 {
852 mmi_midi_test_show_info(0, TxtMidiSpeaker, TxtNull, NULL);
853 }
854
855 return 1;
856 }
857
858
859
860 /*******************************************************************************
861
862 $Function: midi_test_set_headset
863
864 $Description: set audiopath to headset
865
866 $Returns:
867
868 $Arguments:menu, menu item
869
870 *******************************************************************************/
871 GLOBAL int midi_test_set_headset (MfwMnu* m, MfwMnuItem* i)
872 {
873 SHORT mfw_midi_retVal;
874 TRACE_FUNCTION ("midi_test_set_headset()");
875
876 mfw_midi_retVal=mfw_player_set_headset();
877 if(mfw_midi_retVal != MFW_PLAYER_TEST_OK)
878 {
879 TRACE_FUNCTION ("midi_test_set_headset(): Failed");
880 mmi_midi_test_show_info(0, TxtMidiOptionNotImplemented, TxtNull, NULL);
881 }
882 else
883 {
884 mmi_midi_test_show_info(0, TxtMidiHeadset, TxtNull, NULL);
885 }
886
887 return 1;
888 }
889
890
891
892 /*******************************************************************************
893
894 $Function: midi_test_cc_voice_limit
895
896 $Description:Creates the Editor for entering the voice limit number
897
898 $Returns:
899
900 $Arguments:menu, menu item
901
902 *******************************************************************************/
903 GLOBAL int midi_test_cc_voice_limit (MfwMnu* m, MfwMnuItem* i)
904 {
905
906 T_MFW_HND win = mfw_parent(mfw_header());
907 T_MFW_WIN * win_data = ((T_MFW_HDR *) win)->data;
908 T_MMI_MT_Editor_Data * data = (T_MMI_MT_Editor_Data *)(win_data->user);
909
910 TRACE_FUNCTION ("midi_test_cc_voice_limit()");
911
912 data->mt_win_editor = midi_test_editor_create(win);
913
914 if (data->mt_win_editor != (void *)0)
915 {
916 SEND_EVENT(data->mt_win_editor, MT_CREATE_EDITOR, 0, (void *)NULL);
917 }
918 else
919 {
920 TRACE_FUNCTION ("midi_test_cc_voice_limit() : Unable to create Editor Win!");
921 }
922 return 1;
923 }
924
925 /*******************************************************************************
926
927 $Function: midi_test_play
928
929 $Description:Starts Playing a midi file
930
931 $Returns:
932
933 $Arguments:menu, menu item
934
935 *******************************************************************************/
936 GLOBAL int midi_test_play (MfwMnu* m, MfwMnuItem* i)
937 {
938 T_MFW_HND win = mfw_parent(mfw_header());
939 T_MFW_WIN * win_data = ((T_MFW_HDR *) win)->data;
940 T_MMI_MT_Editor_Data * data = (T_MMI_MT_Editor_Data *)(win_data->user);
941 T_AS_PLAYER_TYPE player_type;
942 #ifdef FF_MIDI_LOAD_FROM_MEM
943 T_MELODY melody_data;
944 #else
945 char* midi_file;
946 #endif
947
948 TRACE_FUNCTION ("midi_test_play()");
949
950 //If no file is selected inform the user
951 if(mfw_player_currently_playing_idx < 0)
952 {
953 mmi_midi_test_show_info(0, TxtMidiSelectFile, TxtNull, NULL);
954 return 1;
955
956 }
957 //flag set to 1 means we only play the currently selected file
958 mfw_player_exit_flag = PLAYER_EXIT_FLAG_TRUE;
959 //Play the midi player with high volume.
960 #ifdef FF_MIDI_RINGER
961 #ifdef FF_MIDI_LOAD_FROM_MEM
962 melody_data=sounds_midi_return_memory_location(mfw_player_currently_playing_idx);
963 player_type=mfw_ringer_deduce_player_type(melody_data.melody_name);
964 mfw_player_start_memory(player_type,(UINT32*)melody_data.melody,melody_data.melody_size,(UBYTE)AS_VOLUME_HIGH,mfw_player_playback_loop_flag,sounds_midi_player_start_cb);
965 #else
966 midi_file=sounds_midi_return_file_name(mfw_player_currently_playing_idx);
967 player_type=mfw_ringer_deduce_player_type(midi_file);
968 mfw_player_start_file(player_type,midi_file,(UBYTE)AS_VOLUME_HIGH,mfw_player_playback_loop_flag,sounds_midi_player_start_cb);
969
970 #endif
971 #endif
972 return 1;
973 }
974
975 /*******************************************************************************
976
977 $Function: midi_test_play_all
978
979 $Description:Plays all the midi files in the FFS one after the other
980
981 $Returns:
982
983 $Arguments:menu, menu item
984
985 *******************************************************************************/
986 GLOBAL int midi_test_play_all (MfwMnu* m, MfwMnuItem* i)
987 {
988 T_MFW_HND win = mfw_parent(mfw_header());
989 T_MFW_WIN * win_data = ((T_MFW_HDR *) win)->data;
990 T_MMI_MT_Editor_Data * data = (T_MMI_MT_Editor_Data *)(win_data->user);
991 T_AS_PLAYER_TYPE player_type;
992 int numberOfMelodies=0;
993 #ifdef FF_MIDI_LOAD_FROM_MEM
994 T_MELODY melody_data;
995 #else
996 char* midi_file;
997 #endif
998
999 TRACE_FUNCTION ("midi_test_play_all()");
1000 //Aug 29, 2005 REF: SPR 33999 xdeepadh
1001 //If the files are not populated, then populate the array and then playall the files.
1002 // Nov 23, 2005 REF : DR OMAPS00057378 x0039928
1003 // IsMidiInit variable decides whether to copy files from FFS to LFS
1004 if(IsMidiInit==0)
1005 {
1006 sounds_midi_init();
1007 IsMidiInit = 1;
1008 }
1009
1010 numberOfMelodies = sounds_midi_return_file_number();
1011 TRACE_EVENT_P1("numberOfMelodies for midi_test_play_all is %d",numberOfMelodies);
1012
1013 if(numberOfMelodies <= 0)
1014 {
1015 mmi_midi_test_show_info(0, TxtMidiFileNotLoaded, TxtNull, NULL);
1016 return 1 ;
1017
1018 }
1019 if(mfw_player_currently_playing_idx < 0)
1020 {
1021 //Aug 29, 2005 REF: SPR 33999 xdeepadh
1022 // When the files are not selected, the current playing index is set 0.
1023 mfw_player_currently_playing_idx = 0;
1024 }
1025 //set exit_flag to 0 to notify that we have to play all files
1026 mfw_player_exit_flag = PLAYER_EXIT_FLAG_FALSE;
1027 //Play the midi player with high volume.
1028 #ifdef FF_MIDI_RINGER
1029 #ifdef FF_MIDI_LOAD_FROM_MEM
1030 melody_data=sounds_midi_return_memory_location(mfw_player_currently_playing_idx);
1031 player_type=mfw_ringer_deduce_player_type(melody_data.melody_name);
1032 mfw_player_start_memory(player_type,(UINT32*)melody_data.melody,melody_data.melody_size,(UBYTE)AS_VOLUME_HIGH,FALSE,sounds_midi_player_start_cb);
1033 #else
1034 midi_file=sounds_midi_return_file_name(mfw_player_currently_playing_idx);
1035 player_type=mfw_ringer_deduce_player_type(midi_file);
1036 mfw_player_start_file(player_type,midi_file,(UBYTE)AS_VOLUME_HIGH,FALSE,sounds_midi_player_start_cb);
1037 #endif
1038 #endif
1039 return 1;
1040 }
1041
1042 // Dec 08, 2004 REF: CRR MMI-SPR-27284
1043 // Description: MIDI Player: Back Key malfunctions in MIDI application.
1044 // Solution: A window is created to hold list window. When the user presses Back key, the newly
1045 // created window is deleted along with list window, bringing the control back to Midi options
1046 // screen.
1047 /*******************************************************************************
1048
1049 $Function: midi_test_files_exec_cb
1050
1051 $Description: Call back function
1052
1053 $Returns: none
1054
1055 $Arguments:
1056
1057 *******************************************************************************/
1058 void midi_test_files_exec_cb (T_MFW_HND win, USHORT event, SHORT value, void * parameter)
1059 {
1060 T_MFW_WIN * win_data = ((T_MFW_HDR *) win)->data;
1061 T_mt_menu * data = (T_mt_menu *)win_data->user;
1062 SHORT mfw_midi_retVal;
1063 int line;
1064 int max_file_number;
1065 int i;
1066
1067 ListWinInfo * mnu_data = (ListWinInfo *)parameter;
1068
1069 TRACE_FUNCTION (">>>>> midi_test_files_exec_cb()");
1070
1071 switch (event)
1072 {
1073 case E_INIT:
1074
1075 TRACE_EVENT(">>>> midi_test_files_exec_cb() Event:E_INIT");
1076
1077 /* initialization of administrative data */
1078
1079 data->menu_list_data = (ListMenuData *)ALLOC_MEMORY(sizeof(ListMenuData));
1080
1081 if(data->menu_list_data == 0)
1082 {
1083 TRACE_EVENT("Failed memory alloc 1 ");
1084 return;
1085 }
1086
1087 max_file_number = sounds_midi_return_file_number();
1088 //In case no files have been loaded display info message
1089 //In case no files have been loaded return info message
1090 if(max_file_number == 0)
1091 {
1092 mmi_midi_test_show_info(0, TxtMidiFileNotLoaded, TxtNull, NULL);
1093 return;
1094 }
1095
1096
1097 data->menu_list_data->List = (T_MFW_MNU_ITEM *)ALLOC_MEMORY( max_file_number * sizeof(T_MFW_MNU_ITEM) );
1098
1099 if(data->menu_list_data->List == 0)
1100 {
1101 TRACE_EVENT("Failed memory alloc 2");
1102 return;
1103 }
1104 //Sep 29,2005 REF: SPR 34407 xdeepadh
1105 for (i = 0; i < max_file_number ; i++)
1106 {
1107 mnuInitDataItem(&data->menu_list_data->List[i]);
1108 data->menu_list_data->List[i].flagFunc = item_flag_none;
1109 //Display the midi file names in the list
1110 data->menu_list_data->List[i].str = (char *)sounds_midi_return_file_name(data->mt_file_count++);
1111 }
1112
1113 data->menu_list_data->ListLength =max_file_number;
1114 data->menu_list_data->ListPosition = 1;
1115 data->menu_list_data->CursorPosition = 1;
1116 data->menu_list_data->SnapshotSize = max_file_number;
1117 data->menu_list_data->Font = 0;
1118 data->menu_list_data->LeftSoftKey = TxtSoftSelect;
1119 data->menu_list_data->RightSoftKey = TxtSoftBack;
1120 data->menu_list_data->KeyEvents = KEY_ALL;
1121 data->menu_list_data->Reason = 0;
1122 data->menu_list_data->Strings = TRUE;
1123 data->menu_list_data->Attr = (MfwMnuAttr*)&menuMtSearchListAttr;
1124 //Apr 05, 2005 REF: ENH 29994 xdeepadh
1125 data->menu_list_data->Attr->hdrId = TxtMidiFileTitle;
1126 data->menu_list_data->autoDestroy = FALSE;
1127 listDisplayListMenu(win, data->menu_list_data,(ListCbFunc)midi_mt_menu_list_listmnu_cb,0);
1128
1129 break;
1130
1131 default:
1132 break;
1133 }
1134
1135 }
1136
1137 // Dec 08, 2004 REF: CRR MMI-SPR-27284
1138 // Description: MIDI Player: Back Key malfunctions in MIDI application.
1139 // Solution: A window is created to hold list window. When the user presses Back key, the newly
1140 // created window is deleted along with list window, bringing the control back to Midi options
1141 // screen.
1142 /*******************************************************************************
1143
1144 $Function: midi_test_files_win_cb
1145
1146 $Description: Window event handler
1147
1148 $Returns: MFW_EVENT_REJECTED:
1149 MFW_EVENT_CONSUMED:
1150
1151 $Arguments:
1152
1153 *******************************************************************************/
1154 static int midi_test_files_win_cb (MfwEvt e, MfwWin *w)
1155 {
1156 TRACE_FUNCTION ("midi_test_files_win_cb()");
1157 switch (e)
1158 {
1159 case MfwWinVisible: /* window is visible */
1160 break;
1161 case MfwWinFocussed: /* input focus / selected */
1162 case MfwWinDelete: /* window will be deleted */
1163
1164 default:
1165 return MFW_EVENT_REJECTED;
1166 }
1167 return MFW_EVENT_CONSUMED;
1168 }
1169
1170
1171 // Dec 08, 2004 REF: CRR MMI-SPR-27284
1172 // Description: MIDI Player: Back Key malfunctions in MIDI application.
1173 // Solution: A window is created to hold list window. When the user presses Back key, the newly
1174 // created window is deleted along with list window, bringing the control back to Midi options
1175 // screen.
1176 /*******************************************************************************
1177
1178 $Function: midi_test_files_browse
1179
1180 $Description: This function is called when the user selects "Browse Midi Files" option
1181
1182 $Returns: MFW_EVENT_CONSUMED
1183
1184 $Arguments:
1185
1186
1187 *******************************************************************************/
1188 GLOBAL int midi_test_files_browse( MfwMnu *m, MfwMnuItem *i )
1189 {
1190 T_MFW_HND win;
1191 T_MFW_HND parent_win = mfw_parent(mfw_header());
1192 int numberOfMelodies=0;
1193
1194 TRACE_FUNCTION ("midi_test_files_browse");
1195
1196 // Nov 23, 2005 REF : DR OMAPS00057378 x0039928
1197 // IsMidiInit variable decides whether to copy files from FFS to LFS
1198 if(IsMidiInit==0)
1199 {
1200 sounds_midi_init();
1201 IsMidiInit = 1;
1202 }
1203 // Nov 09, 2005 REF:DR OMAPS00049167 x0039928
1204 // Fix : Call the player initialize routine to set the default parameters.
1205 mfw_player_init();
1206
1207 numberOfMelodies = sounds_midi_return_file_number();
1208 TRACE_EVENT_P1("numberOfMelodies is %d",numberOfMelodies);
1209
1210 if(numberOfMelodies <= 0)
1211 {
1212 mmi_midi_test_show_info(0, TxtMidiFileNotLoaded, TxtNull, NULL);
1213
1214 }
1215 else
1216 {
1217 win = mmi_midi_test_build_Menu(parent_win);
1218 if (win NEQ NULL)
1219 {
1220 SEND_EVENT (win, E_INIT, 0, 0);
1221 }
1222
1223 }
1224 return MFW_EVENT_CONSUMED;
1225 }
1226
1227 //Sep 29,2005 REF: SPR 34407 xdeepadh
1228 /*******************************************************************************
1229
1230 $Function: mmi_midi_test_build_Menu
1231
1232 $Description: To hold list window
1233
1234 $Returns: Window handle
1235
1236 $Arguments:
1237 *******************************************************************************/
1238
1239 static T_MFW_HND mmi_midi_test_build_Menu( MfwHnd parent_window)
1240 {
1241 T_mt_menu * data = (T_mt_menu *)mfwAlloc(sizeof (T_mt_menu));
1242 T_MFW_WIN * win;
1243
1244 TRACE_FUNCTION ("mmi_midi_test_build_Menu");
1245
1246 /*
1247 * Create window handler
1248 */
1249
1250 data->win = win_create (parent_window, 0, E_WIN_VISIBLE, (T_MFW_CB)midi_test_files_win_cb);
1251 if (data->win EQ NULL)
1252 {
1253 return NULL;
1254 }
1255
1256 TRACE_EVENT("list holder window created: " );
1257 /*
1258 * connect the dialog data to the MFW-window
1259 */
1260
1261 data->mmi_control.dialog = (T_DIALOG_FUNC)midi_test_files_exec_cb;
1262 data->mmi_control.data = data;
1263 win = ((T_MFW_HDR *)data->win)->data;
1264 win->user = (void *)data;
1265 data->parent = parent_window;
1266 winShow(data->win);
1267 /*
1268 * return window handle
1269 */
1270
1271 return data->win;
1272 }
1273
1274
1275