FreeCalypso > hg > tcs211-l1-reconst
comparison g23m/condat/ms/src/mfw/mfw_midi.c @ 0:509db1a7b7b8
initial import: leo2moko-r1
author | Space Falcon <falcon@ivan.Harhan.ORG> |
---|---|
date | Mon, 01 Jun 2015 03:24:05 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:509db1a7b7b8 |
---|---|
1 /* | |
2 +--------------------------------------------------------------------+ | |
3 | PROJECT: MMI-Framework (8417) $Workfile:: mfw_midi.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_MIDI | |
10 | |
11 PURPOSE : This module contains Midi Riveria Interface functions. | |
12 | |
13 HISTORY : | |
14 | |
15 Nov 21, 2005 REF:ER OMAPS00057430 nekkareb | |
16 Description: AAC Ringer Implementation | |
17 Solution: The Midi Ringer application has been enhanced to support AAC as ringer. | |
18 | |
19 Nov 23, 2005 REF : DR OMAPS00057378 x0039928 | |
20 Bug: All MIDI files are not displayed in MMI in locosto-lite | |
21 Fix: Buffer memory allocated to copy the file contents is freed | |
22 properly and copying file from FFS to LFS is not terminated if error is | |
23 returned for just any one file, instead it tries to copy other files. | |
24 | |
25 Nov 09, 2005 REF:DR OMAPS00049167 x0039928 | |
26 Description: The midi files cannot be heard if the audio channel selected is 'Mono' | |
27 Solution: Midi Player params are made global so that settings are retained across. | |
28 | |
29 Nov 04, 2005 REF:DRT OMAPS00053737 xdeepadh | |
30 Description: MIDI Ringer Linear Flash Support. | |
31 Solution: The Midi Ringer application has been enhanced to loadand play the midi files from LFS. | |
32 | |
33 Nov 02, 2005 REF:ER OMAPS00039044 xdeepadh | |
34 Description: Mp3 Ringer Implementation | |
35 Solution: The Midi Ringer application has been enhanced to support mp3 as ringer. | |
36 The interface function names have been modified. | |
37 | |
38 Aug 17, 2005 REF: CHG 33822 xdeepadh | |
39 Description: Configuring the Audio path from Midi Test Application Menu | |
40 Solution: Loading the audio profile for headset and handheld. | |
41 | |
42 Aug 05, 2005 xdeepadh | |
43 Description: Configuring the audio path for midi | |
44 | |
45 Apr 05, 2005 REF: ENH 29994 xdeepadh | |
46 Description: Implementation of Generic Midi Ringer and Modification of existing Midi Test Application | |
47 Solution: Generic Midi Ringer and Midi Test Application were implemented. | |
48 | |
49 */ | |
50 | |
51 #define ENTITY_MFW | |
52 /* | |
53 ** Include Files | |
54 */ | |
55 | |
56 #include "rv_swe.h" | |
57 | |
58 /* includes */ | |
59 #include <string.h> | |
60 #include "typedefs.h" | |
61 #include "mfw_midi.h" | |
62 #include "mfw_mfw.h" | |
63 #include "mfw_sys.h" | |
64 #ifdef FF_MMI_AUDIO_PROFILE | |
65 #include "mfw_mme.h" | |
66 #endif | |
67 //Nov 04, 2005 REF:DRT OMAPS00053737 xdeepadh | |
68 #ifdef FF_MIDI_LOAD_FROM_LFS | |
69 #include "ffs/ffs_api.h" | |
70 #endif //FF_MIDI_LOAD_FROM_LFS | |
71 | |
72 /*Local defines*/ | |
73 | |
74 #define MIDI_FIRST_FILE_INDEX 0 | |
75 #define MIDI_MAX_FILES 10 | |
76 /// Maximum length of the audio data filename (excluded EOS character). | |
77 #define FILENAME_MAX_LEN 47 | |
78 /* | |
79 ** Local Variable Definitions | |
80 */ | |
81 static T_RV_RETURN_PATH midi_return_path; | |
82 | |
83 /* Global variables*/ | |
84 int mfw_player_currently_playing_idx=-1; | |
85 UBYTE mfw_player_exit_flag=PLAYER_EXIT_FLAG_TRUE; | |
86 UBYTE mfw_player_playback_loop_flag=FALSE; | |
87 //Aug 05, 2005 xdeepadh | |
88 #ifdef FF_MMI_AUDIO_PROFILE | |
89 //Flag to indicate whether audio media is being played. | |
90 extern UBYTE mfwAudPlay; | |
91 extern void mfw_audio_set_device(int type); | |
92 #endif //FF_MMI_AUDIO_PROFILE | |
93 | |
94 // Nov 09, 2005 REF:DR OMAPS00049167 x0039928 | |
95 // Fix : Declare player_para as global variable. | |
96 #ifdef FF_MMI_TEST_MIDI | |
97 T_AS_PLAYER_PARAMS player_para; | |
98 #endif | |
99 | |
100 /* | |
101 ** Public function Definitions | |
102 */ | |
103 | |
104 /******************************************************************************* | |
105 | |
106 $Function: mfw_player_init | |
107 | |
108 $Description: initialize global variables | |
109 | |
110 $Returns: | |
111 | |
112 $Arguments: | |
113 | |
114 *******************************************************************************/ | |
115 void mfw_player_init(void) | |
116 { | |
117 // Nov 09, 2005 REF:DR OMAPS00049167 x0039928 | |
118 // Fix : Initialize the player parameter to the default values. | |
119 #ifdef FF_MMI_TEST_MIDI | |
120 TRACE_FUNCTION("mfw_player_init"); | |
121 player_para.midi.output_channels = MIDI_CHANNEL_MONO; | |
122 player_para.midi.voice_limit = FF_MIDI_VOICE_LIMIT; | |
123 as_player_set_params(AS_PLAYER_TYPE_MIDI,&player_para); | |
124 #endif | |
125 } | |
126 | |
127 /* | |
128 ** Public function Definitions | |
129 */ | |
130 | |
131 /******************************************************************************* | |
132 | |
133 $Function: mfw_player_set_loop_on | |
134 | |
135 $Description: Sets the playback of the midi file in loop on mode(repeat). | |
136 | |
137 $Returns: MFW_PLAYER_TEST_OK | |
138 | |
139 $Arguments: None | |
140 | |
141 *******************************************************************************/ | |
142 SHORT mfw_player_set_loop_on(void) | |
143 { | |
144 TRACE_FUNCTION("mfw_player_set_loop_on"); | |
145 mfw_player_playback_loop_flag = TRUE; | |
146 return MFW_PLAYER_TEST_OK; | |
147 } | |
148 | |
149 | |
150 /******************************************************************************* | |
151 | |
152 $Function: mfw_player_set_loop_off | |
153 | |
154 $Description: Sets the playback of the midi file in loop off mode(once) | |
155 | |
156 $Returns: MFW_PLAYER_TEST_OK | |
157 | |
158 $Arguments: None | |
159 | |
160 *******************************************************************************/ | |
161 SHORT mfw_player_set_loop_off(void) | |
162 { | |
163 TRACE_FUNCTION("mfw_player_set_loop_off"); | |
164 mfw_player_playback_loop_flag = FALSE; | |
165 return MFW_PLAYER_TEST_OK; | |
166 } | |
167 | |
168 | |
169 | |
170 /******************************************************************************* | |
171 | |
172 $Function: mfw_player_set_channel_mono | |
173 | |
174 $Description:Sets the channel to mono | |
175 | |
176 $Returns: MFW_PLAYER_TEST_OK | |
177 | |
178 $Arguments: None | |
179 | |
180 *******************************************************************************/ | |
181 SHORT mfw_player_set_channel_mono(void) | |
182 { | |
183 #ifdef FF_MMI_TEST_MIDI | |
184 T_AS_RET player_return; | |
185 TRACE_EVENT("mfw_player_set_channel_mono"); | |
186 player_para.midi.output_channels=MIDI_CHANNEL_MONO; | |
187 player_return=as_player_set_params(AS_PLAYER_TYPE_MIDI,&player_para); | |
188 if(player_return==AS_OK) | |
189 return MFW_PLAYER_TEST_OK; | |
190 #else | |
191 return MFW_PLAYER_TEST_OK; | |
192 | |
193 #endif | |
194 } | |
195 | |
196 | |
197 /******************************************************************************* | |
198 | |
199 $Function: mfw_player_set_channel_stereo | |
200 | |
201 $Description:Sets channel to stereo | |
202 | |
203 $Returns: MFW_PLAYER_TEST_OK | |
204 | |
205 $Arguments: None | |
206 | |
207 *******************************************************************************/ | |
208 SHORT mfw_player_set_channel_stereo(void) | |
209 { | |
210 #ifdef FF_MMI_TEST_MIDI | |
211 T_AS_RET player_return; | |
212 TRACE_EVENT("mfw_player_set_channel_stereo"); | |
213 player_para.midi.output_channels=MIDI_CHANNEL_STEREO; | |
214 player_return=as_player_set_params(AS_PLAYER_TYPE_MIDI,&player_para); | |
215 if(player_return==AS_OK) | |
216 return MFW_PLAYER_TEST_OK; | |
217 #else | |
218 return MFW_PLAYER_TEST_OK; | |
219 | |
220 #endif | |
221 } | |
222 | |
223 /******************************************************************************* | |
224 | |
225 $Function: mfw_player_midi_set_voice_limit | |
226 | |
227 $Description: Sets the voicelimit | |
228 | |
229 $Returns: MFW_PLAYER_TEST_OK | |
230 | |
231 $Arguments: voice_limit:The voice limit to be set | |
232 | |
233 *******************************************************************************/ | |
234 SHORT mfw_player_midi_set_voice_limit(int voice_limit) | |
235 { | |
236 #ifdef FF_MMI_TEST_MIDI | |
237 T_AS_RET player_return; | |
238 TRACE_EVENT_P1("mfw_player_midi_set_voice_limit is %d",voice_limit); | |
239 player_para.midi.voice_limit=voice_limit; | |
240 player_return=as_player_set_params(AS_PLAYER_TYPE_MIDI,&player_para); | |
241 if(player_return==AS_OK) | |
242 return MFW_PLAYER_TEST_OK; | |
243 #else | |
244 return MFW_PLAYER_TEST_OK; | |
245 #endif | |
246 } | |
247 | |
248 /******************************************************************************* | |
249 | |
250 $Function: mfw_player_save_selected_file_idx | |
251 | |
252 $Description: save index of file which have been selected | |
253 | |
254 $Returns: MFW_PLAYER_TEST_OK | |
255 | |
256 $Arguments: index: index to be saved | |
257 | |
258 *******************************************************************************/ | |
259 SHORT mfw_player_save_selected_file_idx(int index) | |
260 { | |
261 //default index is set to 0 and inputFileName to NULL at global initialisation | |
262 //save current index of selected file | |
263 TRACE_EVENT_P1("mfw_player_save_selected_file_idx is %d",index); | |
264 mfw_player_currently_playing_idx = index; | |
265 return MFW_PLAYER_TEST_OK; | |
266 | |
267 } | |
268 | |
269 /******************************************************************************* | |
270 | |
271 $Function: mfw_player_set_speaker | |
272 | |
273 $Description:Sets the player_device to Speaker | |
274 | |
275 | |
276 $Returns: MFW_PLAYER_TEST_OK | |
277 | |
278 $Arguments: None | |
279 | |
280 *******************************************************************************/ | |
281 SHORT mfw_player_set_speaker() | |
282 { | |
283 #ifdef FF_MMI_TEST_MIDI | |
284 // Aug 17, 2005 REF: CHG 33822 xdeepadh | |
285 //Load the profile for the Handheld. | |
286 #ifdef FF_MMI_AUDIO_PROFILE | |
287 mfw_audio_set_device(MFW_AUD_HANDHELD); | |
288 return MFW_PLAYER_TEST_OK ; | |
289 #else | |
290 T_AS_RET player_return; | |
291 TRACE_EVENT("mfw_player_set_speaker"); | |
292 player_para.common.output_device=AS_DEVICE_SPEAKER; | |
293 player_return=as_player_set_params(AS_PLAYER_TYPE_COMMON,&player_para); | |
294 if(player_return==AS_OK) | |
295 return MFW_PLAYER_TEST_OK ; | |
296 | |
297 #endif //FF_MMI_AUDIO_PROFILE | |
298 | |
299 #else | |
300 return MFW_PLAYER_TEST_OK; | |
301 | |
302 #endif //FF_MMI_TEST_MIDI | |
303 } | |
304 /******************************************************************************* | |
305 | |
306 $Function: mfw_player_set_headset | |
307 | |
308 $Description:Sets the player_device to Headset | |
309 | |
310 $Returns: MFW_PLAYER_TEST_OK | |
311 | |
312 $Arguments: None | |
313 | |
314 *******************************************************************************/ | |
315 SHORT mfw_player_set_headset() | |
316 { | |
317 #ifdef FF_MMI_TEST_MIDI | |
318 // Aug 17, 2005 REF: CHG 33822 xdeepadh | |
319 //Load the profile for the Headset. | |
320 #ifdef FF_MMI_AUDIO_PROFILE | |
321 mfw_audio_set_device(MFW_AUD_HEADSET); | |
322 return MFW_PLAYER_TEST_OK ; | |
323 #else | |
324 T_AS_RET player_return; | |
325 TRACE_EVENT("mfw_player_set_headset"); | |
326 player_para.common.output_device=AS_DEVICE_HEADSET; | |
327 player_return=as_player_set_params(AS_PLAYER_TYPE_COMMON,&player_para); | |
328 if(player_return==AS_OK) | |
329 return MFW_PLAYER_TEST_OK ; | |
330 #endif //FF_MMI_AUDIO_PROFILE | |
331 #else | |
332 return MFW_PLAYER_TEST_OK; | |
333 | |
334 #endif //FF_MMI_TEST_MIDI | |
335 } | |
336 | |
337 #ifdef FF_MIDI_RINGER | |
338 //Nov 02, 2005 REF:ER OMAPS00039044 xdeepadh | |
339 //The function names have been modified to be generic | |
340 /******************************************************************************* | |
341 | |
342 $Function: mfw_ringer_set_audiopath | |
343 | |
344 $Description:Sets the player_device to Speaker | |
345 | |
346 | |
347 $Returns: MFW_PLAYER_TEST_OK | |
348 | |
349 $Arguments: None | |
350 | |
351 *******************************************************************************/ | |
352 SHORT mfw_ringer_set_audiopath() | |
353 { | |
354 #ifdef FF_MMI_TEST_MIDI | |
355 T_AS_RET player_return; | |
356 TRACE_EVENT("mfw_ringer_set_audiopath"); | |
357 player_para.common.output_device=AS_DEVICE_SPEAKER; | |
358 player_return=as_player_set_params(AS_PLAYER_TYPE_COMMON,&player_para); | |
359 if(player_return==AS_OK) | |
360 return MFW_PLAYER_TEST_OK ; | |
361 #else | |
362 return MFW_PLAYER_TEST_OK; | |
363 | |
364 #endif | |
365 } | |
366 /******************************************************************************* | |
367 | |
368 $Function: mfw_ringer_set_memory | |
369 | |
370 $Description:Set the ringer memory address for the given ringer mode. | |
371 | |
372 $Returns: | |
373 AS_OK The call is successful. | |
374 AS_INVALID_PARAM The player_type,ringer_mode parameter value is invalid. | |
375 AS_INTERNAL_ERROR Not able to send the message request. | |
376 | |
377 $Arguments: player_type:Type of the player based on the file. | |
378 ringer_mode: ringer mode | |
379 memory_pointer:pointer to midi file location | |
380 size:size of the midi file | |
381 | |
382 *******************************************************************************/ | |
383 | |
384 SHORT mfw_ringer_set_memory(T_AS_PLAYER_TYPE player_type,T_AS_RINGER_MODE ringer_mode,UINT32 *memory_pointer,UINT32 size) | |
385 { | |
386 T_AS_RET ringer_return; | |
387 TRACE_FUNCTION("mfw_ringer_set_memory"); | |
388 TRACE_EVENT_P1("player_type is %d",player_type); | |
389 ringer_return=as_ringer_set_memory(ringer_mode,player_type,memory_pointer, size); | |
390 return ringer_return; | |
391 } | |
392 | |
393 /******************************************************************************* | |
394 | |
395 $Function: mfw_ringer_set_file | |
396 | |
397 $Description:Set the ringer filename for the given ringer mode. | |
398 | |
399 $Returns: | |
400 AS_OK The call is successful. | |
401 AS_INVALID_PARAM The player_type or ringer_mode parameter value is invalid. | |
402 AS_INTERNAL_ERROR Not able to send the message request. | |
403 | |
404 $Arguments: | |
405 player_type:Type of the player based on the file. | |
406 ringer_mode: ringer mode | |
407 filename:Name of the midi file | |
408 | |
409 *******************************************************************************/ | |
410 SHORT mfw_ringer_set_file(T_AS_PLAYER_TYPE player_type,T_AS_RINGER_MODE ringer_mode, const char* filename) | |
411 { | |
412 T_AS_RET ringer_return; | |
413 char temp_file_name[FILENAME_MAX_LEN]; | |
414 TRACE_FUNCTION("mfw_ringer_set_file"); | |
415 | |
416 //Nov 04, 2005 REF:DRT OMAPS00053737 xdeepadh | |
417 #ifdef FF_MIDI_LOAD_FROM_LFS //Set the linear file for Ringer | |
418 | |
419 //Provide the complete path of the file | |
420 strcpy(temp_file_name, LFS_CONTENT_DIR); | |
421 strcat(temp_file_name, filename ); | |
422 TRACE_EVENT_P1(" linear temp_filename %s",temp_file_name); | |
423 ringer_return=as_ringer_set_linear_file(ringer_mode,player_type,temp_file_name); | |
424 | |
425 #else //Set the FFS file for Ringer | |
426 //Provide the complete path of the file | |
427 strcpy(temp_file_name, RINGER_CONTENT_DIR); | |
428 strcat(temp_file_name, "/"); | |
429 strcat(temp_file_name, filename ); | |
430 TRACE_EVENT_P1(" ffs temp_filename %s",temp_file_name); | |
431 ringer_return=as_ringer_set_file(ringer_mode,player_type,temp_file_name); | |
432 #endif //FF_MIDI_LOAD_FROM_LFS | |
433 return ringer_return; | |
434 } | |
435 | |
436 /******************************************************************************* | |
437 | |
438 $Function: mfw_ringer_set_volume | |
439 | |
440 $Description:Set the ringer volume for the given ringer mode. | |
441 | |
442 $Returns: | |
443 AS_OK The call is successful. | |
444 AS_INVALID_PARAM The ringer_mode or volume parameter value is invalid. | |
445 AS_INTERNAL_ERROR Not able to send the message request. | |
446 | |
447 $Arguments: ringer_mode: ringer mode | |
448 volume:Volume which has to be set for the given ringer mode | |
449 | |
450 *******************************************************************************/ | |
451 | |
452 SHORT mfw_ringer_set_volume(T_AS_RINGER_MODE ringer_mode,T_AS_VOLUME volume) | |
453 { | |
454 T_AS_RET ringer_return; | |
455 TRACE_FUNCTION("mfw_ringer_set_volume"); | |
456 TRACE_EVENT_P1("the volume to be set is %d",volume); | |
457 ringer_return=as_ringer_set_volume(ringer_mode,volume); | |
458 return ringer_return; | |
459 } | |
460 | |
461 /******************************************************************************* | |
462 | |
463 $Function: mfw_ringer_start | |
464 | |
465 $Description: Play a particular ringer file | |
466 | |
467 $Returns: | |
468 AS_OK The call is successful. | |
469 AS_INVALID_PARAM The ringer_mode parameter value is invalid. | |
470 AS_INTERNAL_ERROR Not able to send the message request. | |
471 | |
472 $Arguments: | |
473 ringer_mode: ringer mode | |
474 loop:playback in loop | |
475 callback_fn:callback function | |
476 | |
477 *******************************************************************************/ | |
478 | |
479 SHORT mfw_ringer_start(T_AS_RINGER_MODE ringer_mode,BOOLEAN loop,void (*callback_fn)(void *)) | |
480 { | |
481 T_AS_RET ringer_return; | |
482 TRACE_EVENT("mfw_ringer_start"); | |
483 //Aug 05, 2005 xdeepadh | |
484 #ifdef FF_MMI_AUDIO_PROFILE | |
485 //Configure the audio path to current Audio device. | |
486 mfw_set_stereo_path(mfw_get_current_audioDevice()); | |
487 mfwAudPlay = TRUE; //File is playing | |
488 #endif //FF_MMI_AUDIO_PROFILE | |
489 mfw_ringer_configure_callback_fn(callback_fn); | |
490 ringer_return=as_ring(ringer_mode,loop,&midi_return_path); | |
491 return ringer_return; | |
492 } | |
493 | |
494 /******************************************************************************* | |
495 | |
496 $Function: mfw_ringer_stop | |
497 | |
498 $Description:Stop the current ringer melody playback. | |
499 | |
500 $Returns: | |
501 AS_OK The call is successful. | |
502 AS_INTERNAL_ERROR Not able to send the message request. | |
503 | |
504 $Arguments: callback_fn:callback function | |
505 | |
506 *******************************************************************************/ | |
507 | |
508 SHORT mfw_ringer_stop(void (*callback_fn)(void *)) | |
509 { | |
510 T_AS_RET ringer_return; | |
511 TRACE_EVENT("mfw_ringer_stop"); | |
512 mfw_ringer_configure_callback_fn(callback_fn); | |
513 ringer_return=as_stop(&midi_return_path); | |
514 return ringer_return; | |
515 } | |
516 | |
517 /******************************************************************************* | |
518 | |
519 $Function: mfw_ringer_get_info | |
520 | |
521 $Description: Gets the ringer information for the given ringer mode. | |
522 | |
523 $Returns: | |
524 pointer to T_AS_RINGER_INFO | |
525 $Arguments: ringer_mode: ringer mode | |
526 ringer_info: The ringer details will be stored here. | |
527 | |
528 *******************************************************************************/ | |
529 T_AS_RINGER_INFO* mfw_ringer_get_info(T_AS_RINGER_MODE ringer_mode,const T_AS_RINGER_INFO* ringer_info) | |
530 { | |
531 T_AS_RET ringer_return; | |
532 TRACE_FUNCTION("mfw_ringer_get_info"); | |
533 ringer_return=as_ringer_get(ringer_mode,&ringer_info); | |
534 TRACE_EVENT_P1("ringer_info volume is %d",ringer_info->volume); | |
535 TRACE_EVENT_P1("ringer info name is %s",ringer_info->data.filename); | |
536 if(ringer_return==AS_OK) | |
537 return (T_AS_RINGER_INFO*)ringer_info; | |
538 } | |
539 | |
540 /******************************************************************************* | |
541 | |
542 $Function: mfw_ringer_configure_callback_fn | |
543 | |
544 $Description: Configure the Riviera Return Path | |
545 | |
546 $Returns:None | |
547 | |
548 $Arguments: Callback function | |
549 | |
550 *******************************************************************************/ | |
551 | |
552 static void mfw_ringer_configure_callback_fn(void (*callback_fn)(void *)) | |
553 { | |
554 | |
555 TRACE_EVENT("mfw_ringer_configure_callback_fn"); | |
556 midi_return_path.addr_id = 0; | |
557 midi_return_path.callback_func = callback_fn; | |
558 | |
559 return; | |
560 } | |
561 | |
562 /******************************************************************************* | |
563 | |
564 $Function: mfw_player_start_memory | |
565 | |
566 $Description:Start the playback melody stored in the given memory location according to the given player type. | |
567 | |
568 $Returns: | |
569 AS_OK The call is successful. | |
570 AS_INVALID_PARAM The player_type or volume parameter value is invalid. | |
571 AS_INTERNAL_ERROR Not able to send the message request. | |
572 | |
573 $Arguments: player_type:Type of the player based on the file. | |
574 address:pointer to midi file location to be played | |
575 size:size of the midi file | |
576 volume:Volume with which to play the midi file | |
577 loop:playback in loop | |
578 callback_fn:callback function | |
579 | |
580 *******************************************************************************/ | |
581 | |
582 SHORT mfw_player_start_memory(T_AS_PLAYER_TYPE player_type,const UINT32 * address, UINT32 size,T_AS_VOLUME volume,BOOLEAN loop,void (*callback_fn)(void *)) | |
583 { | |
584 T_AS_RET player_return; | |
585 TRACE_EVENT("mfw_player_start_memory"); | |
586 //Aug 05, 2005 xdeepadh | |
587 #ifdef FF_MMI_AUDIO_PROFILE | |
588 //Configure the audio path to current Audio device. | |
589 mfw_set_stereo_path(mfw_get_current_audioDevice()); | |
590 mfwAudPlay = TRUE; //File is playing | |
591 #endif //FF_MMI_AUDIO_PROFILE | |
592 mfw_ringer_configure_callback_fn(callback_fn); | |
593 player_return=as_play_memory(player_type,address,size,volume,loop,&midi_return_path); | |
594 return player_return; | |
595 | |
596 } | |
597 | |
598 /******************************************************************************* | |
599 | |
600 $Function: mfw_player_start_file | |
601 | |
602 $Description:Start the playback melody stored in the given file according to the given player type. | |
603 | |
604 $Returns: | |
605 AS_OK The call is successful. | |
606 AS_INVALID_PARAM The player_type or volume parameter value is invalid. | |
607 AS_FILE_ERROR The melody file can not be accessed, or contain unrecognized data. | |
608 AS_INTERNAL_ERROR Not able to send the message request. | |
609 | |
610 | |
611 $Arguments: player_type:Type of the player based on the file. | |
612 filename:Name of the midi file to be played | |
613 volume:Volume with which to play the midi file | |
614 loop:playback in loop | |
615 callback_fn:callback function | |
616 | |
617 *******************************************************************************/ | |
618 | |
619 SHORT mfw_player_start_file(T_AS_PLAYER_TYPE player_type,const char * filename,T_AS_VOLUME volume, BOOLEAN loop,void (*callback_fn)(void *)) | |
620 { | |
621 T_AS_RET player_return; | |
622 char temp_file_name[FILENAME_MAX_LEN]; | |
623 TRACE_EVENT("mfw_player_start_file"); | |
624 //Aug 05, 2005 xdeepadh | |
625 #ifdef FF_MMI_AUDIO_PROFILE | |
626 //Configure the audio path to current Audio device. | |
627 mfw_set_stereo_path(mfw_get_current_audioDevice()); | |
628 mfwAudPlay = TRUE; //File is playing | |
629 #endif //FF_MMI_AUDIO_PROFILE | |
630 mfw_ringer_configure_callback_fn(callback_fn); | |
631 | |
632 //Nov 04, 2005 REF:DRT OMAPS00053737 xdeepadh | |
633 #ifdef FF_MIDI_LOAD_FROM_LFS //Play the linear file for Player | |
634 | |
635 //Since, the file can be with or without the full path , | |
636 //Verify the file for full path , else provide the complete path. | |
637 strcpy(temp_file_name, LFS_CONTENT_DIR); | |
638 | |
639 //The complete path is provided | |
640 if(strncmp(filename,temp_file_name,strlen(temp_file_name))==0) | |
641 { | |
642 player_return=as_play_linear_file(player_type,filename,volume,loop,&midi_return_path); | |
643 } | |
644 //Provide the complete path | |
645 else | |
646 { | |
647 strcat(temp_file_name, filename ); | |
648 player_return=as_play_linear_file(player_type,temp_file_name,volume,loop,&midi_return_path); | |
649 } | |
650 | |
651 #else //Play the FFS file for Player | |
652 | |
653 //Since, the file can be with or without the full path , | |
654 //Verify the file for full path , else provide the complete path. | |
655 strcpy(temp_file_name, RINGER_CONTENT_DIR); | |
656 //The complete path is provided | |
657 if(strncmp(filename,temp_file_name,strlen(temp_file_name))==0) | |
658 { | |
659 player_return=as_play_file(player_type,filename,volume,loop,&midi_return_path); | |
660 } | |
661 //Provide the complete path | |
662 else | |
663 { | |
664 strcat(temp_file_name, "/"); | |
665 strcat(temp_file_name, filename ); | |
666 player_return=as_play_file(player_type,temp_file_name,volume,loop,&midi_return_path); | |
667 } | |
668 #endif //FF_MIDI_LOAD_FROM_LFS | |
669 | |
670 return player_return; | |
671 } | |
672 | |
673 /******************************************************************************* | |
674 | |
675 $Function: mfw_ringer_deduce_player_type | |
676 | |
677 $Description: Deduces the player type | |
678 | |
679 $Returns: T_AS_PLAYER_TYPE | |
680 | |
681 | |
682 $Arguments: filename:Name of the midi file | |
683 | |
684 *******************************************************************************/ | |
685 | |
686 T_AS_PLAYER_TYPE mfw_ringer_deduce_player_type(const char * filename) | |
687 { | |
688 T_AS_PLAYER_TYPE player_type; | |
689 TRACE_EVENT("mfw_ringer_deduce_player_type"); | |
690 as_deduce_player_type(filename,&player_type); | |
691 return player_type; | |
692 } | |
693 | |
694 | |
695 /******************************************************************************* | |
696 | |
697 $Function: mfw_player_stop | |
698 | |
699 $Description:Stop the current melody player | |
700 | |
701 $Returns: | |
702 AS_OK The call is successful. | |
703 AS_INTERNAL_ERROR Not able to send the message request. | |
704 | |
705 | |
706 $Arguments: callback_fn:callback function | |
707 | |
708 *******************************************************************************/ | |
709 | |
710 SHORT mfw_player_stop(void (*callback_fn)(void *)) | |
711 { | |
712 T_AS_RET player_return; | |
713 TRACE_EVENT("mfw_player_stop"); | |
714 mfw_ringer_configure_callback_fn(callback_fn); | |
715 player_return=as_stop(&midi_return_path); | |
716 return player_return; | |
717 } | |
718 | |
719 /******************************************************************************* | |
720 | |
721 $Function: mfw_player_midi_set_params | |
722 | |
723 $Description:Set the specific parameters for the player of given player_type. | |
724 | |
725 $Returns: AS_OK if call is succesfull. | |
726 AS_INVALID_PARAM if the player_type parameter value is invalid. | |
727 | |
728 $Arguments: Voicelimit:Voice limit to be set | |
729 channel:channel to be set | |
730 | |
731 *******************************************************************************/ | |
732 | |
733 SHORT mfw_player_midi_set_params(INT16 voicelimit,INT16 channel) | |
734 { | |
735 T_AS_PLAYER_PARAMS player_para; | |
736 T_AS_RET player_return; | |
737 TRACE_FUNCTION("mfw_player_midi_set_params"); | |
738 //Set the Voice limit and channel for Idle mode | |
739 player_para.midi.voice_limit=voicelimit ; | |
740 player_para.midi.output_channels=channel; | |
741 player_return=as_player_set_params(AS_PLAYER_TYPE_MIDI,&player_para); | |
742 return player_return; | |
743 } | |
744 | |
745 /******************************************************************************* | |
746 | |
747 $Function: mfw_player_mp3_set_params | |
748 | |
749 $Description:Set the specific parameters for the player of given player_type.(mp3) | |
750 | |
751 $Returns: AS_OK if call is succesfull. | |
752 AS_INVALID_PARAM if the player_type parameter value is invalid. | |
753 | |
754 $Arguments: size_file_start:size of the file where the melody must start | |
755 mono_stereo:channel to be set | |
756 | |
757 *******************************************************************************/ | |
758 #ifdef FF_MP3_RINGER | |
759 SHORT mfw_player_mp3_set_params(UINT32 size_file_start,BOOLEAN mono_stereo) | |
760 { | |
761 T_AS_PLAYER_PARAMS player_para; | |
762 T_AS_RET player_return; | |
763 TRACE_FUNCTION("mfw_player_mp3_set_params"); | |
764 //Set the Voice limit and channel for Idle mode | |
765 player_para.mp3.mono_stereo = mono_stereo ; | |
766 player_para.mp3.size_file_start = size_file_start; | |
767 player_return=as_player_set_params(AS_PLAYER_TYPE_MP3,&player_para); | |
768 return player_return; | |
769 } | |
770 #endif //FF_MP3_RINGER | |
771 | |
772 | |
773 //Nov 22, 2005 ER: OMAPS00057430, AAC Ringer support, nekkareb | |
774 /******************************************************************************* | |
775 | |
776 $Function: mfw_player_aac_set_params | |
777 | |
778 $Description:Set the specific parameters for the player of given player_type.(aac) | |
779 | |
780 $Returns: AS_OK if call is succesfull. | |
781 AS_INVALID_PARAM if the player_type parameter value is invalid. | |
782 | |
783 $Arguments: size_file_start:size of the file where the melody must start | |
784 mono_stereo:channel to be set | |
785 | |
786 *******************************************************************************/ | |
787 #ifdef FF_AAC_RINGER | |
788 SHORT mfw_player_aac_set_params(UINT32 size_file_start,BOOLEAN mono_stereo) | |
789 { | |
790 T_AS_PLAYER_PARAMS player_para; | |
791 T_AS_RET player_return; | |
792 | |
793 TRACE_FUNCTION("mfw_player_aac_set_params"); | |
794 | |
795 //Set the Voice limit and channel for Idle mode | |
796 player_para.aac.mono_stereo = mono_stereo ; | |
797 player_para.aac.size_file_start = size_file_start; | |
798 | |
799 player_return=as_player_set_params(AS_PLAYER_TYPE_AAC,&player_para); | |
800 return player_return; | |
801 } | |
802 #endif //FF_AAC_RINGER | |
803 | |
804 | |
805 /******************************************************************************* | |
806 | |
807 $Function: mfw_player_get_params | |
808 | |
809 $Description:gets the specific parametersfor the player of given player_type. | |
810 | |
811 $Returns: AS_OK if call is succesfull. | |
812 AS_INVALID_PARAM if the player_type parameter value is invalid. | |
813 | |
814 $Arguments: player_type:Type of the player based on the file. | |
815 player_para:The structure containing current parameters for the player type | |
816 | |
817 *******************************************************************************/ | |
818 | |
819 SHORT mfw_player_get_params(T_AS_PLAYER_TYPE player_type,const T_AS_PLAYER_PARAMS* player_para) | |
820 { | |
821 T_AS_RET player_return; | |
822 TRACE_FUNCTION("mfw_player_get_params"); | |
823 player_return=as_player_get_params(player_type,&player_para); | |
824 return player_return; | |
825 } | |
826 | |
827 //Nov 04, 2005 REF:DRT OMAPS00053737 xdeepadh | |
828 #ifdef FF_MIDI_LOAD_FROM_LFS | |
829 // ------------------------- LFS utilities --------------------------- | |
830 //These functions should be to load the LFS files, in the absence of ETM | |
831 /******************************************************************************* | |
832 | |
833 $Function: ram_load_file | |
834 | |
835 $Description: This function allocates the size of the file from the RTEST memory bank. | |
836 Then, it reads the file into that buffer. | |
837 | |
838 $Returns: A pointer to the allocated T_RAM_FILE data structure, or NULL | |
839 if there was an error. | |
840 | |
841 $Arguments: filename: A pointer to the RAM file descriptor | |
842 | |
843 *******************************************************************************/ | |
844 T_RAM_FILE *ram_load_file(char* filename) | |
845 { | |
846 T_FFS_FD file; | |
847 T_FFS_RET f_result; | |
848 // Nov 23, 2005 REF : DR OMAPS00057378 x0039928 | |
849 // stat variable declared local. | |
850 T_FFS_STAT stat; | |
851 T_RAM_FILE *file_buf = NULL; | |
852 | |
853 TRACE_EVENT( "FFS getting file length"); | |
854 if ((f_result = ffs_stat(filename, &stat)) < EFFS_OK) | |
855 { | |
856 TRACE_EVENT( "FFS could not read file length."); | |
857 return NULL; | |
858 } | |
859 | |
860 TRACE_EVENT( "FFS creating T_RAM_FILE"); | |
861 file_buf = (T_RAM_FILE *)mfwAlloc(sizeof(T_RAM_FILE)); | |
862 if (file_buf == NULL) | |
863 { | |
864 TRACE_EVENT_P1( "Error to get memory for T_RAM_FILE, size =%d", sizeof(T_RAM_FILE)); | |
865 return NULL; | |
866 } | |
867 | |
868 TRACE_EVENT( "FFS creating file buffer"); | |
869 file_buf->data= (void *)mfwAlloc(stat.size); | |
870 if ((file_buf->data == NULL)) | |
871 { | |
872 TRACE_EVENT_P1( "Error to get memory for data, size =%d", stat.size); | |
873 mfwFree((U8*)file_buf,sizeof(T_RAM_FILE)); | |
874 return NULL; | |
875 } | |
876 | |
877 file_buf->dataSize = stat.size; | |
878 | |
879 TRACE_EVENT( "FFS opening file"); | |
880 if ((file = ffs_open (filename, FFS_O_RDONLY)) <= EFFS_OK) | |
881 { | |
882 TRACE_EVENT("Cannot open file"); | |
883 mfwFree((U8*)file_buf->data,stat.size); | |
884 mfwFree((U8*)file_buf,sizeof(T_RAM_FILE)); | |
885 return NULL; | |
886 } | |
887 | |
888 TRACE_EVENT( "FFS reading file"); | |
889 if ((ffs_read(file, file_buf->data, stat.size)) != stat.size) | |
890 { | |
891 TRACE_EVENT( "Cannot read file"); | |
892 ffs_close (file); | |
893 mfwFree((U8*)file_buf->data,stat.size); | |
894 mfwFree((U8*)file_buf,sizeof(T_RAM_FILE)); | |
895 return NULL; | |
896 } | |
897 | |
898 TRACE_EVENT( "FFS closing file"); | |
899 if ((ffs_close (file)) != EFFS_OK) | |
900 { | |
901 TRACE_EVENT( "Cannot close file"); | |
902 mfwFree((U8*)file_buf->data,stat.size); | |
903 mfwFree((U8*)file_buf,sizeof(T_RAM_FILE)); | |
904 return NULL; | |
905 } | |
906 | |
907 return file_buf; | |
908 } | |
909 | |
910 /******************************************************************************* | |
911 | |
912 $Function: ram_write_lfs | |
913 | |
914 $Description: This function creates an lfs file and writes the midi data content into it. | |
915 | |
916 $Returns: T_RV_TEST_RET | |
917 | |
918 $Arguments: ram_file: A pointer to the RAM file descriptor | |
919 filename: Filename for the LFS file | |
920 | |
921 *******************************************************************************/ | |
922 | |
923 T_RV_TEST_RET ram_write_lfs(T_RAM_FILE * ram_file,char* filename ) | |
924 { | |
925 fd_t lfs_file = NULL; | |
926 int return_val = 0; | |
927 effs_t return_value = 0; | |
928 char temp_file[100]; | |
929 strcpy(temp_file,LFS_CONTENT_DIR); | |
930 strcat(temp_file,filename); | |
931 TRACE_EVENT_P1("LFS fiel filename:%s", temp_file); | |
932 // Create a file | |
933 lfs_file = lfs_open(temp_file, FFS_O_CREATE, (unsigned int *)&ram_file->dataSize); | |
934 if( lfs_file < EFFS_OK) | |
935 { | |
936 TRACE_EVENT_P1( "LFS fiel open failed with error:%d", lfs_file); | |
937 // Nov 23, 2005 REF : DR OMAPS00057378 x0039928 | |
938 // Buffer memory allocated is freed in case of error. | |
939 ram_remove_file(ram_file); | |
940 return -1; | |
941 } | |
942 | |
943 // Write the buffer in LFS | |
944 return_val = lfs_write(lfs_file, ram_file->data, ram_file->dataSize); | |
945 if (return_val < EFFS_OK) | |
946 { | |
947 TRACE_EVENT_P1( "LFS file write failed with error:%d",return_val); | |
948 // Nov 23, 2005 REF : DR OMAPS00057378 x0039928 | |
949 // Buffer memory allocated is freed in case of error. | |
950 ram_remove_file(ram_file); | |
951 return -1; | |
952 } | |
953 | |
954 // Close the LFS file | |
955 return_value = lfs_close(lfs_file); | |
956 if(return_value < EFFS_OK) | |
957 { | |
958 TRACE_EVENT_P1( "LFS file close failed with error%d:",return_value); | |
959 // Nov 23, 2005 REF : DR OMAPS00057378 x0039928 | |
960 // Buffer memory allocated is freed in case of error. | |
961 ram_remove_file(ram_file); | |
962 return -1; | |
963 } | |
964 ram_remove_file(ram_file); | |
965 return 0; | |
966 } | |
967 | |
968 /******************************************************************************* | |
969 | |
970 $Function: ram_remove_file | |
971 | |
972 $Description: This function frees the memory - associated to the file - allocated | |
973 during the call to ram_load_file() function. | |
974 $Returns: None | |
975 | |
976 $Arguments: file_buf A pointer to the RAM file descriptor | |
977 | |
978 *******************************************************************************/ | |
979 void ram_remove_file(T_RAM_FILE* file_buf) | |
980 { | |
981 TRACE_EVENT("FFS removing file from memory"); | |
982 if (file_buf) | |
983 { | |
984 if (file_buf->data) | |
985 { | |
986 // Nov 23, 2005 REF : DR OMAPS00057378 x0039928 | |
987 // stat.size is replaced with file_buf->dataSize as now it is declared local. | |
988 mfwFree((U8*)file_buf->data,file_buf->dataSize); | |
989 | |
990 } | |
991 mfwFree((U8*)file_buf,sizeof(T_RAM_FILE)); | |
992 } | |
993 } | |
994 | |
995 #endif //FF_MIDI_LOAD_FROM_LFS | |
996 #endif |