comparison src/cs/services/Audio/audio_melody_E1.c @ 0:945cf7f506b2

src/cs: chipsetsw import from tcs211-fcmodem binary blobs and LCD demo files have been excluded, all line endings are LF only
author Mychaela Falconia <falcon@freecalypso.org>
date Sun, 25 Sep 2016 22:50:11 +0000
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:945cf7f506b2
1 /****************************************************************************/
2 /* */
3 /* File Name: audio_melody_E1.c */
4 /* */
5 /* Purpose: This file contains all the functions used to manage the */
6 /* melody_E1. */
7 /* */
8 /* Version 0.1 */
9 /* */
10 /* Date Modification */
11 /* ------------------------------------ */
12 /* 18 May 2001 Create */
13 /* */
14 /* Author */
15 /* Francois Mazard - Stephanie Gerthoux */
16 /* */
17 /* (C) Copyright 2001 by Texas Instruments Incorporated, All Rights Reserved*/
18 /****************************************************************************/
19
20 #include "rv/rv_defined_swe.h"
21 #ifdef RVM_AUDIO_MAIN_SWE
22 #ifndef _WINDOWS
23 #include "config/swconfig.cfg"
24 #include "config/sys.cfg"
25 #include "config/chipset.cfg"
26 #endif
27
28 /* include the usefull L1 header */
29 #include "l1_confg.h"
30
31 #if (MELODY_E1)
32 #include "rv/rv_general.h"
33 #include "rvm/rvm_gen.h"
34 #include "audio/audio_features_i.h"
35 #include "audio/audio_ffs_i.h"
36 #include "audio/audio_api.h"
37 #include "audio/audio_structs_i.h"
38 #include "audio/audio_var_i.h"
39 #include "audio/audio_messages_i.h"
40 #include "rvf/rvf_target.h"
41 #include "audio/audio_const_i.h"
42 #include "audio/audio_error_hdlr_i.h"
43
44 /* include the usefull L1 header */
45 #define BOOL_FLAG
46 #define CHAR_FLAG
47 #include "l1_types.h"
48 #include "l1audio_cust.h"
49 #include "l1audio_msgty.h"
50 #include "l1audio_signa.h"
51
52 #include <string.h>
53
54 /********************************************************************************/
55 /* */
56 /* Function Name: audio_melody_E1_send_status */
57 /* */
58 /* Purpose: This function sends the melody_E1 status to the entity. */
59 /* */
60 /* Input Parameters: */
61 /* status, */
62 /* return path */
63 /* */
64 /* Output Parameters: */
65 /* None. */
66 /* */
67 /* Note: */
68 /* None. */
69 /* */
70 /* Revision History: */
71 /* None. */
72 /* */
73 /********************************************************************************/
74 void audio_melody_E1_send_status (T_AUDIO_RET status, T_RV_RETURN return_path)
75 {
76 void *p_send_message = NULL;
77 T_RVF_MB_STATUS mb_status = RVF_RED;
78
79 while (mb_status == RVF_RED)
80 {
81 /* allocate the message buffer */
82 mb_status = rvf_get_buf (p_audio_gbl_var->mb_external,
83 sizeof (T_AUDIO_MELODY_E1_STATUS),
84 (T_RVF_BUFFER **) (&p_send_message));
85
86 /* If insufficient resources, then report a memory error and abort. */
87 /* and wait until more ressource is given */
88 if (mb_status == RVF_RED)
89 {
90 audio_melody_E1_error_trace(AUDIO_ENTITY_NO_MEMORY);
91 rvf_delay(RVF_MS_TO_TICKS(1000));
92 }
93 }
94 /*fill the header of the message */
95 ((T_AUDIO_MELODY_E1_STATUS *)(p_send_message))->os_hdr.msg_id = AUDIO_MELODY_E1_STATUS_MSG;
96
97 /* fill the status parameters */
98 ((T_AUDIO_MELODY_E1_STATUS *)(p_send_message))->status = status;
99
100 if (return_path.callback_func == NULL)
101 {
102 /* send the message to the entity */
103 rvf_send_msg (return_path.addr_id,
104 p_send_message);
105 }
106 else
107 {
108 /* call the callback function */
109 (*return_path.callback_func)((void *)(p_send_message));
110 rvf_free_buf((T_RVF_BUFFER *)p_send_message);
111
112 }
113 }
114
115 /********************************************************************************/
116 /* */
117 /* Function Name: audio_melody_E1_message_switch */
118 /* */
119 /* Purpose: Manage the message supply between the melody manage 1 and */
120 /* manager 0 */
121 /* */
122 /* Input Parameters: */
123 /* start or stop message from the melody E1 features */
124 /* */
125 /* Output Parameters: */
126 /* index of the manager */
127 /* */
128 /* Note: */
129 /* None. */
130 /* */
131 /* Revision History: */
132 /* None. */
133 /* */
134 /********************************************************************************/
135 UINT8 audio_melody_E1_message_switch (T_RV_HDR *p_message)
136 {
137 switch (p_message->msg_id)
138 {
139 case AUDIO_MELODY_E1_START_REQ:
140 {
141 /* Check if the melody E1 number 0 isn't started */
142 if (p_audio_gbl_var->melody_E1_0.state == AUDIO_MELODY_E1_IDLE)
143 {
144 /* Save the mode of the melody */
145 p_audio_gbl_var->melody_E1_mode =
146 ((T_AUDIO_MELODY_E1_START *)p_message)->melody_E1_parameter.melody_mode;
147 return(AUDIO_MELODY_E1_0);
148 }
149 /* Check if the melody E1 number 1 isn't started and if the current mode is game mode */
150 if ( (p_audio_gbl_var->melody_E1_1.state == AUDIO_MELODY_E1_IDLE) &&
151 (p_audio_gbl_var->melody_E1_mode == AUDIO_MELODY_GAME_MODE) )
152 {
153 return(AUDIO_MELODY_E1_1);
154 }
155
156 /* This start command is an error */
157 /* error due to a wrong melody mode */
158 if ( (p_audio_gbl_var->melody_E1_1.state == AUDIO_MELODY_E1_IDLE) &&
159 (p_audio_gbl_var->melody_E1_mode == AUDIO_MELODY_NORMAL_MODE) )
160 {
161 /* Close the FFS file previously open by the audio start API*/
162 #ifndef _WINDOWS
163 if ( ffs_close(((T_AUDIO_MELODY_E1_START *)(p_message))->audio_ffs_fd) != EFFS_OK )
164 {
165 audio_melody_E1_error_trace(AUDIO_ENTITY_FILE_NO_CLOSE);
166 }
167 #endif
168 audio_melody_E1_send_status (AUDIO_MODE_ERROR, ((T_AUDIO_MELODY_E1_START *)(p_message))->return_path);
169 audio_melody_E1_error_trace(AUDIO_ERROR_MODE);
170 p_audio_gbl_var->message_processed = TRUE;
171 return(AUDIO_MELODY_E1_NONE);
172 }
173
174 /* error due to a wrong start */
175 /* Close the FFS file previously open by the audio start API*/
176 #ifndef _WINDOWS
177 if ( ffs_close(((T_AUDIO_MELODY_E1_START *)(p_message))->audio_ffs_fd) != EFFS_OK )
178 {
179 audio_melody_E1_error_trace(AUDIO_ENTITY_FILE_NO_CLOSE);
180 }
181 #endif
182 audio_melody_E1_send_status (AUDIO_ERROR, ((T_AUDIO_MELODY_E1_START *)(p_message))->return_path);
183 audio_melody_E1_error_trace(AUDIO_ERROR_START_EVENT);
184 p_audio_gbl_var->message_processed = TRUE;
185 return(AUDIO_MELODY_E1_NONE);
186 }
187
188 case AUDIO_MELODY_E1_STOP_REQ:
189 {
190 /* Check if the melody E1 number 0 is running and if the stop command and */
191 /* the manager 0 talk about the same melody name */
192 if ( (p_audio_gbl_var->melody_E1_0.state != AUDIO_MELODY_E1_IDLE) &&
193 (strcmp(p_audio_gbl_var->melody_E1_0.melody_name,
194 ((T_AUDIO_MELODY_E1_STOP*)p_message)->melody_name) == 0) )
195 {
196 return(AUDIO_MELODY_E1_0);
197 }
198 /* Check if the melody E1 number 1 is running and if the stop command and */
199 /* the manager 1 talk about the same melody name */
200 if ( (p_audio_gbl_var->melody_E1_1.state != AUDIO_MELODY_E1_IDLE) &&
201 (strcmp(p_audio_gbl_var->melody_E1_1.melody_name,
202 ((T_AUDIO_MELODY_E1_STOP*)p_message)->melody_name) == 0) )
203 {
204 return(AUDIO_MELODY_E1_1);
205 }
206
207 /* the stop command isn't apply to a melody E1, it's an error */
208 /* event error - send an error message*/
209 audio_melody_E1_send_status (AUDIO_ERROR, ((T_AUDIO_MELODY_E1_STOP *)(p_message))->return_path);
210 audio_melody_E1_error_trace(AUDIO_ERROR_STOP_EVENT);
211 p_audio_gbl_var->message_processed = TRUE;
212 return(AUDIO_MELODY_E1_NONE);
213 }
214
215 case AUDIO_FFS_INIT_DONE:
216 {
217 /* The FFS message is from the melody E1 manager 0 */
218 if ( ((T_AUDIO_FFS_INIT *)p_message)->session_id == AUDIO_FFS_SESSION_MELODY_E1_0 )
219 {
220 return(AUDIO_MELODY_E1_0);
221 }
222 /* The FFS message is from the melody E1 manager 1 */
223 if ( ((T_AUDIO_FFS_INIT *)p_message)->session_id == AUDIO_FFS_SESSION_MELODY_E1_1 )
224 {
225 return(AUDIO_MELODY_E1_1);
226 }
227 return(AUDIO_MELODY_E1_NONE);
228 }
229
230 case AUDIO_FFS_STOP_CON:
231 {
232 /* The FFS message is from the melody E1 manager 0 */
233 if ( ((T_AUDIO_FFS_STOP_REQ *)p_message)->session_id == AUDIO_FFS_SESSION_MELODY_E1_0 )
234 {
235 return(AUDIO_MELODY_E1_0);
236 }
237 /* The FFS message is from the melody E1 manager 1 */
238 if ( ((T_AUDIO_FFS_STOP_REQ *)p_message)->session_id == AUDIO_FFS_SESSION_MELODY_E1_1 )
239 {
240 return(AUDIO_MELODY_E1_1);
241 }
242 return(AUDIO_MELODY_E1_NONE);
243 }
244
245 case MMI_MELODY0_START_CON:
246 case MMI_MELODY0_STOP_CON:
247 {
248 return(AUDIO_MELODY_E1_0);
249 }
250
251 case MMI_MELODY1_START_CON:
252 case MMI_MELODY1_STOP_CON:
253 {
254 return(AUDIO_MELODY_E1_1);
255 }
256
257 default:
258 {
259 return(AUDIO_MELODY_E1_NONE);
260 break;
261 }
262
263 } /* switch */
264 }
265 /********************************************************************************/
266 /* */
267 /* Function Name: audio_melody_convert_parameter */
268 /* */
269 /* Purpose: Convert the melody parameters from the entity to the l1 */
270 /* parameters */
271 /* */
272 /* Input Parameters: */
273 /* session_id of the melody */
274 /* id of the melody */
275 /* */
276 /* Output Parameters: */
277 /* layer 1 melody message */
278 /* */
279 /* Note: */
280 /* None. */
281 /* */
282 /* Revision History: */
283 /* None. */
284 /* */
285 /********************************************************************************/
286 void audio_melody_e1_convert_parameter(UINT8 channel_id, T_MMI_MELODY_REQ *l1_parameter, UINT8 melody_id)
287 {
288 if (melody_id == 0)
289 {
290 if (p_audio_gbl_var->melody_E1_mode == AUDIO_MELODY_GAME_MODE)
291 {
292 /* oscillators 0, 1, 2, 3 are used for the melody 0 in game mode */
293 l1_parameter->oscillator_used_bitmap = 0x0F;
294 }
295 else
296 {
297 /* oscillators 0, 1, 2, 3, 4, 5, 6, 7 are used for the melody 0 in normal mode */
298 l1_parameter->oscillator_used_bitmap = 0xFF;
299 }
300
301 /* loopback mode */
302 l1_parameter->loopback =
303 p_audio_gbl_var->melody_E1_0.loopback;
304 }
305 else
306 {
307 /* oscillators 4, 5, 6, 7 are used for the melody 0 */
308 l1_parameter->oscillator_used_bitmap = 0xF0;
309
310 /* loopback mode */
311 l1_parameter->loopback =
312 p_audio_gbl_var->melody_E1_0.loopback;
313
314 }
315 l1_parameter->session_id = channel_id;
316 }
317
318 /********************************************************************************/
319 /* */
320 /* Function Name: audio_melody_e1_manager_0 */
321 /* */
322 /* Purpose: This function is called to manage a melody E1 format number 0. */
323 /* */
324 /* Input Parameters: */
325 /* Message to the audo entity */
326 /* */
327 /* Output Parameters: */
328 /* None. */
329 /* */
330 /* Note: */
331 /* None. */
332 /* */
333 /* Revision History: */
334 /* None. */
335 /* */
336 /********************************************************************************/
337 void audio_melody_E1_manager_0 (T_RV_HDR *p_message)
338 {
339 /* Declare local variables. */
340 void *p_send_message;
341 UINT8 i;
342 T_RVF_MB_STATUS mb_status;
343
344 /**************** audio_melody_e1_manager function begins *********************/
345
346 switch(p_audio_gbl_var->melody_E1_0.state)
347 {
348 case AUDIO_MELODY_E1_IDLE:
349 {
350 switch(p_message->msg_id)
351 {
352 case AUDIO_MELODY_E1_START_REQ:
353 {
354 /* save the task id of the entity */
355 p_audio_gbl_var->melody_E1_0.task_id = p_message->src_addr_id;
356
357 /* save the return path */
358 p_audio_gbl_var->melody_E1_0.return_path.callback_func =
359 ((T_AUDIO_MELODY_E1_START*)(p_message))->return_path.callback_func;
360 p_audio_gbl_var->melody_E1_0.return_path.addr_id =
361 ((T_AUDIO_MELODY_E1_START*)(p_message))->return_path.addr_id;
362
363 for (i=0; i<AUDIO_PATH_NAME_MAX_SIZE; i++)
364 {
365 p_audio_gbl_var->melody_E1_0.melody_name[i] =
366 ((T_AUDIO_MELODY_E1_START*)(p_message))->melody_E1_parameter.melody_name[i];
367 }
368
369 p_audio_gbl_var->melody_E1_0.loopback =
370 ((T_AUDIO_MELODY_E1_START*)(p_message))->melody_E1_parameter.loopback;
371
372 /* Send the Start message to the FFS */
373 /* allocate the message buffer */
374 mb_status = rvf_get_buf (p_audio_gbl_var->mb_internal,
375 sizeof (T_AUDIO_FFS_FLASH_2_RAM_START),
376 (T_RVF_BUFFER **) (&p_send_message));
377
378 /* If insufficient resources, then report a memory error and abort. */
379 if (mb_status == RVF_RED)
380 {
381 audio_melody_E1_error_trace(AUDIO_ENTITY_NO_MEMORY);
382 }
383
384 /* fill the header of the message */
385 ((T_AUDIO_FFS_FLASH_2_RAM_START *)(p_send_message))->os_hdr.msg_id = AUDIO_FFS_FLASH_2_RAM_START_REQ;
386
387 /* fill the parameters */
388 ((T_AUDIO_FFS_FLASH_2_RAM_START *)(p_send_message))->audio_ffs_fd =
389 ((T_AUDIO_MELODY_E1_START*)(p_message))->audio_ffs_fd;
390 ((T_AUDIO_FFS_FLASH_2_RAM_START *)(p_send_message))->initial_size = AUDIO_MELODY_E1_SIZE;
391 ((T_AUDIO_FFS_FLASH_2_RAM_START *)(p_send_message))->loop =
392 ((T_AUDIO_MELODY_E1_START*)(p_message))->melody_E1_parameter.loopback;
393
394 ((T_AUDIO_FFS_FLASH_2_RAM_START *)(p_send_message))->session_id = AUDIO_FFS_SESSION_MELODY_E1_0;
395
396 /* send the message to the entity */
397 rvf_send_msg (p_audio_gbl_var->audio_ffs_addrId,
398 p_send_message);
399
400 /* change to the state AUDIO_MELODY_E1_WAIT_INIT_FFS */
401 p_audio_gbl_var->melody_E1_0.state = AUDIO_MELODY_E1_WAIT_INIT_FFS;
402 break;
403 }
404 }
405 break;
406 } /* case AUDIO_MELODY_E1_IDLE */
407
408 case AUDIO_MELODY_E1_WAIT_INIT_FFS:
409 {
410 switch(p_message->msg_id)
411 {
412 case AUDIO_FFS_INIT_DONE:
413 {
414 /* send the start melody message to the L1 */
415 /* allocate the buffer for the message to the L1 */
416 p_send_message = audio_allocate_l1_message(sizeof(T_MMI_MELODY_REQ));
417
418 if ( p_send_message != NULL)
419 {
420 /* Convert the entity parameters to the audio L1 parameters */
421 audio_melody_e1_convert_parameter(((T_AUDIO_FFS_INIT *)(p_message))->channel_id,
422 ((T_MMI_MELODY_REQ *)(p_send_message)),
423 AUDIO_MELODY_E1_0);
424
425 /* send the start command to the audio L1 */
426 audio_send_l1_message(MMI_MELODY0_START_REQ, p_send_message);
427 }
428
429 /* change to the state AUDIO_MELODY_E1_WAIT_START_CONFIRMATION */
430 p_audio_gbl_var->melody_E1_0.state = AUDIO_MELODY_E1_WAIT_START_CON;
431 break;
432 }
433 case AUDIO_MELODY_E1_STOP_REQ:
434 {
435 /*.Before stopping this task, control that */
436 /* stop task id caller =Melody task id */
437 if ( p_audio_gbl_var->melody_E1_0.task_id == p_message->src_addr_id)
438 {
439 /* change to the state AUDIO_MELODY_E1_WAIT_INIT_DONE */
440 p_audio_gbl_var->melody_E1_0.state = AUDIO_MELODY_E1_WAIT_INIT_DONE;
441 }
442 else
443 {
444 /* A stop request from an other task is sent during a start connection */
445 /* event error - send an error message */
446 audio_melody_E1_send_status (AUDIO_ERROR,((T_AUDIO_MELODY_E1_STOP *)(p_message))->return_path);
447 audio_melody_E1_error_trace(AUDIO_ERROR_STOP_EVENT);
448 }
449 break;
450 } /* case AUDIO_MELODY_E1_STOP_REQ */
451
452 case AUDIO_MELODY_E1_START_REQ:
453 {
454 /* event error - send an error message*/
455 /* Close the FFS file previously open by the audio start API*/
456 #ifndef _WINDOWS
457 if ( ffs_close(((T_AUDIO_MELODY_E1_START *)(p_message))->audio_ffs_fd) != EFFS_OK )
458 {
459 audio_melody_E1_error_trace(AUDIO_ENTITY_FILE_NO_CLOSE);
460 }
461 #endif
462 audio_melody_E1_send_status (AUDIO_ERROR, ((T_AUDIO_MELODY_E1_START *)(p_message))->return_path);
463 audio_melody_E1_error_trace(AUDIO_ERROR_START_EVENT);
464 break;
465 }
466 }
467 break;
468 } /* case AUDIO_MELODY_E1_WAIT_INIT_FFS */
469
470 case AUDIO_MELODY_E1_WAIT_INIT_DONE:
471 {
472 switch(p_message->msg_id)
473 {
474 case AUDIO_FFS_INIT_DONE:
475 {
476 /* Send FFS stop command */
477 /* allocate the message buffer */
478 mb_status = rvf_get_buf (p_audio_gbl_var->mb_internal,
479 sizeof (T_AUDIO_FFS_STOP_REQ),
480 (T_RVF_BUFFER **) (&p_send_message));
481
482 /* If insufficient resources, then report a memory error and abort. */
483 if (mb_status == RVF_RED)
484 {
485 audio_melody_E1_error_trace(AUDIO_ENTITY_NO_MEMORY);
486 }
487
488 /* fill the header of the message */
489 ((T_AUDIO_FFS_STOP_REQ *)(p_send_message))->os_hdr.msg_id = AUDIO_FFS_STOP_REQ;
490
491 /* fill the parameter */
492 ((T_AUDIO_FFS_STOP_REQ *)(p_send_message))->session_id = AUDIO_FFS_SESSION_MELODY_E1_0;
493
494 /* send the message to the entity */
495 rvf_send_msg (p_audio_gbl_var->audio_ffs_addrId,
496 p_send_message);
497
498 /* change to the state AUDIO_MELODY_E1_WAIT_STOP_FFS */
499 p_audio_gbl_var->melody_E1_0.state = AUDIO_MELODY_E1_WAIT_STOP_FFS;
500 break;
501 }
502 case AUDIO_MELODY_E1_STOP_REQ:
503 {
504 /* stop event error - send an error message */
505 audio_melody_E1_send_status (AUDIO_ERROR,((T_AUDIO_MELODY_E1_STOP *)(p_message))->return_path);
506 audio_melody_E1_error_trace(AUDIO_ERROR_STOP_EVENT);
507 break;
508 } /* case AUDIO_MELODY_E1_STOP_REQ */
509
510 case AUDIO_MELODY_E1_START_REQ:
511 {
512 /* event error - send an error message*/
513 /* Close the FFS file previously open by the audio start API*/
514 #ifndef _WINDOWS
515 if ( ffs_close(((T_AUDIO_MELODY_E1_START *)(p_message))->audio_ffs_fd) != EFFS_OK )
516 {
517 audio_melody_E1_error_trace(AUDIO_ENTITY_FILE_NO_CLOSE);
518 }
519 #endif
520 audio_melody_E1_send_status (AUDIO_ERROR, ((T_AUDIO_MELODY_E1_START *)(p_message))->return_path);
521 audio_melody_E1_error_trace(AUDIO_ERROR_START_EVENT);
522 break;
523 }
524 }
525 break;
526 } /* case AUDIO_MELODY_E1_WAIT_INIT_DONE*/
527
528 case AUDIO_MELODY_E1_WAIT_START_CON:
529 {
530 switch(p_message->msg_id)
531 {
532 case MMI_MELODY0_START_CON:
533 {
534 /* change to the state AUDIO_MELODY_E1_WAIT_STOP_COMMAND */
535 p_audio_gbl_var->melody_E1_0.state = AUDIO_MELODY_E1_WAIT_STOP_COMMAND;
536 break;
537 }
538
539 case AUDIO_MELODY_E1_STOP_REQ:
540 {
541 /*.Before stopping this task, control that */
542 /* stop task id caller =Melody task id */
543 if ( p_audio_gbl_var->melody_E1_0.task_id == p_message->src_addr_id)
544 {
545 /* change to the state AUDIO_MELODY_E1_WAIT_STOP_CONFIRMATION */
546 p_audio_gbl_var->melody_E1_0.state = AUDIO_MELODY_E1_WAIT_START_CON_TO_STOP;
547 }
548 else
549 {
550 /* A stop request from an other task is sent during a start connection */
551 /* event error - send an error message */
552 audio_melody_E1_send_status (AUDIO_ERROR,((T_AUDIO_MELODY_E1_STOP *)(p_message))->return_path);
553 audio_melody_E1_error_trace(AUDIO_ERROR_STOP_EVENT);
554 }
555 break;
556 } /* case AUDIO_MELODY_E1_STOP_REQ */
557
558 case AUDIO_MELODY_E1_START_REQ:
559 {
560 /* event error - send an error message*/
561 /* Close the FFS file previously open by the audio start API*/
562 #ifndef _WINDOWS
563 if ( ffs_close(((T_AUDIO_MELODY_E1_START *)(p_message))->audio_ffs_fd) != EFFS_OK )
564 {
565 audio_melody_E1_error_trace(AUDIO_ENTITY_FILE_NO_CLOSE);
566 }
567 #endif
568 audio_melody_E1_send_status (AUDIO_ERROR, ((T_AUDIO_MELODY_E1_START *)(p_message))->return_path);
569 audio_melody_E1_error_trace(AUDIO_ERROR_START_EVENT);
570 break;
571 }
572 }
573 break;
574 } /* case AUDIO_MELODY_E1_PLAY_WAIT_START_CON */
575
576 case AUDIO_MELODY_E1_WAIT_START_CON_TO_STOP:
577 {
578 switch(p_message->msg_id)
579 {
580 case MMI_MELODY0_START_CON:
581 {
582 /* send the stop command to the audio L1 */
583 /* allocate the buffer for the message to the L1 */
584 p_send_message = audio_allocate_l1_message(0);
585 if ( p_send_message != NULL)
586 {
587 /* send the start command to the audio L1 */
588 audio_send_l1_message(MMI_MELODY0_STOP_REQ, p_send_message);
589 }
590
591 /* change to the state AUDIO_MELODY_E1_WAIT_STOP_CON */
592 p_audio_gbl_var->melody_E1_0.state = AUDIO_MELODY_E1_WAIT_STOP_CON;
593 break;
594 }
595
596 case AUDIO_MELODY_E1_STOP_REQ:
597 {
598 /* stop event error - send an error message */
599 audio_melody_E1_send_status (AUDIO_ERROR,((T_AUDIO_MELODY_E1_STOP *)(p_message))->return_path);
600 audio_melody_E1_error_trace(AUDIO_ERROR_STOP_EVENT);
601 break;
602 } /* case AUDIO_MELODY_E1_STOP_REQ */
603
604 case AUDIO_MELODY_E1_START_REQ:
605 {
606 /* event error - send an error message*/
607 /* Close the FFS file previously open by the audio start API*/
608 #ifndef _WINDOWS
609 if ( ffs_close(((T_AUDIO_MELODY_E1_START *)(p_message))->audio_ffs_fd) != EFFS_OK )
610 {
611 audio_melody_E1_error_trace(AUDIO_ENTITY_FILE_NO_CLOSE);
612 }
613 #endif
614 audio_melody_E1_send_status (AUDIO_ERROR, ((T_AUDIO_MELODY_E1_START *)(p_message))->return_path);
615 audio_melody_E1_error_trace(AUDIO_ERROR_START_EVENT);
616 break;
617 }
618 }
619 break;
620 }
621
622 case AUDIO_MELODY_E1_WAIT_STOP_COMMAND:
623 {
624 switch(p_message->msg_id)
625 {
626 case MMI_MELODY0_STOP_CON:
627 {
628 /* Send FFS stop command */
629 /* allocate the message buffer */
630 mb_status = rvf_get_buf (p_audio_gbl_var->mb_internal,
631 sizeof (T_AUDIO_FFS_STOP_REQ),
632 (T_RVF_BUFFER **) (&p_send_message));
633
634 /* If insufficient resources, then report a memory error and abort. */
635 if (mb_status == RVF_RED)
636 {
637 audio_melody_E1_error_trace(AUDIO_ENTITY_NO_MEMORY);
638 }
639
640 /* fill the header of the message */
641 ((T_AUDIO_FFS_STOP_REQ *)(p_send_message))->os_hdr.msg_id = AUDIO_FFS_STOP_REQ;
642
643 /* fill the parameter */
644 ((T_AUDIO_FFS_STOP_REQ *)(p_send_message))->session_id = AUDIO_FFS_SESSION_MELODY_E1_0;
645
646 /* send the message to the entity */
647 rvf_send_msg (p_audio_gbl_var->audio_ffs_addrId,
648 p_send_message);
649
650 /* change to the state AUDIO_MELODY_E1_WAIT_STOP_FFS */
651 p_audio_gbl_var->melody_E1_0.state = AUDIO_MELODY_E1_WAIT_STOP_FFS;
652 break;
653 }
654
655 case AUDIO_MELODY_E1_STOP_REQ:
656 {
657 /*.Before stopping this task, control that */
658 /* stop task id caller =Melody task id */
659 if ( p_audio_gbl_var->melody_E1_0.task_id == p_message->src_addr_id)
660 {
661 /* send the stop command to the audio L1 */
662 /* allocate the buffer for the message to the L1 */
663 p_send_message = audio_allocate_l1_message(0);
664 if (p_send_message != NULL)
665 {
666 /* send the start command to the audio L1 */
667 audio_send_l1_message(MMI_MELODY0_STOP_REQ, p_send_message);
668 }
669
670 /* change to the state AUDIO_MELODY_E1_WAIT_STOP_CONFIRMATION */
671 p_audio_gbl_var->melody_E1_0.state = AUDIO_MELODY_E1_WAIT_STOP_CON;
672 }
673 else
674 {
675 /* A stop request from an other task is sent during a start connection */
676 /* event error - send an error message */
677 audio_melody_E1_send_status (AUDIO_ERROR,((T_AUDIO_MELODY_E1_STOP *)(p_message))->return_path);
678 audio_melody_E1_error_trace(AUDIO_ERROR_STOP_EVENT);
679 }
680 break;
681 } /* case AUDIO_MELODY_E1_STOP_REQ */
682
683 case AUDIO_MELODY_E1_START_REQ:
684 {
685 /* event error - send an error message*/
686 /* Close the FFS file previously open by the audio start API*/
687 #ifndef _WINDOWS
688 if ( ffs_close(((T_AUDIO_MELODY_E1_START *)(p_message))->audio_ffs_fd) != EFFS_OK )
689 {
690 audio_melody_E1_error_trace(AUDIO_ENTITY_FILE_NO_CLOSE);
691 }
692 #endif
693 audio_melody_E1_send_status (AUDIO_ERROR, ((T_AUDIO_MELODY_E1_START *)(p_message))->return_path);
694 audio_melody_E1_error_trace(AUDIO_ERROR_START_EVENT);
695 break;
696 }
697 }
698 break;
699 } /* case AUDIO_MELODY_E1_WAIT_STOP_COMMAND */
700
701 case AUDIO_MELODY_E1_WAIT_STOP_CON:
702 {
703 switch(p_message->msg_id)
704 {
705 case MMI_MELODY0_STOP_CON:
706 {
707 /* Send FFS stop command */
708 /* allocate the message buffer */
709 mb_status = rvf_get_buf (p_audio_gbl_var->mb_internal,
710 sizeof (T_AUDIO_FFS_STOP_REQ),
711 (T_RVF_BUFFER **) (&p_send_message));
712
713 /* If insufficient resources, then report a memory error and abort. */
714 if (mb_status == RVF_RED)
715 {
716 audio_melody_E1_error_trace(AUDIO_ENTITY_NO_MEMORY);
717 }
718
719 /* fill the header of the message */
720 ((T_AUDIO_FFS_STOP_REQ *)(p_send_message))->os_hdr.msg_id = AUDIO_FFS_STOP_REQ;
721
722 /* fill the parameter */
723 ((T_AUDIO_FFS_STOP_REQ *)(p_send_message))->session_id = AUDIO_FFS_SESSION_MELODY_E1_0;
724
725 /* send the message to the entity */
726 rvf_send_msg (p_audio_gbl_var->audio_ffs_addrId,
727 p_send_message);
728
729 /* change to the state AUDIO_MELODY_0_WAIT_STOP_FFS */
730 p_audio_gbl_var->melody_E1_0.state = AUDIO_MELODY_E1_WAIT_STOP_FFS;
731 break;
732 }
733
734 case AUDIO_MELODY_E1_STOP_REQ:
735 {
736 /* stop event error - send an error message */
737 audio_melody_E1_send_status (AUDIO_ERROR,((T_AUDIO_MELODY_E1_STOP *)(p_message))->return_path);
738 audio_melody_E1_error_trace(AUDIO_ERROR_STOP_EVENT);
739 break;
740 } /* case AUDIO_MELODY_E1_STOP_REQ */
741
742 case AUDIO_MELODY_E1_START_REQ:
743 {
744 /* event error - send an error message*/
745 /* Close the FFS file previously open by the audio start API*/
746 #ifndef _WINDOWS
747 if ( ffs_close(((T_AUDIO_MELODY_E1_START *)(p_message))->audio_ffs_fd) != EFFS_OK )
748 {
749 audio_melody_E1_error_trace(AUDIO_ENTITY_FILE_NO_CLOSE);
750 }
751 #endif
752 audio_melody_E1_send_status (AUDIO_ERROR, ((T_AUDIO_MELODY_E1_START *)(p_message))->return_path);
753 audio_melody_E1_error_trace(AUDIO_ERROR_START_EVENT);
754 break;
755 }
756 }
757 break;
758 } /* case AUDIO_MELODY_E1_WAIT_STOP_CON */
759
760 case AUDIO_MELODY_E1_WAIT_STOP_FFS:
761 {
762 switch(p_message->msg_id)
763 {
764 case AUDIO_FFS_STOP_CON:
765 {
766 audio_melody_E1_send_status (AUDIO_OK, p_audio_gbl_var->melody_E1_0.return_path);
767
768 /* change to the state AUDIO_MELODY_0_IDLE */
769 p_audio_gbl_var->melody_E1_0.state = AUDIO_MELODY_E1_IDLE;
770
771 break;
772 }
773
774 case AUDIO_MELODY_E1_STOP_REQ:
775 {
776 /* stop event error - send an error message */
777 audio_melody_E1_send_status (AUDIO_ERROR,((T_AUDIO_MELODY_E1_STOP *)(p_message))->return_path);
778 audio_melody_E1_error_trace(AUDIO_ERROR_STOP_EVENT);
779 break;
780 } /* case AUDIO_MELODY_E1_STOP_REQ */
781
782 case AUDIO_MELODY_E1_START_REQ:
783 {
784 /* event error - send an error message*/
785 /* Close the FFS file previously open by the audio start API*/
786 #ifndef _WINDOWS
787 if ( ffs_close(((T_AUDIO_MELODY_E1_START *)(p_message))->audio_ffs_fd) != EFFS_OK )
788 {
789 audio_melody_E1_error_trace(AUDIO_ENTITY_FILE_NO_CLOSE);
790 }
791 #endif
792 audio_melody_E1_send_status (AUDIO_ERROR, ((T_AUDIO_MELODY_E1_START *)(p_message))->return_path);
793 audio_melody_E1_error_trace(AUDIO_ERROR_START_EVENT);
794 break;
795 }
796
797 }
798 break;
799 } /* case AUDIO_MELODY_E1_WAIT_STOP_CON */
800 } /* switch(p_audio_gbl_var->melody_E1_0.state) */
801 } /*********************** End of audio_melody_E1_manager_0 function **********************/
802
803 /********************************************************************************/
804 /* */
805 /* Function Name: audio_melody_e1_manager_1 */
806 /* */
807 /* Purpose: This function is called to manage a melody E1 format number 1. */
808 /* */
809 /* Input Parameters: */
810 /* Message to the audo entity */
811 /* */
812 /* Output Parameters: */
813 /* None. */
814 /* */
815 /* Note: */
816 /* None. */
817 /* */
818 /* Revision History: */
819 /* None. */
820 /* */
821 /********************************************************************************/
822 void audio_melody_E1_manager_1 (T_RV_HDR *p_message)
823 {
824 /* Declare local variables. */
825 void *p_send_message;
826 UINT8 i;
827 T_RVF_MB_STATUS mb_status;
828
829 /**************** audio_melody_e1_manager function begins *********************/
830
831 switch(p_audio_gbl_var->melody_E1_1.state)
832 {
833 case AUDIO_MELODY_E1_IDLE:
834 {
835 switch(p_message->msg_id)
836 {
837 case AUDIO_MELODY_E1_START_REQ:
838 {
839 /* save the task id of the entity */
840 p_audio_gbl_var->melody_E1_1.task_id = p_message->src_addr_id;
841
842 /* save the return path */
843 p_audio_gbl_var->melody_E1_1.return_path.callback_func =
844 ((T_AUDIO_MELODY_E1_START*)(p_message))->return_path.callback_func;
845 p_audio_gbl_var->melody_E1_1.return_path.addr_id =
846 ((T_AUDIO_MELODY_E1_START*)(p_message))->return_path.addr_id;
847
848 for (i=0; i<AUDIO_PATH_NAME_MAX_SIZE; i++)
849 {
850 p_audio_gbl_var->melody_E1_1.melody_name[i] =
851 ((T_AUDIO_MELODY_E1_START*)(p_message))->melody_E1_parameter.melody_name[i];
852 }
853
854 p_audio_gbl_var->melody_E1_1.loopback =
855 ((T_AUDIO_MELODY_E1_START*)(p_message))->melody_E1_parameter.loopback;
856
857 /* Send the Start message to the FFS */
858 /* allocate the message buffer */
859 mb_status = rvf_get_buf (p_audio_gbl_var->mb_internal,
860 sizeof (T_AUDIO_FFS_FLASH_2_RAM_START),
861 (T_RVF_BUFFER **) (&p_send_message));
862
863 /* If insufficient resources, then report a memory error and abort. */
864 if (mb_status == RVF_RED)
865 {
866 audio_melody_E1_error_trace(AUDIO_ENTITY_NO_MEMORY);
867 }
868
869 /* fill the header of the message */
870 ((T_AUDIO_FFS_FLASH_2_RAM_START *)(p_send_message))->os_hdr.msg_id = AUDIO_FFS_FLASH_2_RAM_START_REQ;
871
872 /* fill the parameters */
873 ((T_AUDIO_FFS_FLASH_2_RAM_START *)(p_send_message))->audio_ffs_fd =
874 ((T_AUDIO_MELODY_E1_START*)(p_message))->audio_ffs_fd;
875 ((T_AUDIO_FFS_FLASH_2_RAM_START *)(p_send_message))->initial_size = AUDIO_MELODY_E1_SIZE;
876 ((T_AUDIO_FFS_FLASH_2_RAM_START *)(p_send_message))->loop =
877 ((T_AUDIO_MELODY_E1_START*)(p_message))->melody_E1_parameter.loopback;
878
879 ((T_AUDIO_FFS_FLASH_2_RAM_START *)(p_send_message))->session_id = AUDIO_FFS_SESSION_MELODY_E1_1;
880
881 /* send the message to the entity */
882 rvf_send_msg (p_audio_gbl_var->audio_ffs_addrId,
883 p_send_message);
884
885 /* change to the state AUDIO_MELODY_E1_WAIT_INIT_FFS */
886 p_audio_gbl_var->melody_E1_1.state = AUDIO_MELODY_E1_WAIT_INIT_FFS;
887 break;
888 }
889 }
890 break;
891 } /* case AUDIO_MELODY_E1_IDLE */
892
893 case AUDIO_MELODY_E1_WAIT_INIT_FFS:
894 {
895 switch(p_message->msg_id)
896 {
897 case AUDIO_FFS_INIT_DONE:
898 {
899 /* send the start melody message to the L1 */
900 /* allocate the buffer for the message to the L1 */
901 p_send_message = audio_allocate_l1_message(sizeof(T_MMI_MELODY_REQ));
902
903 if ( p_send_message != NULL)
904 {
905 /* Convert the entity parameters to the audio L1 parameters */
906 audio_melody_e1_convert_parameter(((T_AUDIO_FFS_INIT *)(p_message))->channel_id,
907 ((T_MMI_MELODY_REQ *)(p_send_message)),
908 AUDIO_MELODY_E1_1);
909
910 /* send the start command to the audio L1 */
911 audio_send_l1_message(MMI_MELODY1_START_REQ, p_send_message);
912 }
913
914 /* change to the state AUDIO_MELODY_E1_WAIT_START_CONFIRMATION */
915 p_audio_gbl_var->melody_E1_1.state = AUDIO_MELODY_E1_WAIT_START_CON;
916 break;
917 }
918
919 case AUDIO_MELODY_E1_STOP_REQ:
920 {
921 /*.Before stopping this task, control that */
922 /* stop task id caller =Melody task id */
923 if ( p_audio_gbl_var->melody_E1_1.task_id == p_message->src_addr_id)
924 {
925 /* change to the state AUDIO_MELODY_E1_WAIT_INIT_DONE */
926 p_audio_gbl_var->melody_E1_1.state = AUDIO_MELODY_E1_WAIT_INIT_DONE;
927 }
928 else
929 {
930 /* A stop request from an other task is sent during a start connection */
931 /* event error - send an error message */
932 audio_melody_E1_send_status (AUDIO_ERROR,((T_AUDIO_MELODY_E1_STOP *)(p_message))->return_path);
933 audio_melody_E1_error_trace(AUDIO_ERROR_STOP_EVENT);
934 }
935 break;
936 } /* case AUDIO_MELODY_E1_STOP_REQ */
937
938 case AUDIO_MELODY_E1_START_REQ:
939 {
940 /* event error - send an error message*/
941 /* Close the FFS file previously open by the audio start API*/
942 #ifndef _WINDOWS
943 if ( ffs_close(((T_AUDIO_MELODY_E1_START *)(p_message))->audio_ffs_fd) != EFFS_OK )
944 {
945 audio_melody_E1_error_trace(AUDIO_ENTITY_FILE_NO_CLOSE);
946 }
947 #endif
948 audio_melody_E1_send_status (AUDIO_ERROR, ((T_AUDIO_MELODY_E1_START *)(p_message))->return_path);
949 audio_melody_E1_error_trace(AUDIO_ERROR_START_EVENT);
950 break;
951 }
952 }
953 break;
954 } /* case AUDIO_MELODY_E1_WAIT_INIT_FFS */
955
956 case AUDIO_MELODY_E1_WAIT_INIT_DONE:
957 {
958 switch(p_message->msg_id)
959 {
960 case AUDIO_FFS_INIT_DONE:
961 {
962 /* Send FFS stop command */
963 /* allocate the message buffer */
964 mb_status = rvf_get_buf (p_audio_gbl_var->mb_internal,
965 sizeof (T_AUDIO_FFS_STOP_REQ),
966 (T_RVF_BUFFER **) (&p_send_message));
967
968 /* If insufficient resources, then report a memory error and abort. */
969 if (mb_status == RVF_RED)
970 {
971 audio_melody_E1_error_trace(AUDIO_ENTITY_NO_MEMORY);
972 }
973
974 /* fill the header of the message */
975 ((T_AUDIO_FFS_STOP_REQ *)(p_send_message))->os_hdr.msg_id = AUDIO_FFS_STOP_REQ;
976
977 /* fill the parameter */
978 ((T_AUDIO_FFS_STOP_REQ *)(p_send_message))->session_id = AUDIO_FFS_SESSION_MELODY_E1_1;
979
980 /* send the message to the entity */
981 rvf_send_msg (p_audio_gbl_var->audio_ffs_addrId,
982 p_send_message);
983
984 /* change to the state AUDIO_MELODY_E1_WAIT_STOP_FFS */
985 p_audio_gbl_var->melody_E1_1.state = AUDIO_MELODY_E1_WAIT_STOP_FFS;
986 break;
987 }
988
989 case AUDIO_MELODY_E1_STOP_REQ:
990 {
991 /* stop event error - send an error message */
992 audio_melody_E1_send_status (AUDIO_ERROR,((T_AUDIO_MELODY_E1_STOP *)(p_message))->return_path);
993 audio_melody_E1_error_trace(AUDIO_ERROR_STOP_EVENT);
994 break;
995 } /* case AUDIO_MELODY_E1_STOP_REQ */
996
997 case AUDIO_MELODY_E1_START_REQ:
998 {
999 /* event error - send an error message*/
1000 /* Close the FFS file previously open by the audio start API*/
1001 #ifndef _WINDOWS
1002 if ( ffs_close(((T_AUDIO_MELODY_E1_START *)(p_message))->audio_ffs_fd) != EFFS_OK )
1003 {
1004 audio_melody_E1_error_trace(AUDIO_ENTITY_FILE_NO_CLOSE);
1005 }
1006 #endif
1007 audio_melody_E1_send_status (AUDIO_ERROR, ((T_AUDIO_MELODY_E1_START *)(p_message))->return_path);
1008 audio_melody_E1_error_trace(AUDIO_ERROR_START_EVENT);
1009 break;
1010 }
1011 }
1012 break;
1013 } /* case AUDIO_MELODY_E1_WAIT_INIT_DONE*/
1014
1015 case AUDIO_MELODY_E1_WAIT_START_CON:
1016 {
1017 switch(p_message->msg_id)
1018 {
1019 case MMI_MELODY1_START_CON:
1020 {
1021 /* change to the state AUDIO_MELODY_E1_WAIT_STOP_COMMAND */
1022 p_audio_gbl_var->melody_E1_1.state = AUDIO_MELODY_E1_WAIT_STOP_COMMAND;
1023 break;
1024 }
1025
1026 case AUDIO_MELODY_E1_STOP_REQ:
1027 {
1028 /*.Before stopping this task, control that */
1029 /* stop task id caller =Melody task id */
1030 if ( p_audio_gbl_var->melody_E1_1.task_id == p_message->src_addr_id)
1031 {
1032 /* change to the state AUDIO_MELODY_E1_WAIT_STOP_CONFIRMATION */
1033 p_audio_gbl_var->melody_E1_1.state = AUDIO_MELODY_E1_WAIT_START_CON_TO_STOP;
1034 }
1035 else
1036 {
1037 /* A stop request from an other task is sent during a start connection */
1038 /* event error - send an error message */
1039 audio_melody_E1_send_status (AUDIO_ERROR,((T_AUDIO_MELODY_E1_STOP *)(p_message))->return_path);
1040 audio_melody_E1_error_trace(AUDIO_ERROR_STOP_EVENT);
1041 }
1042 break;
1043 } /* case AUDIO_MELODY_E1_STOP_REQ */
1044
1045 case AUDIO_MELODY_E1_START_REQ:
1046 {
1047 /* event error - send an error message*/
1048 /* Close the FFS file previously open by the audio start API*/
1049 #ifndef _WINDOWS
1050 if ( ffs_close(((T_AUDIO_MELODY_E1_START *)(p_message))->audio_ffs_fd) != EFFS_OK )
1051 {
1052 audio_melody_E1_error_trace(AUDIO_ENTITY_FILE_NO_CLOSE);
1053 }
1054 #endif
1055 audio_melody_E1_send_status (AUDIO_ERROR, ((T_AUDIO_MELODY_E1_START *)(p_message))->return_path);
1056 audio_melody_E1_error_trace(AUDIO_ERROR_START_EVENT);
1057 break;
1058 }
1059 }
1060 break;
1061 } /* case AUDIO_WAIT_START_CON */
1062
1063 case AUDIO_MELODY_E1_WAIT_START_CON_TO_STOP:
1064 {
1065 switch(p_message->msg_id)
1066 {
1067 case MMI_MELODY1_START_CON:
1068 {
1069 /* send the stop command to the audio L1 */
1070 /* allocate the buffer for the message to the L1 */
1071 p_send_message = audio_allocate_l1_message(0);
1072 if ( p_send_message != NULL)
1073 {
1074 /* send the start command to the audio L1 */
1075 audio_send_l1_message(MMI_MELODY1_STOP_REQ, p_send_message);
1076 }
1077
1078 /* change to the state AUDIO_MELODY_E1_WAIT_STOP_CON */
1079 p_audio_gbl_var->melody_E1_1.state = AUDIO_MELODY_E1_WAIT_STOP_CON;
1080 break;
1081 }
1082
1083 case AUDIO_MELODY_E1_STOP_REQ:
1084 {
1085 /* stop event error - send an error message */
1086 audio_melody_E1_send_status (AUDIO_ERROR,((T_AUDIO_MELODY_E1_STOP *)(p_message))->return_path);
1087 audio_melody_E1_error_trace(AUDIO_ERROR_STOP_EVENT);
1088 break;
1089 } /* case AUDIO_MELODY_E1_STOP_REQ */
1090
1091 case AUDIO_MELODY_E1_START_REQ:
1092 {
1093 /* start event error - send an error message*/
1094 /* Close the FFS file previously open by the audio start API*/
1095 #ifndef _WINDOWS
1096 if ( ffs_close(((T_AUDIO_MELODY_E1_START *)(p_message))->audio_ffs_fd) != EFFS_OK )
1097 {
1098 audio_melody_E1_error_trace(AUDIO_ENTITY_FILE_NO_CLOSE);
1099 }
1100 #endif
1101 audio_melody_E1_send_status (AUDIO_ERROR, ((T_AUDIO_MELODY_E1_START *)(p_message))->return_path);
1102 audio_melody_E1_error_trace(AUDIO_ERROR_START_EVENT);
1103 break;
1104 }
1105 }
1106 break;
1107 }
1108
1109 case AUDIO_MELODY_E1_WAIT_STOP_COMMAND:
1110 {
1111 switch(p_message->msg_id)
1112 {
1113 case MMI_MELODY1_STOP_CON:
1114 {
1115 /* Send FFS stop command */
1116 /* allocate the message buffer */
1117 mb_status = rvf_get_buf (p_audio_gbl_var->mb_internal,
1118 sizeof (T_AUDIO_FFS_STOP_REQ),
1119 (T_RVF_BUFFER **) (&p_send_message));
1120
1121 /* If insufficient resources, then report a memory error and abort. */
1122 if (mb_status == RVF_RED)
1123 {
1124 audio_melody_E1_error_trace(AUDIO_ENTITY_NO_MEMORY);
1125 }
1126
1127 /* fill the header of the message */
1128 ((T_AUDIO_FFS_STOP_REQ *)(p_send_message))->os_hdr.msg_id = AUDIO_FFS_STOP_REQ;
1129
1130 /* fill the parameter */
1131 ((T_AUDIO_FFS_STOP_REQ *)(p_send_message))->session_id = AUDIO_FFS_SESSION_MELODY_E1_1;
1132
1133 /* send the message to the entity */
1134 rvf_send_msg (p_audio_gbl_var->audio_ffs_addrId,
1135 p_send_message);
1136
1137 /* change to the state AUDIO_MELODY_E1_WAIT_STOP_FFS */
1138 p_audio_gbl_var->melody_E1_1.state = AUDIO_MELODY_E1_WAIT_STOP_FFS;
1139 break;
1140 }
1141
1142 case AUDIO_MELODY_E1_STOP_REQ:
1143 {
1144 /*.Before stopping this task, control that */
1145 /* stop task id caller =Melody task id */
1146 if ( p_audio_gbl_var->melody_E1_1.task_id == p_message->src_addr_id)
1147 {
1148 /* send the stop command to the audio L1 */
1149 /* allocate the buffer for the message to the L1 */
1150 p_send_message = audio_allocate_l1_message(0);
1151 if (p_send_message != NULL)
1152 {
1153 /* send the start command to the audio L1 */
1154 audio_send_l1_message(MMI_MELODY1_STOP_REQ, p_send_message);
1155 }
1156
1157 /* change to the state AUDIO_MELODY_E1_WAIT_STOP_CONFIRMATION */
1158 p_audio_gbl_var->melody_E1_1.state = AUDIO_MELODY_E1_WAIT_STOP_CON;
1159 }
1160 else
1161 {
1162 /* A stop request from an other task is sent during a start connection */
1163 /* event error - send an error message */
1164 audio_melody_E1_send_status (AUDIO_ERROR,((T_AUDIO_MELODY_E1_STOP *)(p_message))->return_path);
1165 audio_melody_E1_error_trace(AUDIO_ERROR_STOP_EVENT);
1166 }
1167 break;
1168 } /* case AUDIO_MELODY_E1_STOP_REQ */
1169
1170 case AUDIO_MELODY_E1_START_REQ:
1171 {
1172 /* event error - send an error message*/
1173 /* Close the FFS file previously open by the audio start API*/
1174 #ifndef _WINDOWS
1175 if ( ffs_close(((T_AUDIO_MELODY_E1_START *)(p_message))->audio_ffs_fd) != EFFS_OK )
1176 {
1177 audio_melody_E1_error_trace(AUDIO_ENTITY_FILE_NO_CLOSE);
1178 }
1179 #endif
1180 audio_melody_E1_send_status (AUDIO_ERROR, ((T_AUDIO_MELODY_E1_START *)(p_message))->return_path);
1181 audio_melody_E1_error_trace(AUDIO_ERROR_START_EVENT);
1182 break;
1183 }
1184 }
1185 break;
1186 } /* case AUDIO_MELODY_E1_WAIT_STOP_COMMAND */
1187
1188 case AUDIO_MELODY_E1_WAIT_STOP_CON:
1189 {
1190 switch(p_message->msg_id)
1191 {
1192 case MMI_MELODY1_STOP_CON:
1193 {
1194 /* Send FFS stop command */
1195 /* allocate the message buffer */
1196 mb_status = rvf_get_buf (p_audio_gbl_var->mb_internal,
1197 sizeof (T_AUDIO_FFS_STOP_REQ),
1198 (T_RVF_BUFFER **) (&p_send_message));
1199
1200 /* If insufficient resources, then report a memory error and abort. */
1201 if (mb_status == RVF_RED)
1202 {
1203 audio_melody_E1_error_trace(AUDIO_ENTITY_NO_MEMORY);
1204 }
1205
1206 /* fill the header of the message */
1207 ((T_AUDIO_FFS_STOP_REQ *)(p_send_message))->os_hdr.msg_id = AUDIO_FFS_STOP_REQ;
1208
1209 /* fill the parameter */
1210 ((T_AUDIO_FFS_STOP_REQ *)(p_send_message))->session_id = AUDIO_FFS_SESSION_MELODY_E1_1;
1211
1212 /* send the message to the entity */
1213 rvf_send_msg (p_audio_gbl_var->audio_ffs_addrId,
1214 p_send_message);
1215
1216 /* change to the state AUDIO_MELODY_1_WAIT_STOP_FFS */
1217 p_audio_gbl_var->melody_E1_1.state = AUDIO_MELODY_E1_WAIT_STOP_FFS;
1218 break;
1219 }
1220 case AUDIO_MELODY_E1_STOP_REQ:
1221 {
1222 /* event error - send an error message */
1223 audio_melody_E1_send_status (AUDIO_ERROR,((T_AUDIO_MELODY_E1_STOP *)(p_message))->return_path);
1224 audio_melody_E1_error_trace(AUDIO_ERROR_STOP_EVENT);
1225 break;
1226 } /* case AUDIO_MELODY_E1_STOP_REQ */
1227
1228 case AUDIO_MELODY_E1_START_REQ:
1229 {
1230 /* event error - send an error message*/
1231 /* Close the FFS file previously open by the audio start API*/
1232 #ifndef _WINDOWS
1233 if ( ffs_close(((T_AUDIO_MELODY_E1_START *)(p_message))->audio_ffs_fd) != EFFS_OK )
1234 {
1235 audio_melody_E1_error_trace(AUDIO_ENTITY_FILE_NO_CLOSE);
1236 }
1237 #endif
1238 audio_melody_E1_send_status (AUDIO_ERROR, ((T_AUDIO_MELODY_E1_START *)(p_message))->return_path);
1239 audio_melody_E1_error_trace(AUDIO_ERROR_START_EVENT);
1240 break;
1241 }
1242
1243 }
1244 break;
1245 } /* case AUDIO_MELODY_E1_WAIT_STOP_CON */
1246
1247 case AUDIO_MELODY_E1_WAIT_STOP_FFS:
1248 {
1249 switch(p_message->msg_id)
1250 {
1251 case AUDIO_FFS_STOP_CON:
1252 {
1253 audio_melody_E1_send_status (AUDIO_OK, p_audio_gbl_var->melody_E1_1.return_path);
1254
1255 /* change to the state AUDIO_MELODY_1_IDLE */
1256 p_audio_gbl_var->melody_E1_1.state = AUDIO_MELODY_E1_IDLE;
1257
1258 break;
1259 }
1260 case AUDIO_MELODY_E1_STOP_REQ:
1261 {
1262 /* event error - send an error message */
1263 audio_melody_E1_send_status (AUDIO_ERROR,((T_AUDIO_MELODY_E1_STOP *)(p_message))->return_path);
1264 audio_melody_E1_error_trace(AUDIO_ERROR_STOP_EVENT);
1265 break;
1266 } /* case AUDIO_MELODY_E1_STOP_REQ */
1267
1268 case AUDIO_MELODY_E1_START_REQ:
1269 {
1270 /* event error - send an error message*/
1271 /* Close the FFS file previously open by the audio start API*/
1272 #ifndef _WINDOWS
1273 if ( ffs_close(((T_AUDIO_MELODY_E1_START *)(p_message))->audio_ffs_fd) != EFFS_OK )
1274 {
1275 audio_melody_E1_error_trace(AUDIO_ENTITY_FILE_NO_CLOSE);
1276 }
1277 #endif
1278 audio_melody_E1_send_status (AUDIO_ERROR, ((T_AUDIO_MELODY_E1_START *)(p_message))->return_path);
1279 audio_melody_E1_error_trace(AUDIO_ERROR_START_EVENT);
1280 break;
1281 }
1282 }
1283 break;
1284 } /* case AUDIO_MELODY_E1_WAIT_STOP_CON */
1285 } /* switch(p_audio_gbl_var->melody_E1_1.state) */
1286 } /*********************** End of audio_melody_E1_manager_1 function **********************/
1287
1288 #endif /* MELODY_E1 */
1289 #endif /* RVM_AUDIO_MAIN_SWE */