FreeCalypso > hg > fc-magnetite
comparison src/aci2/mfw/mfw_mp3test.c @ 3:93999a60b835
src/aci2, src/condat2: import of g23m/condat source pieces from TCS211
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Mon, 26 Sep 2016 00:29:36 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
2:c41a534f33c6 | 3:93999a60b835 |
---|---|
1 /* | |
2 +--------------------------------------------------------------------+ | |
3 | PROJECT: MMI-Framework (8417) $Workfile:: mfw_mp3.c $| | |
4 | $Author:: NDH $Revision:: 1 $| | |
5 | CREATED: 21.05.04 $Modtime:: 21.05.04 14:58 $| | |
6 | STATE : code | | |
7 +--------------------------------------------------------------------+ | |
8 | |
9 MODULE : MFW_MP3 | |
10 | |
11 PURPOSE : This module contains Audio Interface functions. | |
12 | |
13 HISTORY : | |
14 Nov 16,2005 REF: DR OMAPS00049192 x0039928 | |
15 Bug:MP3: The screen is not refreshed after the mp3 file completes playing | |
16 Fix: The AUDIO_OK event recieved after mp3 file play completes is now handled | |
17 in mfw_mp3_test_start_cb() | |
18 | |
19 Nov 14, 2005 REF: OMAPS00044445 xdeepadh | |
20 Description: Implementation of Test Menu for AAC | |
21 Solution: The existing MP3 test Application has been enhanced to support the AAC file testing. | |
22 The interfaces have been made generic to support both MP3 and AAC files. | |
23 | |
24 Nov 24,2005 REF: DR OMAPS00049192 x0039928 | |
25 Bug:MP3: The screen is not refreshed after the mp3 file completes playing | |
26 Soln: A variable mfw_mp3_playstate is added to maintain the mfw play state. | |
27 | |
28 Nov 16,2005 REF: DR OMAPS00049192 x0039928 | |
29 Bug:MP3: The screen is not refreshed after the mp3 file completes playing | |
30 Fix: The AUDIO_OK event recieved after mp3 file play completes is now handled | |
31 in mfw_mp3_test_start_cb() | |
32 | |
33 Aug 05, 2005 xdeepadh | |
34 Description: Configuring the audio path for midi | |
35 | |
36 | |
37 Jul 18, 2005 REF: SPR 31695 xdeepadh | |
38 Bug:Problems with MP3 test application | |
39 Fix:The window handling of MP3 Test Application has been done properly. | |
40 | |
41 Apr 06, 2005 REF: ENH 30011 xdeepadh | |
42 Description: Replacing the Test Application compilation flags with new flags. | |
43 Solution: Removed the Condition to call mp3 APIs, if L1_MP3 flag is enabled. | |
44 This file will be compiled only if L1_Mp3 flag is enabled. | |
45 */ | |
46 | |
47 | |
48 /* | |
49 ** Include Files | |
50 */ | |
51 | |
52 #define ENTITY_MFW | |
53 | |
54 /* includes */ | |
55 #include <string.h> | |
56 | |
57 #include "typedefs.h" | |
58 #include "rv_swe.h" | |
59 #include "l1sw.cfg" | |
60 | |
61 #include "rvm/rvm_gen.h" /* Generic RVM types and functions. */ | |
62 #include "rvf/rvf_pool_size.h" /* Stack & Memory Bank sizes definitions */ | |
63 #include "mfw_mfw.h" | |
64 #include "mfw_mp3test.h" | |
65 #include "mfw_sys.h" //Added for Trace functions. Jul 18, 2005 REF: SPR 31695 xdeepadh | |
66 #include "Audio/audio_api.h" | |
67 | |
68 #include "ffs/ffs_api.h" | |
69 | |
70 /*Local defines*/ | |
71 | |
72 //define maximum number of MP3 files being saved | |
73 #define PLAYER_MAX_FILES 5 | |
74 #define PLAYER_DIR "/mmi/mp3" | |
75 | |
76 /* | |
77 ** Local Variable Definitions | |
78 */ | |
79 | |
80 static T_RV_RETURN_PATH audio_player_return_path; | |
81 char* INPUT_FILES_STRING[PLAYER_MAX_FILES]; | |
82 int NUM_INPUT_FILES; | |
83 | |
84 T_AUDIO_MP3_PARAMETER mp3_parameter; | |
85 #ifdef FF_MMI_TEST_AAC | |
86 T_AUDIO_AAC_PARAMETER aac_parameter; | |
87 #endif | |
88 | |
89 #ifdef FF_MMI_AUDIO_PROFILE | |
90 //Flag to indicate whether audio media is being played. | |
91 extern UBYTE mfwAudPlay; | |
92 #endif | |
93 | |
94 //Nov 16,2005 REF: DR OMAPS00049192 x0039928 | |
95 MMI_RETURN_PATH mmi_audio_player_return_path; | |
96 | |
97 //Nov 24,2005 REF: DR OMAPS00049192 x0039928 | |
98 // Declare a variable to maintain the mp3 play state | |
99 int mfw_mp3_playstate = FALSE; | |
100 | |
101 char* inputFileName; // input file | |
102 char tempFilePath[AUDIO_MP3_PATH_NAME_MAX_SIZE]; | |
103 int audio_player_currently_playing_idx = -1; //index of file to play | |
104 UBYTE IsMP3On; //Variable to check the selected file | |
105 | |
106 /* | |
107 Function Prototypes | |
108 */ | |
109 static void mfw_audio_player_configure_callback_fn(void (*callback_fn)(void *)); | |
110 | |
111 | |
112 /* | |
113 ** Public function Definitions | |
114 */ | |
115 /******************************************************************************* | |
116 | |
117 $Function: mfw_audio_player_populate_files | |
118 | |
119 $Description:This function is called in order to retrieve file names from | |
120 Flash and save them in a table | |
121 | |
122 $Returns: Status | |
123 | |
124 $Arguments: filenames: table to save file names in | |
125 max_files_count:number of files in the list to be filled . | |
126 | |
127 *******************************************************************************/ | |
128 int mfw_audio_player_populate_files(char **file_names, int max_files_count) | |
129 { | |
130 T_FFS_FD fd = 0; | |
131 char dir_name_p[] = PLAYER_DIR; | |
132 T_FFS_DIR dir = {0}; | |
133 char dest_name_p[100] = ""; | |
134 int i, files_count = 0; | |
135 char *fileExt; | |
136 | |
137 if (ffs_opendir (dir_name_p, &dir) <= 0) | |
138 { | |
139 files_count = 0; | |
140 } | |
141 | |
142 //read maximum of 5 file names | |
143 for (i = 0; ffs_readdir (&dir, dest_name_p, 100) > 0x0; i++) | |
144 { | |
145 (file_names[files_count]) = (char*)mfwAlloc(strlen(dest_name_p) + 1); | |
146 | |
147 if(file_names[files_count] != NULL) | |
148 { | |
149 // Jul 18, 2005 REF: SPR 31695 xdeepadh | |
150 //retrieve file extension | |
151 fileExt =(char*) mfw_audio_player_GetExtension(dest_name_p); | |
152 //Store only mp3 and aac file names in array | |
153 if ( strcmp(fileExt, "mp3")== 0 ) | |
154 { | |
155 strcpy (file_names[files_count], dest_name_p); | |
156 files_count++; | |
157 } | |
158 #ifdef FF_MMI_TEST_AAC | |
159 if ( strcmp(fileExt, "aac") == 0) | |
160 { | |
161 strcpy (file_names[files_count], dest_name_p); | |
162 files_count++; | |
163 } | |
164 #endif | |
165 if(files_count >= max_files_count) | |
166 break; | |
167 } | |
168 else | |
169 { | |
170 //files_count = 0; | |
171 } | |
172 | |
173 } | |
174 return files_count; | |
175 } | |
176 | |
177 | |
178 /******************************************************************************* | |
179 | |
180 $Function: mfw_audio_player_init | |
181 | |
182 $Description:Populate the Player array | |
183 | |
184 $Returns: Status | |
185 | |
186 $Arguments: None | |
187 | |
188 *******************************************************************************/ | |
189 void mfw_audio_player_init(void) | |
190 { | |
191 NUM_INPUT_FILES = mfw_audio_player_populate_files(INPUT_FILES_STRING, PLAYER_MAX_FILES); | |
192 mp3_parameter.mono_stereo = AUDIO_MP3_MONO; | |
193 #ifdef FF_MMI_TEST_AAC | |
194 aac_parameter.mono_stereo= AUDIO_AAC_MONO; | |
195 #endif | |
196 } | |
197 | |
198 /******************************************************************************* | |
199 | |
200 $Function: mfw_audio_player_set_channel_mono | |
201 | |
202 $Description:set channel to mono | |
203 | |
204 $Returns: Status | |
205 | |
206 $Arguments: None | |
207 | |
208 *******************************************************************************/ | |
209 SHORT mfw_audio_player_set_channel_mono(void) | |
210 { | |
211 TRACE_FUNCTION("mfw_audio_player_set_channel_mono"); | |
212 | |
213 switch(IsMP3On) | |
214 { | |
215 case MFW_PLAYER_MP3: | |
216 TRACE_EVENT("MP3"); | |
217 mp3_parameter.mono_stereo = AUDIO_MP3_MONO; | |
218 break; | |
219 | |
220 #ifdef FF_MMI_TEST_AAC | |
221 case MFW_PLAYER_AAC: | |
222 TRACE_EVENT("AAC"); | |
223 aac_parameter.mono_stereo= AUDIO_AAC_MONO; | |
224 break; | |
225 #endif | |
226 default: | |
227 break; | |
228 } | |
229 | |
230 return MFW_PLAYER_TEST_OK; | |
231 } | |
232 | |
233 | |
234 /******************************************************************************* | |
235 | |
236 $Function: mfw_audio_player_set_channel_stereo | |
237 | |
238 $Description:set channel to stereo | |
239 | |
240 $Returns: Status | |
241 | |
242 $Arguments: None | |
243 | |
244 *******************************************************************************/ | |
245 SHORT mfw_audio_player_set_channel_stereo(void) | |
246 { | |
247 TRACE_FUNCTION("mfw_audio_player_set_channel_stereo"); | |
248 | |
249 switch(IsMP3On) | |
250 { | |
251 case MFW_PLAYER_MP3: | |
252 TRACE_EVENT("MP3"); | |
253 mp3_parameter.mono_stereo = AUDIO_MP3_STEREO; | |
254 break; | |
255 | |
256 #ifdef FF_MMI_TEST_AAC | |
257 case MFW_PLAYER_AAC: | |
258 TRACE_EVENT("AAC"); | |
259 aac_parameter.mono_stereo= AUDIO_AAC_STEREO; | |
260 break; | |
261 #endif | |
262 default: | |
263 break; | |
264 } | |
265 | |
266 return MFW_PLAYER_TEST_OK; | |
267 } | |
268 | |
269 | |
270 | |
271 | |
272 /******************************************************************************* | |
273 | |
274 $Function: mfw_audio_player_mp3_start_cb | |
275 | |
276 $Description:callback function for starting mp3 file | |
277 | |
278 $Returns: None | |
279 | |
280 $Arguments: parameter: callback parameter | |
281 | |
282 *******************************************************************************/ | |
283 static void mfw_audio_player_mp3_start_cb (void *parameter) | |
284 { | |
285 //Nov 16,2005 REF: DR OMAPS00049192 x0039928 | |
286 T_AUDIO_MP3_STATUS *param = (T_AUDIO_MP3_STATUS *)parameter; | |
287 SHORT event = param->status; | |
288 UINT32 msg = param->os_hdr.msg_id; | |
289 switch(event) | |
290 { | |
291 // MMI callback function is called to destroy the focus window when AUDIO_OK | |
292 // event is recieved for mp3 file play complete | |
293 case AUDIO_OK: | |
294 if((mfw_mp3_playstate == TRUE) && (msg == AUDIO_MP3_STATUS_MSG)) | |
295 (* mmi_audio_player_return_path.callback)(mmi_audio_player_return_path.focus_win); | |
296 break; | |
297 default: | |
298 break; | |
299 } | |
300 } | |
301 | |
302 | |
303 /******************************************************************************* | |
304 | |
305 $Function: mfw_audio_player_aac_start_cb | |
306 | |
307 $Description:callback function for starting aac file | |
308 | |
309 $Returns: None | |
310 | |
311 $Arguments: parameter: callback parameter | |
312 | |
313 *******************************************************************************/ | |
314 #ifdef FF_MMI_TEST_AAC | |
315 static void mfw_audio_player_aac_start_cb(void *parameter) | |
316 { | |
317 //Nov 16,2005 REF: DR OMAPS00049192 x0039928 | |
318 T_AUDIO_AAC_STATUS *param = (T_AUDIO_AAC_STATUS *)parameter; | |
319 SHORT event = param->status; | |
320 UINT32 msg = param->os_hdr.msg_id; | |
321 switch(event) | |
322 { | |
323 // MMI callback function is called to destroy the focus window when AUDIO_OK | |
324 // event is recieved for mp3 file play complete | |
325 case AUDIO_OK: | |
326 if((mfw_mp3_playstate == TRUE) &&(msg == AUDIO_AAC_STATUS_MSG)) | |
327 (* mmi_audio_player_return_path.callback)(mmi_audio_player_return_path.focus_win); | |
328 break; | |
329 default: | |
330 break; | |
331 } | |
332 } | |
333 #endif | |
334 | |
335 /******************************************************************************* | |
336 | |
337 $Function: mfw_audio_player_configure_callback_fn | |
338 | |
339 $Description:Configure the Riviera Return Path | |
340 | |
341 $Returns:None | |
342 | |
343 $Arguments: callback function | |
344 | |
345 *******************************************************************************/ | |
346 | |
347 static void mfw_audio_player_configure_callback_fn(void (*callback_fn)(void *)) | |
348 { | |
349 audio_player_return_path.addr_id = 0; | |
350 audio_player_return_path.callback_func = callback_fn; | |
351 | |
352 return; | |
353 } | |
354 | |
355 | |
356 | |
357 /******************************************************************************* | |
358 | |
359 $Function: mfw_audio_player_play | |
360 | |
361 $Description:play the file which was loaded | |
362 When no file was manually selected, play file located at first index by default | |
363 | |
364 $Returns:Status | |
365 | |
366 $Arguments: None | |
367 | |
368 *******************************************************************************/ | |
369 SHORT mfw_audio_player_play(void) | |
370 { | |
371 | |
372 SHORT mfw_audio_player_retVal; | |
373 TRACE_FUNCTION("mfw_audio_player_play"); | |
374 | |
375 //Aug 05, 2005 xdeepadh | |
376 #ifdef FF_MMI_AUDIO_PROFILE | |
377 //Configure the audio path to current Audio device. | |
378 mfw_set_stereo_path(mfw_get_current_audioDevice()); | |
379 mfwAudPlay = TRUE; //File is playing | |
380 #endif | |
381 //Nov 24,2005 REF: DR OMAPS00049192 x0039928 | |
382 // Set mp3 play state to True | |
383 mfw_mp3_playstate = TRUE; | |
384 | |
385 | |
386 //Based on the file selected, call the respective APIS to start playing | |
387 switch(IsMP3On) | |
388 { | |
389 case MFW_PLAYER_MP3 : | |
390 sprintf(tempFilePath,"%s/%s",PLAYER_DIR, inputFileName); | |
391 strcpy(mp3_parameter.mp3_name, tempFilePath); | |
392 mfw_audio_player_configure_callback_fn(mfw_audio_player_mp3_start_cb); | |
393 | |
394 if (audio_mp3_start(&mp3_parameter, audio_player_return_path)) | |
395 { | |
396 mfw_audio_player_retVal = MFW_PLAYER_TEST_OK; | |
397 } | |
398 else | |
399 { | |
400 mfw_audio_player_retVal = MFW_PLAYER_TEST_RIVIERA_FAILED; | |
401 } | |
402 break; | |
403 | |
404 #ifdef FF_MMI_TEST_AAC | |
405 | |
406 case MFW_PLAYER_AAC: | |
407 sprintf(tempFilePath,"%s/%s",PLAYER_DIR, inputFileName); | |
408 strcpy(aac_parameter.aac_name, tempFilePath); | |
409 mfw_audio_player_configure_callback_fn(mfw_audio_player_aac_start_cb); | |
410 | |
411 if (audio_aac_start(&aac_parameter, audio_player_return_path)) | |
412 { | |
413 mfw_audio_player_retVal = MFW_PLAYER_TEST_OK; | |
414 } | |
415 else | |
416 { | |
417 mfw_audio_player_retVal = MFW_PLAYER_TEST_RIVIERA_FAILED; | |
418 } | |
419 break; | |
420 #endif | |
421 default: | |
422 break; | |
423 } | |
424 return mfw_audio_player_retVal; | |
425 } | |
426 | |
427 | |
428 | |
429 /******************************************************************************* | |
430 | |
431 $Function: mfw_audio_player_stop | |
432 | |
433 $Description:stop the file which was played | |
434 | |
435 $Returns:Status | |
436 | |
437 $Arguments: None | |
438 | |
439 *******************************************************************************/ | |
440 SHORT mfw_audio_player_stop(void) | |
441 { | |
442 | |
443 SHORT mfw_audio_player_retVal; | |
444 UINT32 size_played; | |
445 // Aug 05, 2005 xdeepadh | |
446 #ifdef FF_MMI_AUDIO_PROFILE | |
447 //configure the audio to voice path | |
448 mfwAudPlay = FALSE; | |
449 mfw_unset_stereo_path(mfw_get_current_audioDevice()); | |
450 #endif | |
451 TRACE_FUNCTION("mfw_audio_player_stop"); | |
452 // Nov 24, 2005 REF : DR OMAPS00049192 x0039928 | |
453 // Set mp3 play state to false | |
454 mfw_mp3_playstate = FALSE; | |
455 | |
456 //Based on the file selected, call the respective APIS to stop playing | |
457 switch(IsMP3On) | |
458 { | |
459 case MFW_PLAYER_MP3 : | |
460 if (audio_mp3_stop(&size_played)) | |
461 { | |
462 mfw_audio_player_retVal = MFW_PLAYER_TEST_OK; | |
463 } | |
464 else | |
465 { | |
466 mfw_audio_player_retVal = MFW_PLAYER_TEST_RIVIERA_FAILED; | |
467 } | |
468 break; | |
469 | |
470 #ifdef FF_MMI_TEST_AAC | |
471 case MFW_PLAYER_AAC: | |
472 if(audio_aac_stop(&size_played)) | |
473 { | |
474 mfw_audio_player_retVal = MFW_PLAYER_TEST_OK; | |
475 } | |
476 else | |
477 { | |
478 mfw_audio_player_retVal = MFW_PLAYER_TEST_RIVIERA_FAILED; | |
479 } | |
480 break; | |
481 #endif | |
482 default: | |
483 break; | |
484 } | |
485 | |
486 return mfw_audio_player_retVal; | |
487 } | |
488 | |
489 /******************************************************************************* | |
490 | |
491 $Function: mfw_audio_player_pause | |
492 $Description:pause the file which was played | |
493 $Returns:Status | |
494 | |
495 $Arguments: None | |
496 | |
497 *******************************************************************************/ | |
498 SHORT mfw_audio_player_pause(void) | |
499 { | |
500 SHORT mfw_audio_player_retVal; | |
501 | |
502 TRACE_FUNCTION("mfw_audio_player_pause"); | |
503 //Based on the file selected, call the respective APIS to pause playing | |
504 switch(IsMP3On) | |
505 { | |
506 case MFW_PLAYER_MP3 : | |
507 if (audio_mp3_pause()) | |
508 { | |
509 mfw_audio_player_retVal = MFW_PLAYER_TEST_OK; | |
510 } | |
511 else | |
512 { | |
513 mfw_audio_player_retVal = MFW_PLAYER_TEST_RIVIERA_FAILED; | |
514 } | |
515 break; | |
516 | |
517 #ifdef FF_MMI_TEST_AAC | |
518 case MFW_PLAYER_AAC: | |
519 if (audio_aac_pause()) | |
520 { | |
521 mfw_audio_player_retVal = MFW_PLAYER_TEST_OK; | |
522 } | |
523 else | |
524 { | |
525 mfw_audio_player_retVal = MFW_PLAYER_TEST_RIVIERA_FAILED; | |
526 } | |
527 break; | |
528 #endif | |
529 default: | |
530 break; | |
531 } | |
532 return mfw_audio_player_retVal; | |
533 } | |
534 | |
535 | |
536 | |
537 /******************************************************************************* | |
538 | |
539 $Function: mfw_audio_player_resume | |
540 | |
541 $Description:resume the file which was played | |
542 $Returns:Status | |
543 | |
544 $Arguments: None | |
545 | |
546 *******************************************************************************/ | |
547 SHORT mfw_audio_player_resume(void) | |
548 { | |
549 SHORT mfw_audio_player_retVal; | |
550 | |
551 TRACE_FUNCTION("mfw_audio_player_resume"); | |
552 //Based on the file selected, call the respective APIS to resume playing | |
553 switch(IsMP3On) | |
554 { | |
555 case MFW_PLAYER_MP3 : | |
556 if (audio_mp3_resume()) | |
557 { | |
558 mfw_audio_player_retVal = MFW_PLAYER_TEST_OK; | |
559 } | |
560 else | |
561 { | |
562 mfw_audio_player_retVal = MFW_PLAYER_TEST_RIVIERA_FAILED; | |
563 } | |
564 break; | |
565 | |
566 #ifdef FF_MMI_TEST_AAC | |
567 case MFW_PLAYER_AAC: | |
568 if (audio_aac_resume()) | |
569 { | |
570 mfw_audio_player_retVal = MFW_PLAYER_TEST_OK; | |
571 } | |
572 else | |
573 { | |
574 mfw_audio_player_retVal = MFW_PLAYER_TEST_RIVIERA_FAILED; | |
575 } | |
576 break; | |
577 #endif | |
578 default: | |
579 break; | |
580 } | |
581 return mfw_audio_player_retVal; | |
582 } | |
583 | |
584 /******************************************************************************* | |
585 | |
586 $Function: mfw_audio_player_return_file_number | |
587 | |
588 $Description:resume the file which was played | |
589 $Returns:Status | |
590 | |
591 $Arguments: None | |
592 | |
593 *******************************************************************************/ | |
594 int mfw_audio_player_return_file_number(void) | |
595 { | |
596 return NUM_INPUT_FILES; | |
597 } | |
598 | |
599 /******************************************************************************* | |
600 | |
601 $Function: mfw_audio_player_return_file_name | |
602 | |
603 $Description: return file name given an input index | |
604 $Returns:file name of the selected index | |
605 | |
606 $Arguments: index | |
607 | |
608 *******************************************************************************/ | |
609 char* mfw_audio_player_return_file_name(int index) | |
610 { | |
611 return INPUT_FILES_STRING[index]; | |
612 } | |
613 | |
614 | |
615 /******************************************************************************* | |
616 | |
617 $Function: mfw_audio_player_save_selected_file_idx | |
618 | |
619 $Description:return file name given an input index | |
620 $Returns:status | |
621 | |
622 $Arguments: index | |
623 | |
624 *******************************************************************************/ | |
625 | |
626 SHORT mfw_audio_player_save_selected_file_idx(int index) | |
627 { | |
628 //default index is set to 0 and inputFileName to NULL at mp3 mfw initialisation | |
629 //save currently selected file to control block | |
630 audio_player_currently_playing_idx = index; | |
631 inputFileName = INPUT_FILES_STRING[index]; | |
632 return MFW_PLAYER_TEST_OK; | |
633 | |
634 } | |
635 // Jul 18, 2005 REF: SPR 31695 xdeepadh | |
636 | |
637 /******************************************************************************* | |
638 | |
639 $Function: mfw_audio_player_GetExtension | |
640 | |
641 $Description: public function to retrieve the extension of a file | |
642 | |
643 $Returns:Extention of the filename | |
644 | |
645 $Arguments: scr- Filename | |
646 | |
647 *******************************************************************************/ | |
648 char *mfw_audio_player_GetExtension(char *src) | |
649 { | |
650 int i; | |
651 TRACE_FUNCTION("mfw_audio_player_GetExtension"); | |
652 for(i = 0; i < strlen(src); i++){ | |
653 if(src[i] == '.'){ | |
654 return (src+i+1); | |
655 } | |
656 } | |
657 return (src+i); | |
658 } | |
659 | |
660 |