comparison src/cs/services/Audio/audio_vm_record.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_vm_record.c */
4 /* */
5 /* Purpose: This file contains all the functions used to manage the */
6 /* Voice Memorization recording task. */
7 /* */
8 /* Version 0.1 */
9 /* */
10 /* Date Modification */
11 /* ------------------------------------ */
12 /* 1 August 2001 Create */
13 /* */
14 /* Author */
15 /* 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 (VOICE_MEMO)
32 #include <math.h>
33 #include "rv/rv_general.h"
34 #include "rvm/rvm_gen.h"
35 #include "audio/audio_features_i.h"
36 #include "audio/audio_ffs_i.h"
37 #include "audio/audio_api.h"
38 #include "audio/audio_structs_i.h"
39 #include "audio/audio_var_i.h"
40 #include "audio/audio_messages_i.h"
41 #include "rvf/rvf_target.h"
42 #include "audio/audio_const_i.h"
43 #include "audio/audio_error_hdlr_i.h"
44
45 /* include the usefull L1 header */
46 #define BOOL_FLAG
47 #define CHAR_FLAG
48 #include "l1_types.h"
49 #include "l1audio_cust.h"
50 #include "l1audio_msgty.h"
51 #include "l1audio_signa.h"
52
53 /********************************************************************************/
54 /* */
55 /* Function Name: audio_vm_record_send_status */
56 /* */
57 /* Purpose: This function sends the voice memorization record status */
58 /* 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_vm_record_send_status ( T_AUDIO_RET status,
75 UINT32 recorded_size,
76 T_RV_RETURN return_path)
77 {
78 void *p_send_message;
79 T_RVF_MB_STATUS mb_status = RVF_RED;
80
81 while (mb_status == RVF_RED)
82 {
83 /* allocate the message buffer */
84 mb_status = rvf_get_buf (p_audio_gbl_var->mb_external,
85 sizeof (T_AUDIO_VM_RECORD_STATUS),
86 (T_RVF_BUFFER **) (&p_send_message));
87
88 /* If insufficient resources, then report a memory error and abort. */
89 /* and wait until more ressource is given */
90 if (mb_status == RVF_RED)
91 {
92 audio_voice_memo_error_trace(AUDIO_ENTITY_NO_MEMORY);
93 rvf_delay(RVF_MS_TO_TICKS(1000));
94 }
95 }
96
97 /*fill the header of the message */
98 ((T_AUDIO_VM_RECORD_STATUS *)(p_send_message))->os_hdr.msg_id = AUDIO_VM_RECORD_STATUS_MSG;
99
100 /* fill the status parameters */
101 ((T_AUDIO_VM_RECORD_STATUS *)(p_send_message))->status = status;
102 if (recorded_size == 0)
103 {
104 ((T_AUDIO_VM_RECORD_STATUS *)(p_send_message))->recorded_duration = 0;
105 }
106 else
107 {
108 ((T_AUDIO_VM_RECORD_STATUS *)(p_send_message))->recorded_duration = (UINT16)((recorded_size - 1) / 1000);
109 }
110
111 if (return_path.callback_func == NULL)
112 {
113 /* send the message to the entity */
114 rvf_send_msg (return_path.addr_id,
115 p_send_message);
116 }
117 else
118 {
119 /* call the callback function */
120 (*return_path.callback_func)((void *)(p_send_message));
121 rvf_free_buf((T_RVF_BUFFER *)p_send_message);
122 }
123 }
124
125
126 /********************************************************************************/
127 /* */
128 /* Function Name: audio_vm_record_convert_parameter */
129 /* */
130 /* Purpose: Convert the voice memorization record parameters from the */
131 /* entity to the l1 parameters */
132 /* */
133 /* Input Parameters: */
134 /* session_id of the voice memo record */
135 /* id of the voice memo record */
136 /* */
137 /* Output Parameters: */
138 /* layer 1 voice memo record message */
139 /* */
140 /* Note: */
141 /* None. */
142 /* */
143 /* Revision History: */
144 /* None. */
145 /* */
146 /********************************************************************************/
147 void audio_vm_record_convert_parameter( UINT8 channel_id,
148 T_AUDIO_VM_RECORD_START *entity_parameter,
149 T_MMI_VM_RECORD_REQ *l1_parameter)
150 {
151 double frequency_index, frequency_beep, amplitude_beep, amplitude, amplitude_index;
152
153 /* session id : specifies the customer data identification corresponding to */
154 /* this voice memorization */
155 l1_parameter->session_id = channel_id;
156 l1_parameter->maximum_size =
157 (entity_parameter->memo_duration)*1000 + 1;
158 l1_parameter->dtx_used = (BOOL)(entity_parameter->compression_mode);
159 l1_parameter->record_coeff_ul = (UINT16)(entity_parameter->microphone_gain);
160 l1_parameter->record_coeff_dl = (UINT16)(entity_parameter->network_gain);
161
162 /* Calculation of the frequency index */
163 /* note: we /* add +0.5 to compensate the truncation */
164 frequency_beep = (double)(entity_parameter->tones_parameter.tones[0].frequency_tone);
165 frequency_index = (256 * cos(6.283185*(frequency_beep/8000)));
166 /* Calculation of the amplitude index */
167 /* note: we /* add +0.5 to compensate the truncation */
168 amplitude_beep = (double)(entity_parameter->tones_parameter.tones[0].amplitude_tone);
169 amplitude = exp((amplitude_beep*0.115129)+(5.544625));
170 amplitude_index = amplitude * sin(6.283185*(frequency_beep/8000));
171
172 l1_parameter->d_k_x1_t0 = (UINT16)((((UINT16)(frequency_index))<<8) | ((UINT16)(amplitude_index)));
173
174 /* Calculation of the frequency index */
175 /* note: we /* add +0.5 to compensate the truncation */
176 frequency_beep = (double)(entity_parameter->tones_parameter.tones[1].frequency_tone);
177 frequency_index = (256 * cos(6.283185*(frequency_beep/8000)));
178 /* Calculation of the amplitude index */
179 /* note: we /* add +0.5 to compensate the truncation */
180 amplitude_beep = (double)(entity_parameter->tones_parameter.tones[1].amplitude_tone);
181 amplitude = exp((amplitude_beep*0.115129)+(5.544625));
182 amplitude_index = amplitude * sin(6.283185*(frequency_beep/8000));
183
184 l1_parameter->d_k_x1_t1 = (UINT16)((((UINT16)(frequency_index))<<8) | ((UINT16)(amplitude_index)));
185
186 /* Calculation of the frequency index */
187 /* note: we /* add +0.5 to compensate the truncation */
188 frequency_beep = (double)(entity_parameter->tones_parameter.tones[2].frequency_tone);
189 frequency_index = (256 * cos(6.283185*(frequency_beep/8000)));
190 /* Calculation of the amplitude index */
191 /* note: we /* add +0.5 to compensate the truncation */
192 amplitude_beep = (double)(entity_parameter->tones_parameter.tones[2].amplitude_tone);
193 amplitude = exp((amplitude_beep*0.115129)+(5.544625));
194 amplitude_index = amplitude * sin(6.283185*(frequency_beep/8000));
195
196 l1_parameter->d_k_x1_t2 = (UINT16)((((UINT16)(frequency_index))<<8) | ((UINT16)(amplitude_index)));
197
198 l1_parameter->d_t0_on = (UINT16)((entity_parameter->tones_parameter.tones[0].start_tone)/20);
199 l1_parameter->d_t1_on = (UINT16)((entity_parameter->tones_parameter.tones[1].start_tone)/20);
200 l1_parameter->d_t2_on = (UINT16)((entity_parameter->tones_parameter.tones[2].start_tone)/20);
201
202 l1_parameter->d_t0_off = (UINT16)((entity_parameter->tones_parameter.tones[0].stop_tone)/20);
203 l1_parameter->d_t1_off = (UINT16)((entity_parameter->tones_parameter.tones[1].stop_tone)/20);
204 l1_parameter->d_t2_off = (UINT16)((entity_parameter->tones_parameter.tones[2].stop_tone)/20);
205
206 l1_parameter->d_bu_off = (UINT16)((entity_parameter->tones_parameter.frame_duration)/20);
207
208 l1_parameter->d_se_off = (UINT16)((entity_parameter->tones_parameter.sequence_duration)/20);
209
210 l1_parameter->d_pe_off = (UINT16)((entity_parameter->tones_parameter.period_duration)/20);
211
212 l1_parameter->d_pe_rep = entity_parameter->tones_parameter.repetition;
213 }
214
215
216
217 /********************************************************************************/
218 /* */
219 /* Function Name: audio_vm_record_manager */
220 /* */
221 /* Purpose: This function is called to manage a voice memorization record */
222 /* manager */
223 /* */
224 /* Input Parameters: */
225 /* Message to the audio entity */
226 /* */
227 /* Output Parameters: */
228 /* None. */
229 /* */
230 /* Note: */
231 /* None. */
232 /* */
233 /* Revision History: */
234 /* None. */
235 /* */
236 /********************************************************************************/
237 void audio_vm_record_manager (T_RV_HDR *p_message)
238 {
239 /* Declare local variables. */
240 void *p_send_message;
241 T_RVF_MB_STATUS mb_status;
242
243 /**************** audio_vm_record_manager function begins ***********************/
244
245 switch(p_audio_gbl_var->vm_record.state)
246 {
247 case AUDIO_VM_RECORD_IDLE:
248 {
249 switch(p_message->msg_id)
250 {
251 case AUDIO_VM_RECORD_START_REQ:
252 {
253 /* save the task id of the entity */
254 p_audio_gbl_var->vm_record.task_id = p_message->src_addr_id;
255
256 /* save the return path */
257 p_audio_gbl_var->vm_record.return_path.callback_func =
258 ((T_AUDIO_VM_RECORD_START*)(p_message))->return_path.callback_func;
259 p_audio_gbl_var->vm_record.return_path.addr_id =
260 ((T_AUDIO_VM_RECORD_START*)(p_message))->return_path.addr_id;
261
262 /* Send the Start message to the FFS */
263 /* allocate the message buffer */
264 mb_status = rvf_get_buf (p_audio_gbl_var->mb_internal,
265 sizeof (T_AUDIO_FFS_RAM_2_FLASH_START),
266 (T_RVF_BUFFER **) (&p_send_message));
267
268 /* If insufficient resources, then report a memory error and abort. */
269 if (mb_status == RVF_RED)
270 {
271 audio_voice_memo_error_trace(AUDIO_ENTITY_NO_MEMORY);
272 }
273
274 /* fill the header of the message */
275 ((T_AUDIO_FFS_RAM_2_FLASH_START *)(p_send_message))->os_hdr.msg_id = AUDIO_FFS_RAM_2_FLASH_START_REQ;
276
277 /* fill the parameters */
278 ((T_AUDIO_FFS_RAM_2_FLASH_START *)(p_send_message))->audio_ffs_fd =
279 ((T_AUDIO_VM_RECORD_START*)(p_message))->audio_ffs_fd;
280 ((T_AUDIO_FFS_RAM_2_FLASH_START *)(p_send_message))->initial_size =
281 AUDIO_VM_RECORD_INITIAL_SIZE;
282 ((T_AUDIO_FFS_RAM_2_FLASH_START *)(p_send_message))->session_id = AUDIO_FFS_SESSION_VM_RECORD;
283
284 /* allocate the buffer for the message to the L1 */
285 p_audio_gbl_var->vm_record.p_l1_send_message =
286 audio_allocate_l1_message(sizeof(T_MMI_VM_RECORD_REQ));
287
288 if ( p_audio_gbl_var->vm_record.p_l1_send_message != NULL )
289 {
290 /* Convert the entity parameters to the audio L1 parameters */
291 audio_vm_record_convert_parameter( ((T_AUDIO_FFS_RAM_2_FLASH_START *)(p_send_message))->session_id,
292 ((T_AUDIO_VM_RECORD_START*)(p_message)),
293 ((T_MMI_VM_RECORD_REQ *)(p_audio_gbl_var->vm_record.p_l1_send_message)));
294
295 }
296
297 /* send the message to the entity */
298 rvf_send_msg ( p_audio_gbl_var->audio_ffs_addrId,
299 p_send_message);
300
301 /* change to the state AUDIO_VM_RECORD_WAIT_INIT_FFS */
302 p_audio_gbl_var->vm_record.state = AUDIO_VM_RECORD_WAIT_INIT_FFS;
303 break;
304 }
305 /* A stop request is sent during a start connection */
306 /* event error - send an error message, the recorded size is null */
307 case AUDIO_VM_RECORD_STOP_REQ:
308 {
309 audio_vm_record_send_status ( AUDIO_ERROR, 0,
310 ((T_AUDIO_VM_RECORD_STOP *)(p_message))->return_path);
311 audio_voice_memo_error_trace(AUDIO_ERROR_STOP_EVENT);
312 break;
313 } /* case AUDIO_VM_RECORD_STOP_REQ */
314 }
315 break;
316 } /* case AUDIO_VM_RECORD_IDLE */
317
318 case AUDIO_VM_RECORD_WAIT_INIT_FFS:
319 {
320 switch(p_message->msg_id)
321 {
322 case AUDIO_FFS_INIT_DONE:
323 {
324 /* set the channel_id */
325 ((T_MMI_VM_RECORD_REQ *)p_audio_gbl_var->vm_record.p_l1_send_message)->session_id =
326 ((T_AUDIO_FFS_INIT *)p_message)->channel_id;
327
328 /* send the start voice memo record message to the L1 */
329 audio_send_l1_message( MMI_VM_RECORD_START_REQ, p_audio_gbl_var->vm_record.p_l1_send_message);
330
331 /* change to the state AUDIO_VM_RECORD_WAIT_START_CONFIRMATION */
332 p_audio_gbl_var->vm_record.state = AUDIO_VM_RECORD_WAIT_START_CON;
333 break;
334 }
335
336 case AUDIO_VM_RECORD_STOP_REQ:
337 {
338 /*.Before stopping this task, control that */
339 /* stop task id caller = Voice Memorization task id */
340 if ( p_audio_gbl_var->vm_record.task_id == p_message->src_addr_id)
341 {
342 /* Deallocate the L1 message previously allocated */
343 audio_deallocate_l1_message(p_audio_gbl_var->vm_record.p_l1_send_message);
344
345 /* change to the state AUDIO_VM_RECORD_WAIT_INIT_DONE */
346 p_audio_gbl_var->vm_record.state = AUDIO_VM_RECORD_WAIT_INIT_DONE;
347 }
348 else
349 {
350 /* A stop request from an other task is sent during a start connection */
351 /* event error - send an error message, the recorded size is null */
352 audio_vm_record_send_status ( AUDIO_ERROR, 0,
353 ((T_AUDIO_VM_RECORD_STOP *)(p_message))->return_path);
354 audio_voice_memo_error_trace(AUDIO_ERROR_STOP_EVENT);
355 }
356 break;
357 } /* case AUDIO_VM_RECORD_STOP_REQ */
358 case AUDIO_VM_RECORD_START_REQ:
359 {
360 /* event error - send an error message, the recorded size is null*/
361 /* Close the FFS file previously open by the audio start API*/
362 #ifndef _WINDOWS
363 if ( ffs_close(((T_AUDIO_VM_RECORD_START *)(p_message))->audio_ffs_fd) != EFFS_OK )
364 {
365 audio_voice_memo_error_trace(AUDIO_ENTITY_FILE_NO_CLOSE);
366 }
367 #endif
368 audio_vm_record_send_status ( AUDIO_ERROR, 0,
369 ((T_AUDIO_VM_RECORD_START *)(p_message))->return_path);
370 audio_voice_memo_error_trace(AUDIO_ERROR_START_EVENT);
371 break;
372 }
373
374 } /* switch */
375 break;
376 } /* case AUDIO_VM_RECORD_E1_WAIT_INIT_FFS */
377
378 case AUDIO_VM_RECORD_WAIT_INIT_DONE:
379 {
380 switch(p_message->msg_id)
381 {
382 case AUDIO_FFS_INIT_DONE:
383
384 {
385 /* Send FFS stop command */
386 /* allocate the message buffer */
387 mb_status = rvf_get_buf (p_audio_gbl_var->mb_internal,
388 sizeof (T_AUDIO_FFS_STOP_REQ),
389 (T_RVF_BUFFER **) (&p_send_message));
390
391 /* If insufficient resources, then report a memory error and abort. */
392 if (mb_status == RVF_RED)
393 {
394 audio_voice_memo_error_trace(AUDIO_ENTITY_NO_MEMORY);
395 }
396
397 /* fill the header of the message */
398 ((T_AUDIO_FFS_STOP_REQ *)(p_send_message))->os_hdr.msg_id = AUDIO_FFS_STOP_REQ;
399
400 /* fill the parameter */
401 ((T_AUDIO_FFS_STOP_REQ *)(p_send_message))->session_id = AUDIO_FFS_SESSION_VM_RECORD;
402
403 /* send the message to the entity */
404 rvf_send_msg (p_audio_gbl_var->audio_ffs_addrId,
405 p_send_message);
406
407 /* change to the state AUDIO_VM_RECORD_WAIT_STOP_FFS */
408 p_audio_gbl_var->vm_record.state = AUDIO_VM_RECORD_WAIT_STOP_FFS;
409 break;
410 }
411 case AUDIO_VM_RECORD_START_REQ:
412 {
413 /* event error - send an error message, the recorded size is null*/
414 /* Close the FFS file previously open by the audio start API*/
415 #ifndef _WINDOWS
416 if ( ffs_close(((T_AUDIO_VM_RECORD_START *)(p_message))->audio_ffs_fd) != EFFS_OK )
417 {
418 audio_voice_memo_error_trace(AUDIO_ENTITY_FILE_NO_CLOSE);
419 }
420 #endif
421 audio_vm_record_send_status ( AUDIO_ERROR, 0,
422 ((T_AUDIO_VM_RECORD_START *)(p_message))->return_path);
423 audio_voice_memo_error_trace(AUDIO_ERROR_START_EVENT);
424 break;
425 }
426 case AUDIO_VM_RECORD_STOP_REQ:
427 {
428 /* event error - send an error message, the recorded size is null*/
429 audio_vm_record_send_status ( AUDIO_ERROR, 0,
430 ((T_AUDIO_VM_RECORD_STOP *)(p_message))->return_path);
431 audio_voice_memo_error_trace(AUDIO_ERROR_STOP_EVENT);
432 break;
433 }
434 }
435 break;
436 } /* case AUDIO_VM_RECORD_WAIT_INIT_DONE*/
437
438 case AUDIO_VM_RECORD_WAIT_START_CON:
439 {
440 switch(p_message->msg_id)
441 {
442 case MMI_VM_RECORD_START_CON:
443 {
444 /* change to the state AUDIO_VM_RECORD_WAIT_STOP_COMMAND */
445 p_audio_gbl_var->vm_record.state = AUDIO_VM_RECORD_WAIT_STOP_COMMAND;
446 break;
447 }
448 case AUDIO_VM_RECORD_STOP_REQ:
449 { /*.Before stopping this task, control that */
450 /* stop task id caller = voice memo task id */
451 if ( p_audio_gbl_var->vm_record.task_id == p_message->src_addr_id)
452 {
453 /* change to the state AUDIO_VM_RECORD_WAIT_STOP_CONFIRMATION */
454 p_audio_gbl_var->vm_record.state = AUDIO_VM_RECORD_WAIT_START_CON_TO_STOP;
455 }
456 else
457 {
458 /* A stop request from an other task is sent during a start connection */
459 /* event error - send an error message, the recorded size is null */
460 audio_vm_record_send_status ( AUDIO_ERROR, 0,
461 ((T_AUDIO_VM_RECORD_STOP *)(p_message))->return_path);
462 audio_voice_memo_error_trace(AUDIO_ERROR_STOP_EVENT);
463 }
464 break;
465 }
466 case AUDIO_VM_RECORD_START_REQ:
467 {
468 /* event error - send an error message, the recorded size is null*/
469 /* Close the FFS file previously open by the audio start API*/
470 #ifndef _WINDOWS
471 if ( ffs_close(((T_AUDIO_VM_RECORD_START *)(p_message))->audio_ffs_fd) != EFFS_OK )
472 {
473 audio_voice_memo_error_trace(AUDIO_ENTITY_FILE_NO_CLOSE);
474 }
475 #endif
476 audio_vm_record_send_status ( AUDIO_ERROR, 0,
477 ((T_AUDIO_VM_RECORD_START *)(p_message))->return_path);
478 audio_voice_memo_error_trace(AUDIO_ERROR_START_EVENT);
479 break;
480 }
481 }
482 break;
483 } /* case AUDIO_VM_RECORD_WAIT_START_CON */
484
485 case AUDIO_VM_RECORD_WAIT_START_CON_TO_STOP:
486 {
487 switch(p_message->msg_id)
488 {
489 case MMI_VM_RECORD_START_CON:
490 {
491 /* send the stop command to the audio L1 */
492 /* allocate the buffer for the message to the L1 */
493 p_send_message = audio_allocate_l1_message(0);
494 if ( p_send_message != NULL)
495 {
496 /* send the stop command to the audio L1 */
497 audio_send_l1_message(MMI_VM_RECORD_STOP_REQ, p_send_message);
498 }
499
500 /* change to the state AUDIO_VM_RECORD_WAIT_STOP_CON */
501 p_audio_gbl_var->vm_record.state = AUDIO_VM_RECORD_WAIT_STOP_CON;
502 break;
503 }
504 case AUDIO_VM_RECORD_START_REQ:
505 {
506 /* event error - send an error message the recorded size is null*/
507 /* Close the FFS file previously open by the audio start API*/
508 #ifndef _WINDOWS
509 if ( ffs_close(((T_AUDIO_VM_RECORD_START *)(p_message))->audio_ffs_fd) != EFFS_OK )
510 {
511 audio_voice_memo_error_trace(AUDIO_ENTITY_FILE_NO_CLOSE);
512 }
513 #endif
514 audio_vm_record_send_status ( AUDIO_ERROR, 0,
515 ((T_AUDIO_VM_RECORD_START *)(p_message))->return_path);
516 audio_voice_memo_error_trace(AUDIO_ERROR_START_EVENT);
517 break;
518 }
519 case AUDIO_VM_RECORD_STOP_REQ:
520 {
521 /* event error - send an error message, the recorded size is null*/
522 audio_vm_record_send_status ( AUDIO_ERROR, 0,
523 ((T_AUDIO_VM_RECORD_STOP *)(p_message))->return_path);
524 audio_voice_memo_error_trace(AUDIO_ERROR_STOP_EVENT);
525 break;
526 }
527
528 }
529 break;
530 } /* case AUDIO_VM_RECORD_WAIT_START_CON_TO_STOP */
531
532 case AUDIO_VM_RECORD_WAIT_STOP_COMMAND:
533 {
534 switch(p_message->msg_id)
535 {
536 case MMI_VM_RECORD_STOP_CON:
537 {
538 /* Send FFS stop command */
539 /* allocate the message buffer */
540 mb_status = rvf_get_buf (p_audio_gbl_var->mb_internal,
541 sizeof (T_AUDIO_FFS_STOP_REQ),
542 (T_RVF_BUFFER **) (&p_send_message));
543
544 /* If insufficient resources, then report a memory error and abort. */
545 if (mb_status == RVF_RED)
546 {
547 audio_voice_memo_error_trace(AUDIO_ENTITY_NO_MEMORY);
548 }
549
550 /* fill the header of the message */
551 ((T_AUDIO_FFS_STOP_REQ *)(p_send_message))->os_hdr.msg_id = AUDIO_FFS_STOP_REQ;
552
553 /* fill the parameter */
554 ((T_AUDIO_FFS_STOP_REQ *)(p_send_message))->session_id = AUDIO_FFS_SESSION_VM_RECORD;
555
556 /* fill the recorded size */
557 p_audio_gbl_var->vm_record.recorded_size = ((T_MMI_VM_RECORD_CON *)p_message)->recorded_size;
558
559 /* send the message to the entity */
560 rvf_send_msg (p_audio_gbl_var->audio_ffs_addrId,
561 p_send_message);
562
563 /* change to the state AUDIO_VM_RECORD_WAIT_STOP_FFS */
564 p_audio_gbl_var->vm_record.state = AUDIO_VM_RECORD_WAIT_STOP_FFS;
565 break;
566 }
567
568 case AUDIO_VM_RECORD_STOP_REQ:
569 { /*.Before stopping this task, control that stop task id caller = Voice task id */
570 if ( p_audio_gbl_var->vm_record.task_id == p_message->src_addr_id)
571 {
572 /* send the stop command to the audio L1 */
573 /* allocate the buffer for the message to the L1 */
574 p_send_message = audio_allocate_l1_message(0);
575 if (p_send_message != NULL)
576 {
577 /* send the stop command to the audio L1 */
578 audio_send_l1_message(MMI_VM_RECORD_STOP_REQ, p_send_message);
579 }
580
581 /* change to the state AUDIO_VM_RECORD_WAIT_STOP_CONFIRMATION */
582 p_audio_gbl_var->vm_record.state = AUDIO_VM_RECORD_WAIT_STOP_CON;
583 }
584 else
585 {
586 /* A stop request from an other task is sent during a start connection */
587 /* event error - send an error message, the recorded size is null */
588 audio_vm_record_send_status ( AUDIO_ERROR, 0,
589 ((T_AUDIO_VM_RECORD_STOP *)(p_message))->return_path);
590 audio_voice_memo_error_trace(AUDIO_ERROR_STOP_EVENT);
591 }
592 break;
593 }
594 case AUDIO_VM_RECORD_START_REQ:
595 {
596 /* A start request from an other task is sent during a start connection */
597 /* event error - send an error message, the recorded size is null */
598 /* Close the FFS file previously open by the audio start API*/
599 #ifndef _WINDOWS
600 if ( ffs_close(((T_AUDIO_VM_RECORD_START *)(p_message))->audio_ffs_fd) != EFFS_OK )
601 {
602 audio_voice_memo_error_trace(AUDIO_ENTITY_FILE_NO_CLOSE);
603 }
604 #endif
605 audio_vm_record_send_status ( AUDIO_ERROR, 0,
606 ((T_AUDIO_VM_RECORD_START *)(p_message))->return_path);
607 audio_voice_memo_error_trace(AUDIO_ERROR_START_EVENT);
608 }
609 }
610 break;
611 } /* case AUDIO_VM_RECORD_WAIT_STOP_COMMAND */
612
613 case AUDIO_VM_RECORD_WAIT_STOP_CON:
614 {
615 switch(p_message->msg_id)
616 {
617 case MMI_VM_RECORD_STOP_CON:
618 {
619 /* Send FFS stop command */
620 /* allocate the message buffer */
621 mb_status = rvf_get_buf (p_audio_gbl_var->mb_internal,
622 sizeof (T_AUDIO_FFS_STOP_REQ),
623 (T_RVF_BUFFER **) (&p_send_message));
624
625 /* If insufficient resources, then report a memory error and abort. */
626 if (mb_status == RVF_RED)
627 {
628 audio_voice_memo_error_trace(AUDIO_ENTITY_NO_MEMORY);
629 }
630
631 /* fill the header of the message */
632 ((T_AUDIO_FFS_STOP_REQ *)(p_send_message))->os_hdr.msg_id = AUDIO_FFS_STOP_REQ;
633
634 /* fill the parameter */
635 ((T_AUDIO_FFS_STOP_REQ *)(p_send_message))->session_id = AUDIO_FFS_SESSION_VM_RECORD;
636
637 /* fill the recorded size */
638 p_audio_gbl_var->vm_record.recorded_size = ((T_MMI_VM_RECORD_CON *)p_message)->recorded_size;
639
640 /* send the message to the entity */
641 rvf_send_msg (p_audio_gbl_var->audio_ffs_addrId,
642 p_send_message);
643
644 /* change to the state AUDIO_VM_RECORD_WAIT_STOP_FFS */
645 p_audio_gbl_var->vm_record.state = AUDIO_VM_RECORD_WAIT_STOP_FFS;
646 break;
647 }
648 case AUDIO_VM_RECORD_STOP_REQ:
649 {
650 /* event error - send an error message, the recorded size is null*/
651 audio_vm_record_send_status (AUDIO_ERROR, 0,
652 ((T_AUDIO_VM_RECORD_STOP *)(p_message))->return_path);
653 audio_voice_memo_error_trace(AUDIO_ERROR_STOP_EVENT);
654 break;
655 }
656 case AUDIO_VM_RECORD_START_REQ:
657 {
658 /* event error - send an error message, the recorded size is null*/
659 /* Close the FFS file previously open by the audio start API*/
660 #ifndef _WINDOWS
661 if ( ffs_close(((T_AUDIO_VM_RECORD_START *)(p_message))->audio_ffs_fd) != EFFS_OK )
662 {
663 audio_voice_memo_error_trace(AUDIO_ENTITY_FILE_NO_CLOSE);
664 }
665 #endif
666 audio_vm_record_send_status ( AUDIO_ERROR, 0,
667 ((T_AUDIO_VM_RECORD_START *)(p_message))->return_path);
668 audio_voice_memo_error_trace(AUDIO_ERROR_START_EVENT);
669 break;
670 }
671
672 }
673 break;
674 } /* case AUDIO_VM_RECORD_WAIT_STOP_CON */
675
676 case AUDIO_VM_RECORD_WAIT_STOP_FFS:
677 {
678 switch(p_message->msg_id)
679 {
680 case AUDIO_FFS_STOP_CON:
681 {
682 audio_vm_record_send_status ( AUDIO_OK,
683 p_audio_gbl_var->vm_record.recorded_size,
684 p_audio_gbl_var->vm_record.return_path);
685
686 /* change to the state AUDIO_VM_RECORD_IDLE */
687 p_audio_gbl_var->vm_record.state = AUDIO_VM_RECORD_IDLE;
688
689 break;
690 }
691 case AUDIO_VM_RECORD_STOP_REQ:
692 {
693 /* event error - send an error message, the recorded size is null*/
694 audio_vm_record_send_status ( AUDIO_ERROR, 0,
695 ((T_AUDIO_VM_RECORD_STOP *)(p_message))->return_path);
696 audio_voice_memo_error_trace(AUDIO_ERROR_STOP_EVENT);
697 break;
698 }
699 case AUDIO_VM_RECORD_START_REQ:
700 {
701 /* event error - send an error message, the recorded size is null*/
702 /* Close the FFS file previously open by the audio start API*/
703 #ifndef _WINDOWS
704 if ( ffs_close(((T_AUDIO_VM_RECORD_START *)(p_message))->audio_ffs_fd) != EFFS_OK )
705 {
706 audio_voice_memo_error_trace(AUDIO_ENTITY_FILE_NO_CLOSE);
707 }
708 #endif
709 audio_vm_record_send_status ( AUDIO_ERROR, 0,
710 ((T_AUDIO_VM_RECORD_START *)(p_message))->return_path);
711 audio_voice_memo_error_trace(AUDIO_ERROR_START_EVENT);
712 break;
713 }
714 }
715 break;
716 } /* case AUDIO_VM_RECORD_WAIT_STOP_CON */
717 } /* switch(p_audio_gbl_var->vm_record.state) */
718 } /*********************** End of audio_vm_record_manager function **********************/
719
720 #endif /* VM_RECORD */
721 #endif /* RVM_AUDIO_MAIN_SWE */