comparison src/cs/services/audio/audio_api.c @ 52:1eb391057168

Main and Audio source directories lowercased
author Mychaela Falconia <falcon@freecalypso.org>
date Thu, 19 Jul 2018 22:49:10 +0000
parents src/cs/services/Audio/audio_api.c@b6a5e36de839
children
comparison
equal deleted inserted replaced
51:daf96987cb39 52:1eb391057168
1 /****************************************************************************/
2 /* */
3 /* File Name: audio_api.c */
4 /* */
5 /* Purpose: This file contains all the functions used to service */
6 /* primitives. */
7 /* */
8 /* Version 0.1 */
9 /* */
10 /* Date Modification */
11 /* ------------------------------------------------------------------------*/
12 /* 14 May 2001 Create */
13 /* */
14 /* Author Francois Mazard - Stephanie Gerthoux */
15 /* */
16 /* (C) Copyright 2001 by Texas Instruments Incorporated, All Rights Reserved*/
17 /****************************************************************************/
18
19 #include "rv/rv_defined_swe.h"
20
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 "l1_confg.h"
29 #include "l1audio_cust.h"
30 #include "rv/rv_general.h"
31 #include "rvm/rvm_gen.h"
32 #include "audio/audio_ffs_i.h"
33 #include "audio/audio_api.h"
34 #include "audio/audio_structs_i.h"
35 #include "audio/audio_error_hdlr_i.h"
36 #include "audio/audio_var_i.h"
37 #include "audio/audio_messages_i.h"
38 #include "rvf/rvf_target.h"
39 #include "audio/audio_const_i.h"
40 #include "audio/audio_macro_i.h"
41 #include "ffs/ffs_api.h"
42
43 #include <string.h>
44
45 /* external dependency */
46 #if (SPEECH_RECO)
47 extern INT8 audio_sr_create_vocabulary_database(char* directory, void** pp_database);
48 #endif
49 /* read */
50 extern T_AUDIO_RET audio_mode_voice_path_read (T_AUDIO_VOICE_PATH_SETTING *data);
51 extern T_AUDIO_RET audio_mode_microphone_mode_read (INT8 *data);
52 extern T_AUDIO_RET audio_mode_microphone_gain_read (INT8 *data);
53 extern T_AUDIO_RET audio_mode_microphone_extra_gain_read (INT8 *data);
54 extern T_AUDIO_RET audio_mode_microphone_output_bias_read (INT8 *data);
55 extern T_AUDIO_RET audio_mode_microphone_fir_read (T_AUDIO_FIR_COEF *data);
56 extern T_AUDIO_RET audio_mode_speaker_mode_read (INT8 *data);
57 extern T_AUDIO_RET audio_mode_speaker_gain_read (INT8 *data);
58 extern T_AUDIO_RET audio_mode_speaker_filter_read (INT8 *data);
59 extern T_AUDIO_RET audio_mode_speaker_fir_read (T_AUDIO_FIR_COEF *data);
60 extern T_AUDIO_RET audio_mode_speaker_buzzer_read (INT8 *data);
61 extern T_AUDIO_RET audio_mode_sidetone_gain_read (INT8 *data);
62 extern T_AUDIO_RET audio_mode_aec_read (T_AUDIO_AEC_CFG *data);
63 extern T_AUDIO_RET audio_mode_speaker_volume_read (T_AUDIO_SPEAKER_LEVEL *data);
64
65 T_AUDIO_RET audio_driver_handle_session(UINT32 msg_id, UINT8 channel_id, T_RV_RETURN return_path);
66
67
68 /********************************************************************************/
69 /* */
70 /* Function Name: audio_keybeep_start */
71 /* */
72 /* Purpose: This function is called to initiate a key beep generation */
73 /* and DTMF generation. The key beep is the generation of two */
74 /* sine waves */
75 /* */
76 /* Input Parameters: */
77 /* Audio Key Beep Parameters, */
78 /* Return path. */
79 /* */
80 /* Output Parameters: */
81 /* Validation of the keybeep parameters. */
82 /* */
83 /* Note: */
84 /* None. */
85 /* */
86 /* Revision History: */
87 /* None. */
88 /* */
89 /********************************************************************************/
90 T_AUDIO_RET audio_keybeep_start (T_AUDIO_KEYBEEP_PARAMETER parameter,
91 T_RV_RETURN return_path)
92 {
93 #if (KEYBEEP)
94 /* Declare local variables. */
95 T_RVF_MB_STATUS mb_status = RVF_GREEN;
96 T_AUDIO_KEYBEEP_START *p_msg_start = NULL;
97
98 /************************ audio_keybeep_start function begins ******************/
99
100 if (p_audio_gbl_var == NULL )
101 {
102 audio_keybeep_error_trace(AUDIO_ENTITY_NOT_START);
103 return(AUDIO_ERROR);
104 }
105
106 /* If bad parameters, then report an error and abort.*/
107 if ((parameter.frequency_beep[0] < FREQUENCY_BEEP_MIN) ||
108 (parameter.frequency_beep[0] > FREQUENCY_BEEP_MAX) ||
109 (parameter.frequency_beep[1] < FREQUENCY_BEEP_MIN) ||
110 (parameter.frequency_beep[1] > FREQUENCY_BEEP_MAX) ||
111 (parameter.amplitude_beep[0] < AMPLITUDE_BEEP_MIN) ||
112 (parameter.amplitude_beep[0] > AMPLITUDE_BEEP_MAX) ||
113 (parameter.amplitude_beep[1] < AMPLITUDE_BEEP_MIN) ||
114 (parameter.amplitude_beep[1] > AMPLITUDE_BEEP_MAX) ||
115 (parameter.duration < DURATION_BEEP_MIN ))
116 {
117 audio_keybeep_error_trace(AUDIO_ENTITY_BAD_PARAMETER);
118 return (AUDIO_ERROR);
119 }
120
121 /* allocate the memory for the message to send */
122 mb_status = rvf_get_buf (p_audio_gbl_var->mb_external,
123 sizeof (T_AUDIO_KEYBEEP_START),
124 (T_RVF_BUFFER **) (&p_msg_start));
125
126 /* If insufficient resources, then report a memory error and abort. */
127 if (mb_status == RVF_YELLOW)
128 {
129 /* deallocate the memory */
130 rvf_free_buf((T_RVF_BUFFER *)p_msg_start);
131 audio_keybeep_error_trace(AUDIO_ENTITY_NO_MEMORY);
132 return (AUDIO_ERROR);
133 }
134 else
135 if (mb_status == RVF_RED)
136 {
137 audio_keybeep_error_trace(AUDIO_ENTITY_NO_MEMORY);
138 return (AUDIO_ERROR);
139 }
140
141 /* fill the message id */
142 p_msg_start->os_hdr.msg_id = AUDIO_KEYBEEP_START_REQ;
143
144 /* fill the address source id */
145 p_msg_start->os_hdr.src_addr_id = rvf_get_taskid();
146 p_msg_start->os_hdr.dest_addr_id = p_audio_gbl_var->addrId;
147
148 /* fill the message parameters */
149 p_msg_start->keybeep_parameter.frequency_beep[0] = parameter.frequency_beep[0];
150 p_msg_start->keybeep_parameter.frequency_beep[1] = parameter.frequency_beep[1];
151 p_msg_start->keybeep_parameter.amplitude_beep[0] = parameter.amplitude_beep[0];
152 p_msg_start->keybeep_parameter.amplitude_beep[1] = parameter.amplitude_beep[1];
153 p_msg_start->keybeep_parameter.duration = parameter.duration;
154
155 if (return_path.callback_func == NULL)
156 {
157 p_msg_start->return_path.addr_id = return_path.addr_id;
158 p_msg_start->return_path.callback_func = NULL;
159 }
160 else
161 {
162 p_msg_start->return_path.callback_func = return_path.callback_func;
163 }
164
165 /* send the messsage to the audio entity */
166 rvf_send_msg (p_audio_gbl_var->addrId,
167 p_msg_start);
168
169 return (AUDIO_OK);
170 #else
171 AUDIO_SEND_TRACE("Keybeep not compiled", RV_TRACE_LEVEL_ERROR);
172 return (AUDIO_ERROR);
173 #endif
174 } /*********************** End of audio_Keybeep_Start function ******************/
175
176 /********************************************************************************/
177 /* */
178 /* Function Name: audio_keybeep_stop */
179 /* */
180 /* Purpose: This function is called to stop a key beep generation */
181 /* */
182 /* Input Parameters: */
183 /* Return path. */
184 /* */
185 /* Output Parameters: */
186 /* None. */
187 /* */
188 /* Note: */
189 /* None. */
190 /* */
191 /* Revision History: */
192 /* None. */
193 /* */
194 /********************************************************************************/
195 T_AUDIO_RET audio_keybeep_stop (T_RV_RETURN return_path)
196 {
197 #if (KEYBEEP)
198 /* Declare local variables. */
199 T_RVF_MB_STATUS mb_status = RVF_GREEN;
200 T_AUDIO_KEYBEEP_STOP *p_msg = NULL;
201
202 /************************ audio_keybeep_stop function begins ****************/
203
204 if (p_audio_gbl_var == NULL )
205 {
206 audio_keybeep_error_trace(AUDIO_ENTITY_NOT_START);
207 return(AUDIO_ERROR);
208 }
209
210 /* allocate the memory for the message to send */
211 mb_status = rvf_get_buf (p_audio_gbl_var->mb_external,
212 sizeof (T_AUDIO_KEYBEEP_STOP),
213 (T_RVF_BUFFER **) (&p_msg));
214
215 /* If insufficient resources, then report a memory error and abort. */
216 if (mb_status == RVF_YELLOW)
217 {
218 /* deallocate the memory */
219 rvf_free_buf((T_RVF_BUFFER *)p_msg);
220 audio_keybeep_error_trace(AUDIO_ENTITY_NO_MEMORY);
221 return (AUDIO_ERROR);
222 }
223 else
224 if (mb_status == RVF_RED)
225 {
226 audio_keybeep_error_trace(AUDIO_ENTITY_NO_MEMORY);
227 return (AUDIO_ERROR);
228 }
229
230
231 /* fill the message id */
232 p_msg->os_hdr.msg_id = AUDIO_KEYBEEP_STOP_REQ;
233
234 /* fill the address source id */
235 p_msg->os_hdr.src_addr_id = rvf_get_taskid();
236 p_msg->os_hdr.dest_addr_id = p_audio_gbl_var->addrId;
237
238 if (return_path.callback_func == NULL)
239 {
240 p_msg->return_path.addr_id = return_path.addr_id;
241 p_msg->return_path.callback_func = NULL;
242 }
243 else
244 {
245 p_msg->return_path.callback_func = return_path.callback_func;
246 }
247
248 /* send the messsage to the audio entity */
249 rvf_send_msg (p_audio_gbl_var->addrId,
250 p_msg);
251
252 return (AUDIO_OK);
253 #else
254 AUDIO_SEND_TRACE("Keybeep not compiled", RV_TRACE_LEVEL_ERROR);
255 return (AUDIO_ERROR);
256 #endif
257 } /*********************** End of audio_Keybeep_Stop function *******************/
258
259 /********************************************************************************/
260 /* */
261 /* Function Name: audio_tones_start */
262 /* */
263 /* Purpose: This function is called to initiate tones generation. */
264 /* The tones are the generation of up to three scheduled */
265 /* sine waves.......................................... */
266 /* */
267 /* Input Parameters: */
268 /* Audio tones Parameters, */
269 /* Return path. */
270 /* */
271 /* Output Parameters: */
272 /* Validation of the tones parameters. */
273 /* */
274 /* Note: */
275 /* None. */
276 /* */
277 /* Revision History: */
278 /* None. */
279 /* */
280 /********************************************************************************/
281 T_AUDIO_RET audio_tones_start (T_AUDIO_TONES_PARAMETER* parameter,
282 T_RV_RETURN return_path)
283 {
284 #if (TONE)
285 /* Declare local variables. */
286 T_RVF_MB_STATUS mb_status = RVF_GREEN;
287 T_AUDIO_TONES_START *p_msg_start = NULL;
288
289 /************************ audio_tones_start function begins ********************/
290
291 if (p_audio_gbl_var == NULL )
292 {
293 audio_tones_error_trace(AUDIO_ENTITY_NOT_START);
294 return(AUDIO_ERROR);
295 }
296
297 /* If bad tones parameters, then report an error and abort.*/
298 if ( (parameter->tones[0].frequency_tone < FREQUENCY_BEEP_MIN) ||
299 (parameter->tones[1].frequency_tone < FREQUENCY_BEEP_MIN) ||
300 (parameter->tones[2].frequency_tone < FREQUENCY_BEEP_MIN) ||
301 (parameter->tones[0].frequency_tone > FREQUENCY_BEEP_MAX) ||
302 (parameter->tones[1].frequency_tone > FREQUENCY_BEEP_MAX) ||
303 (parameter->tones[2].frequency_tone > FREQUENCY_BEEP_MAX) ||
304 (parameter->tones[0].amplitude_tone < AMPLITUDE_BEEP_MIN) ||
305 (parameter->tones[1].amplitude_tone < AMPLITUDE_BEEP_MIN) ||
306 (parameter->tones[2].amplitude_tone < AMPLITUDE_BEEP_MIN) ||
307 (parameter->tones[0].amplitude_tone > AMPLITUDE_BEEP_MAX) ||
308 (parameter->tones[1].amplitude_tone > AMPLITUDE_BEEP_MAX) ||
309 (parameter->tones[2].amplitude_tone > AMPLITUDE_BEEP_MAX) ||
310 (parameter->frame_duration == 0 ) ||
311 (parameter->period_duration < parameter->sequence_duration) ||
312 (parameter->sequence_duration < parameter->frame_duration) ||
313 (parameter->period_duration < parameter->frame_duration) ||
314 ((parameter->tones[0].stop_tone - parameter->tones[0].start_tone) < DURATION_BEEP_MIN) ||
315 ((parameter->tones[1].stop_tone - parameter->tones[1].start_tone) < DURATION_BEEP_MIN) ||
316 ((parameter->tones[2].stop_tone - parameter->tones[2].start_tone) < DURATION_BEEP_MIN) )
317 {
318 audio_tones_error_trace(AUDIO_ENTITY_BAD_PARAMETER);
319 return (AUDIO_ERROR);
320 }
321
322 /* allocate the memory for the message to send */
323 mb_status = rvf_get_buf (p_audio_gbl_var->mb_external,
324 sizeof (T_AUDIO_TONES_START),
325 (T_RVF_BUFFER **) (&p_msg_start));
326
327 /* If insufficient resources, then report a memory error and abort. */
328 if (mb_status == RVF_YELLOW)
329 {
330 /* deallocate the memory */
331 rvf_free_buf((T_RVF_BUFFER *)p_msg_start);
332 audio_tones_error_trace(AUDIO_ENTITY_NO_MEMORY);
333 return (AUDIO_ERROR);
334 }
335 else
336 if (mb_status == RVF_RED)
337 {
338 audio_tones_error_trace(AUDIO_ENTITY_NO_MEMORY);
339 return (AUDIO_ERROR);
340 }
341
342 /* fill the message id */
343 p_msg_start->os_hdr.msg_id = AUDIO_TONES_START_REQ;
344
345 /* fill the address source id */
346 p_msg_start->os_hdr.src_addr_id = rvf_get_taskid();
347 p_msg_start->os_hdr.dest_addr_id = p_audio_gbl_var->addrId;
348
349 /* fill the message parameters */
350 p_msg_start->tones_parameter.tones[0].frequency_tone = parameter->tones[0].frequency_tone;
351 p_msg_start->tones_parameter.tones[1].frequency_tone = parameter->tones[1].frequency_tone;
352 p_msg_start->tones_parameter.tones[2].frequency_tone = parameter->tones[2].frequency_tone;
353
354 p_msg_start->tones_parameter.tones[0].amplitude_tone = parameter->tones[0].amplitude_tone;
355 p_msg_start->tones_parameter.tones[1].amplitude_tone = parameter->tones[1].amplitude_tone;
356 p_msg_start->tones_parameter.tones[2].amplitude_tone = parameter->tones[2].amplitude_tone;
357
358 p_msg_start->tones_parameter.tones[0].start_tone = parameter->tones[0].start_tone;
359 p_msg_start->tones_parameter.tones[1].start_tone = parameter->tones[1].start_tone;
360 p_msg_start->tones_parameter.tones[2].start_tone = parameter->tones[2].start_tone;
361 p_msg_start->tones_parameter.tones[0].stop_tone = parameter->tones[0].stop_tone;
362 p_msg_start->tones_parameter.tones[1].stop_tone = parameter->tones[1].stop_tone;
363 p_msg_start->tones_parameter.tones[2].stop_tone = parameter->tones[2].stop_tone;
364
365 p_msg_start->tones_parameter.frame_duration= parameter->frame_duration;
366 p_msg_start->tones_parameter.sequence_duration = parameter->sequence_duration;
367 p_msg_start->tones_parameter.period_duration = parameter->period_duration;
368 p_msg_start->tones_parameter.repetition = parameter->repetition;
369
370 if (return_path.callback_func == NULL)
371 {
372 p_msg_start->return_path.addr_id = return_path.addr_id;
373 p_msg_start->return_path.callback_func = NULL;
374 }
375 else
376 {
377 p_msg_start->return_path.callback_func = return_path.callback_func;
378 }
379
380 /* send the messsage to the audio entity */
381 rvf_send_msg (p_audio_gbl_var->addrId,
382 p_msg_start);
383
384 return (AUDIO_OK);
385 #else
386 AUDIO_SEND_TRACE("Tones not compiled", RV_TRACE_LEVEL_ERROR);
387 return (AUDIO_ERROR);
388 #endif
389 } /*********************** End of audio_tones_Start function ********************/
390
391 /********************************************************************************/
392 /* */
393 /* Function Name: audio_tones_stop */
394 /* */
395 /* Purpose: This function is called to stop a tones generation */
396 /* */
397 /* Input Parameters: */
398 /* Return path. */
399 /* */
400 /* Output Parameters: */
401 /* Validation of the tones parameters. */
402 /* */
403 /* Note: */
404 /* None. */
405 /* */
406 /* Revision History: */
407 /* None. */
408 /* */
409 /********************************************************************************/
410 T_AUDIO_RET audio_tones_stop (T_RV_RETURN return_path)
411 {
412 #if (TONE)
413 /* Declare local variables. */
414 T_RVF_MB_STATUS mb_status = RVF_GREEN;
415 T_AUDIO_TONES_STOP *p_msg = NULL;
416
417 /************************ audio_tones_stop function begins *********************/
418
419 if (p_audio_gbl_var == NULL )
420 {
421 audio_tones_error_trace(AUDIO_ENTITY_NOT_START);
422 return(AUDIO_ERROR);
423 }
424
425 /* allocate the memory for the message to send */
426 mb_status = rvf_get_buf (p_audio_gbl_var->mb_external,
427 sizeof (T_AUDIO_TONES_STOP),
428 (T_RVF_BUFFER **) (&p_msg));
429
430 /* If insufficient resources, then report a memory error and abort. */
431 if (mb_status == RVF_YELLOW)
432 {
433 /* deallocate the memory */
434 rvf_free_buf((T_RVF_BUFFER *)p_msg);
435 audio_tones_error_trace(AUDIO_ENTITY_NO_MEMORY);
436 return (AUDIO_ERROR);
437 }
438 else
439 if (mb_status == RVF_RED)
440 {
441 audio_tones_error_trace(AUDIO_ENTITY_NO_MEMORY);
442 return (AUDIO_ERROR);
443 }
444
445 /* fill the message id */
446 p_msg->os_hdr.msg_id = AUDIO_TONES_STOP_REQ;
447
448 /* fill the address source id */
449 p_msg->os_hdr.src_addr_id = rvf_get_taskid();
450 p_msg->os_hdr.dest_addr_id = p_audio_gbl_var->addrId;
451
452 if (return_path.callback_func == NULL)
453 {
454 p_msg->return_path.addr_id = return_path.addr_id;
455 p_msg->return_path.callback_func = NULL;
456 }
457 else
458 {
459 p_msg->return_path.callback_func = return_path.callback_func;
460 }
461
462 /* send the messsage to the audio entity */
463 rvf_send_msg (p_audio_gbl_var->addrId,
464 p_msg);
465
466 return (AUDIO_OK);
467 #else
468 AUDIO_SEND_TRACE("Tones not compiled", RV_TRACE_LEVEL_ERROR);
469 return (AUDIO_ERROR);
470 #endif
471 } /*********************** End of audio_Tones_Stop function *********************/
472
473 /********************************************************************************/
474 /* */
475 /* Function Name: audio_melody_E1_start */
476 /* */
477 /* Purpose: This function is called to initiate the melody E1 generation */
478 /* */
479 /* Input Parameters: */
480 /* Audio Melody E1 Parameters, */
481 /* Return path. */
482 /* */
483 /* Output Parameters: */
484 /* Validation of the melody E1 parameters. */
485 /* */
486 /* Note: */
487 /* None. */
488 /* */
489 /* Revision History: */
490 /* None. */
491 /* */
492 /********************************************************************************/
493 T_AUDIO_RET audio_melody_E1_start (T_AUDIO_MELODY_E1_PARAMETER *p_parameter,
494 T_RV_RETURN return_path)
495 {
496 #if (MELODY_E1)
497 /* Declare local variables. */
498 T_RVF_MB_STATUS mb_status = RVF_GREEN;
499 T_AUDIO_MELODY_E1_START *p_msg_start = NULL;
500 T_FFS_FD ffs_fd;
501
502 /************************ audio_melody_E1_start function begins ***************/
503
504 if (p_audio_gbl_var == NULL )
505 {
506 audio_melody_E1_error_trace(AUDIO_ENTITY_NOT_START);
507 return(AUDIO_ERROR);
508 }
509
510 /* check if the melody E1 file exist */
511 #ifndef _WINDOWS
512 ffs_fd = ffs_open(p_parameter->melody_name, FFS_O_RDONLY);
513 if (ffs_fd <= 0)
514 {
515 audio_melody_E1_error_trace(AUDIO_ENTITY_FILE_ERROR);
516 return (AUDIO_ERROR);
517 }
518 #else
519 ffs_fd = 0x00000001;
520 #endif
521
522 /* allocate the memory for the message to send */
523 mb_status = rvf_get_buf (p_audio_gbl_var->mb_external,
524 sizeof (T_AUDIO_MELODY_E1_START),
525 (T_RVF_BUFFER **) (&p_msg_start));
526
527 /* If insufficient resources, then report a memory error and abort. */
528 if (mb_status == RVF_YELLOW)
529 {
530 /* deallocate the memory */
531 rvf_free_buf((T_RVF_BUFFER *)p_msg_start);
532 audio_melody_E1_error_trace(AUDIO_ENTITY_NO_MEMORY);
533 /* close the file previously open */
534 #ifndef _WINDOWS
535 ffs_close(ffs_fd);
536 #endif
537 return (AUDIO_ERROR);
538 }
539 else
540 if (mb_status == RVF_RED)
541 {
542 audio_melody_E1_error_trace(AUDIO_ENTITY_NO_MEMORY);
543 /* close the file previously open */
544 #ifndef _WINDOWS
545 ffs_close(ffs_fd);
546 #endif
547 return (AUDIO_ERROR);
548 }
549
550 /* fill the message id */
551 p_msg_start->os_hdr.msg_id = AUDIO_MELODY_E1_START_REQ;
552
553 /* fill the address source id */
554 p_msg_start->os_hdr.src_addr_id = rvf_get_taskid();
555 p_msg_start->os_hdr.dest_addr_id = p_audio_gbl_var->addrId;
556
557 /* fill the message parameters */
558 p_msg_start->audio_ffs_fd = ffs_fd;
559
560 strcpy(p_msg_start->melody_E1_parameter.melody_name,
561 p_parameter->melody_name);
562
563 if ( (p_parameter->loopback == AUDIO_MELODY_NO_LOOPBACK) ||
564 (p_parameter->loopback == AUDIO_MELODY_LOOPBACK) )
565 {
566 p_msg_start->melody_E1_parameter.loopback = p_parameter->loopback;
567 }
568 else
569 {
570 /* deallocate the memory */
571 rvf_free_buf((T_RVF_BUFFER *)p_msg_start);
572 /* Wrong parameter */
573 audio_melody_E1_error_trace(AUDIO_ENTITY_BAD_PARAMETER);
574 /* close the file previously open */
575 #ifndef _WINDOWS
576 ffs_close(ffs_fd);
577 #endif
578 return (AUDIO_ERROR);
579 }
580
581 if ( (p_parameter->melody_mode == AUDIO_MELODY_GAME_MODE) ||
582 (p_parameter->melody_mode == AUDIO_MELODY_NORMAL_MODE) )
583 {
584 p_msg_start->melody_E1_parameter.melody_mode = p_parameter->melody_mode;
585 }
586 else
587 {
588 /* deallocate the memory */
589 rvf_free_buf((T_RVF_BUFFER *)p_msg_start);
590 /* Wrong parameter */
591 audio_melody_E1_error_trace(AUDIO_ENTITY_BAD_PARAMETER);
592 /* close the file previously open */
593 #ifndef _WINDOWS
594 ffs_close(ffs_fd);
595 #endif
596 return (AUDIO_ERROR);
597 }
598
599 if (return_path.callback_func == NULL)
600 {
601 p_msg_start->return_path.addr_id = return_path.addr_id;
602 p_msg_start->return_path.callback_func = NULL;
603 }
604
605 else
606 {
607 p_msg_start->return_path.callback_func = return_path.callback_func;
608 }
609
610 /* send the messsage to the audio entity */
611 rvf_send_msg (p_audio_gbl_var->addrId,
612 p_msg_start);
613
614 return (AUDIO_OK);
615 #else
616 AUDIO_SEND_TRACE("Melody E1 not compiled", RV_TRACE_LEVEL_ERROR);
617 return (AUDIO_ERROR);
618 #endif
619 } /*********************** End of audio_melody_E1_Start function ****************/
620
621 /********************************************************************************/
622 /* */
623 /* Function Name: audio_melody_E1_stop */
624 /* */
625 /* Purpose: This function is called to stop a melody_E1 generation */
626 /* */
627 /* Input Parameters: */
628 /* Audio Melody E1 Stop Parameters, */
629 /* Return path. */
630 /* */
631 /* Output Parameters: */
632 /* Validation of the melody E1 parameters. */
633 /* Note: */
634 /* None. */
635 /* */
636 /* Revision History: */
637 /* None. */
638 /* */
639 /********************************************************************************/
640 T_AUDIO_RET audio_melody_E1_stop (T_AUDIO_MELODY_E1_STOP_PARAMETER *p_parameter,
641 T_RV_RETURN return_path)
642 {
643 #if (MELODY_E1)
644 /* Declare local variables. */
645 T_RVF_MB_STATUS mb_status = RVF_GREEN;
646 T_AUDIO_MELODY_E1_STOP *p_msg = NULL;
647
648 /************************ audio_melody_E1_stop function begins ****************/
649
650 if (p_audio_gbl_var == NULL )
651 {
652 audio_melody_E1_error_trace(AUDIO_ENTITY_NOT_START);
653 return(AUDIO_ERROR);
654 }
655
656 /* allocate the memory for the message to send */
657 mb_status = rvf_get_buf (p_audio_gbl_var->mb_external,
658 sizeof (T_AUDIO_MELODY_E1_STOP),
659 (T_RVF_BUFFER **) (&p_msg));
660
661 /* If insufficient resources, then report a memory error and abort. */
662 if (mb_status == RVF_YELLOW)
663 {
664 /* deallocate the memory */
665 rvf_free_buf((T_RVF_BUFFER *)p_msg);
666 audio_melody_E1_error_trace(AUDIO_ENTITY_NO_MEMORY);
667 return (AUDIO_ERROR);
668 }
669 else
670 if (mb_status == RVF_RED)
671 {
672 audio_melody_E1_error_trace(AUDIO_ENTITY_NO_MEMORY);
673 return (AUDIO_ERROR);
674 }
675
676 /* fill the message id */
677 p_msg->os_hdr.msg_id = AUDIO_MELODY_E1_STOP_REQ;
678
679 /* fill the address source id */
680 p_msg->os_hdr.src_addr_id = rvf_get_taskid();
681 p_msg->os_hdr.dest_addr_id = p_audio_gbl_var->addrId;
682
683 strcpy (p_msg->melody_name, p_parameter->melody_name);
684
685 if (return_path.callback_func == NULL)
686 {
687 p_msg->return_path.addr_id = return_path.addr_id;
688 p_msg->return_path.callback_func = NULL;
689 }
690 else
691 {
692 p_msg->return_path.callback_func = return_path.callback_func;
693 }
694
695 /* send the messsage to the audio entity */
696 rvf_send_msg (p_audio_gbl_var->addrId,
697 p_msg);
698
699 return (AUDIO_OK);
700 #else
701 AUDIO_SEND_TRACE("Melody E1 not compiled", RV_TRACE_LEVEL_ERROR);
702 return (AUDIO_ERROR);
703 #endif
704 } /*********************** End of audio_melody_E1_Stop function *****************/
705
706 /********************************************************************************/
707 /* */
708 /* Function Name: audio_vm_play_start */
709 /* */
710 /* Purpose: This function is called to initiate the voice Memorization play */
711 /* generation */
712 /* */
713 /* Input Parameters: */
714 /* Audio Voice Memorization Play Parameters, */
715 /* Return path. */
716 /* */
717 /* Output Parameters: */
718 /* Validation of the Voice Memorization Play parameters. */
719 /* */
720 /* Note: */
721 /* None. */
722 /* */
723 /* Revision History: */
724 /* None. */
725 /* */
726 /********************************************************************************/
727 T_AUDIO_RET audio_vm_play_start (T_AUDIO_VM_PLAY_PARAMETER *p_parameter,
728 T_RV_RETURN return_path)
729 {
730 #if (VOICE_MEMO)
731 /* Declare local variables. */
732 T_RVF_MB_STATUS mb_status = RVF_GREEN;
733 T_AUDIO_VM_PLAY_START *p_msg_start = NULL;
734 T_FFS_FD ffs_fd;
735
736 /************************ audio_vm_play_start function begins ******************/
737
738 if (p_audio_gbl_var == NULL )
739 {
740 audio_voice_memo_error_trace(AUDIO_ENTITY_NOT_START);
741 return(AUDIO_ERROR);
742 }
743
744 /* check if the voice memo play file exist */
745 #ifndef _WINDOWS
746 ffs_fd = ffs_open(p_parameter->memo_name, FFS_O_RDONLY);
747 if ( ffs_fd <= 0)
748 {
749 audio_voice_memo_error_trace(AUDIO_ENTITY_FILE_ERROR);
750 return (AUDIO_ERROR);
751 }
752 #else
753 ffs_fd = 0x00000010;
754 #endif
755
756 /* allocate the memory for the message to send */
757 mb_status = rvf_get_buf (p_audio_gbl_var->mb_external,
758 sizeof (T_AUDIO_VM_PLAY_START),
759 (T_RVF_BUFFER **) (&p_msg_start));
760
761 /* If insufficient resources, then report a memory error and abort. */
762 if (mb_status == RVF_YELLOW)
763 {
764 /* deallocate the memory */
765 rvf_free_buf((T_RVF_BUFFER *)p_msg_start);
766 audio_voice_memo_error_trace(AUDIO_ENTITY_NO_MEMORY);
767 /* close the file previously open */
768 #ifndef _WINDOWS
769 ffs_close(ffs_fd);
770 #endif
771 return (AUDIO_ERROR);
772 }
773 else
774 if (mb_status == RVF_RED)
775 {
776 audio_voice_memo_error_trace(AUDIO_ENTITY_NO_MEMORY);
777 /* close the file previously open */
778 #ifndef _WINDOWS
779 ffs_close(ffs_fd);
780 #endif
781 return (AUDIO_ERROR);
782 }
783
784 /* fill the message id */
785 p_msg_start->os_hdr.msg_id = AUDIO_VM_PLAY_START_REQ;
786
787 /* fill the address source id */
788 p_msg_start->os_hdr.src_addr_id = rvf_get_taskid();
789 p_msg_start->os_hdr.dest_addr_id = p_audio_gbl_var->addrId;
790
791 /* fill the message parameters */
792 p_msg_start->audio_ffs_fd = ffs_fd;
793
794 if (return_path.callback_func == NULL)
795 {
796 p_msg_start->return_path.addr_id = return_path.addr_id;
797 p_msg_start->return_path.callback_func = NULL;
798 }
799
800 else
801 {
802 p_msg_start->return_path.callback_func = return_path.callback_func;
803 }
804
805 /* send the messsage to the audio entity */
806 rvf_send_msg (p_audio_gbl_var->addrId,
807 p_msg_start);
808
809 return (AUDIO_OK);
810 #else
811 AUDIO_SEND_TRACE("VM Play not compiled", RV_TRACE_LEVEL_ERROR);
812 return (AUDIO_ERROR);
813 #endif
814 } /*********************** End of audio_vm_play_start function ******************/
815
816 /********************************************************************************/
817 /* */
818 /* Function Name: audio_vm_play_stop */
819 /* */
820 /* Purpose: This function is called to stop a voice memorization Play */
821 /* generation */
822 /* */
823 /* Input Parameters: */
824 /* Return path. */
825 /* */
826 /* Output Parameters: */
827 /* None. */
828 /* */
829 /* Note: */
830 /* None. */
831 /* */
832 /* Revision History: */
833 /* None. */
834 /* */
835 /********************************************************************************/
836 T_AUDIO_RET audio_vm_play_stop (T_RV_RETURN return_path)
837 {
838 #if (VOICE_MEMO)
839 /* Declare local variables. */
840 T_RVF_MB_STATUS mb_status = RVF_GREEN;
841 T_AUDIO_VM_PLAY_STOP *p_msg = NULL;
842
843 /************************ audio_vm_play_stop function begins *******************/
844
845 if (p_audio_gbl_var == NULL )
846 {
847 audio_voice_memo_error_trace(AUDIO_ENTITY_NOT_START);
848 return(AUDIO_ERROR);
849 }
850
851 /* allocate the memory for the message to send */
852 mb_status = rvf_get_buf (p_audio_gbl_var->mb_external,
853 sizeof (T_AUDIO_VM_PLAY_STOP),
854 (T_RVF_BUFFER **) (&p_msg));
855
856 /* If insufficient resources, then report a memory error and abort. */
857 if (mb_status == RVF_YELLOW)
858 {
859 /* deallocate the memory */
860 rvf_free_buf((T_RVF_BUFFER *)p_msg);
861 audio_voice_memo_error_trace(AUDIO_ENTITY_NO_MEMORY);
862 return (AUDIO_ERROR);
863 }
864 else
865 if (mb_status == RVF_RED)
866 {
867 audio_voice_memo_error_trace(AUDIO_ENTITY_NO_MEMORY);
868 return (AUDIO_ERROR);
869 }
870
871 /* fill the message id */
872 p_msg->os_hdr.msg_id = AUDIO_VM_PLAY_STOP_REQ;
873
874 /* fill the address source id */
875 p_msg->os_hdr.src_addr_id = rvf_get_taskid();
876 p_msg->os_hdr.dest_addr_id = p_audio_gbl_var->addrId;
877
878 if (return_path.callback_func == NULL)
879 {
880 p_msg->return_path.addr_id = return_path.addr_id;
881 p_msg->return_path.callback_func = NULL;
882 }
883 else
884 {
885 p_msg->return_path.callback_func = return_path.callback_func;
886 }
887
888 /* send the messsage to the audio entity */
889 rvf_send_msg (p_audio_gbl_var->addrId,
890 p_msg);
891
892 return (AUDIO_OK);
893 #else
894 AUDIO_SEND_TRACE("VM Play not compiled", RV_TRACE_LEVEL_ERROR);
895 return (AUDIO_ERROR);
896 #endif
897 } /*********************** End of audio_vm_play_Stop function *******************/
898
899 /********************************************************************************/
900 /* */
901 /* Function Name: audio_vm_record_start */
902 /* */
903 /* Purpose: This function is called to initiate the voice Memorization */
904 /* record generation */
905 /* */
906 /* Input Parameters: */
907 /* Audio Voice Memorization Record Parameters, */
908 /* Return path. */
909 /* */
910 /* Output Parameters: */
911 /* Validation of the Voice Memorization Record parameters. */
912 /* */
913 /* Note: */
914 /* None. */
915 /* */
916 /* Revision History: */
917 /* None. */
918 /* */
919 /********************************************************************************/
920 T_AUDIO_RET audio_vm_record_start ( T_AUDIO_VM_RECORD_PARAMETER *p_record_parameter,
921 T_AUDIO_TONES_PARAMETER *p_tones_parameter,
922 T_RV_RETURN return_path)
923 {
924 #if (VOICE_MEMO)
925 /* Declare local variables. */
926 T_RVF_MB_STATUS mb_status = RVF_GREEN;
927 T_AUDIO_VM_RECORD_START *p_msg_start = NULL;
928 T_FFS_FD ffs_fd;
929
930 /************************ audio_vm_record_start function begins **************/
931
932 if (p_audio_gbl_var == NULL )
933 {
934 audio_voice_memo_error_trace(AUDIO_ENTITY_NOT_START);
935 return(AUDIO_ERROR);
936 }
937
938 /* check if the voice memo record file already exist */
939 #ifndef _WINDOWS
940 ffs_fd = ffs_open(p_record_parameter->memo_name,
941 FFS_O_CREATE | FFS_O_WRONLY | FFS_O_TRUNC | FFS_O_APPEND);
942 if ( ffs_fd <= 0)
943 {
944 audio_voice_memo_error_trace(AUDIO_ENTITY_FILE_ERROR);
945 return (AUDIO_ERROR);
946 }
947 #else
948 ffs_fd = 0x00000011;
949 #endif
950
951 /* If bad tones parameters, then report an error and abort.*/
952 if ( (p_tones_parameter->tones[0].frequency_tone < FREQUENCY_BEEP_MIN) ||
953 (p_tones_parameter->tones[1].frequency_tone < FREQUENCY_BEEP_MIN) ||
954 (p_tones_parameter->tones[2].frequency_tone < FREQUENCY_BEEP_MIN) ||
955 (p_tones_parameter->tones[0].frequency_tone > FREQUENCY_BEEP_MAX) ||
956 (p_tones_parameter->tones[1].frequency_tone > FREQUENCY_BEEP_MAX) ||
957 (p_tones_parameter->tones[2].frequency_tone > FREQUENCY_BEEP_MAX) ||
958 (p_tones_parameter->tones[0].amplitude_tone < AMPLITUDE_BEEP_MIN) ||
959 (p_tones_parameter->tones[1].amplitude_tone < AMPLITUDE_BEEP_MIN) ||
960 (p_tones_parameter->tones[2].amplitude_tone < AMPLITUDE_BEEP_MIN) ||
961 (p_tones_parameter->tones[0].amplitude_tone > AMPLITUDE_BEEP_MAX) ||
962 (p_tones_parameter->tones[1].amplitude_tone > AMPLITUDE_BEEP_MAX) ||
963 (p_tones_parameter->tones[2].amplitude_tone > AMPLITUDE_BEEP_MAX) ||
964 (p_tones_parameter->frame_duration == 0 ) ||
965 (p_tones_parameter->period_duration < p_tones_parameter->sequence_duration) ||
966 (p_tones_parameter->sequence_duration < p_tones_parameter->frame_duration) ||
967 (p_tones_parameter->period_duration < p_tones_parameter->frame_duration) ||
968 ((p_tones_parameter->tones[0].stop_tone - p_tones_parameter->tones[0].start_tone) < DURATION_BEEP_MIN) ||
969 ((p_tones_parameter->tones[1].stop_tone - p_tones_parameter->tones[1].start_tone) < DURATION_BEEP_MIN) ||
970 ((p_tones_parameter->tones[2].stop_tone - p_tones_parameter->tones[2].start_tone) < DURATION_BEEP_MIN) )
971 {
972 audio_voice_memo_error_trace(AUDIO_ENTITY_BAD_PARAMETER);
973 #ifndef _WINDOWS
974 /* close the file previously open */
975 ffs_close(ffs_fd);
976 #endif
977 return (AUDIO_ERROR);
978 }
979
980 /* If bad voice memo record parameters, then report an error and abort.*/
981 if ( ( p_record_parameter->memo_duration == 0) ||
982 (( p_record_parameter->compression_mode != AUDIO_VM_NO_COMPRESSION_MODE ) &&
983 ( p_record_parameter->compression_mode != AUDIO_VM_COMPRESSION_MODE )))
984 {
985 audio_voice_memo_error_trace(AUDIO_ENTITY_BAD_PARAMETER);
986 #ifndef _WINDOWS
987 /* close the file previously open */
988 ffs_close(ffs_fd);
989 #endif
990 return (AUDIO_ERROR);
991 }
992
993 /* allocate the memory for the message to send */
994 mb_status = rvf_get_buf (p_audio_gbl_var->mb_external,
995 sizeof (T_AUDIO_VM_RECORD_START),
996 (T_RVF_BUFFER **) (&p_msg_start));
997
998 /* If insufficient resources, then report a memory error and abort. */
999 if (mb_status == RVF_YELLOW)
1000 {
1001 /* deallocate the memory */
1002 rvf_free_buf((T_RVF_BUFFER *)p_msg_start);
1003 audio_voice_memo_error_trace(AUDIO_ENTITY_NO_MEMORY);
1004 #ifndef _WINDOWS
1005 /* close the file previously open */
1006 ffs_close(ffs_fd);
1007 #endif
1008 return (AUDIO_ERROR);
1009 }
1010 else
1011 if (mb_status == RVF_RED)
1012 {
1013 audio_voice_memo_error_trace(AUDIO_ENTITY_NO_MEMORY);
1014 #ifndef _WINDOWS
1015 /* close the file previously open */
1016 ffs_close(ffs_fd);
1017 #endif
1018 return (AUDIO_ERROR);
1019 }
1020
1021 /* fill the message id */
1022 p_msg_start->os_hdr.msg_id = AUDIO_VM_RECORD_START_REQ;
1023
1024 /* fill the address source id */
1025 p_msg_start->os_hdr.src_addr_id = rvf_get_taskid();
1026 p_msg_start->os_hdr.dest_addr_id = p_audio_gbl_var->addrId;
1027
1028 /* fill the message parameters */
1029 p_msg_start->audio_ffs_fd = ffs_fd;
1030 p_msg_start->compression_mode = p_record_parameter->compression_mode;
1031 p_msg_start->memo_duration = p_record_parameter->memo_duration;
1032 p_msg_start->microphone_gain = p_record_parameter->microphone_gain;
1033 p_msg_start->network_gain = p_record_parameter->network_gain;
1034
1035 /* fill the message tones parameters */
1036 p_msg_start->tones_parameter.tones[0].frequency_tone = p_tones_parameter->tones[0].frequency_tone;
1037 p_msg_start->tones_parameter.tones[1].frequency_tone = p_tones_parameter->tones[1].frequency_tone;
1038 p_msg_start->tones_parameter.tones[2].frequency_tone = p_tones_parameter->tones[2].frequency_tone;
1039
1040 p_msg_start->tones_parameter.tones[0].amplitude_tone = p_tones_parameter->tones[0].amplitude_tone;
1041 p_msg_start->tones_parameter.tones[1].amplitude_tone = p_tones_parameter->tones[1].amplitude_tone;
1042 p_msg_start->tones_parameter.tones[2].amplitude_tone = p_tones_parameter->tones[2].amplitude_tone;
1043
1044 p_msg_start->tones_parameter.tones[0].start_tone = p_tones_parameter->tones[0].start_tone;
1045 p_msg_start->tones_parameter.tones[1].start_tone = p_tones_parameter->tones[1].start_tone;
1046 p_msg_start->tones_parameter.tones[2].start_tone = p_tones_parameter->tones[2].start_tone;
1047 p_msg_start->tones_parameter.tones[0].stop_tone = p_tones_parameter->tones[0].stop_tone;
1048 p_msg_start->tones_parameter.tones[1].stop_tone = p_tones_parameter->tones[1].stop_tone;
1049 p_msg_start->tones_parameter.tones[2].stop_tone = p_tones_parameter->tones[2].stop_tone;
1050
1051 p_msg_start->tones_parameter.frame_duration= p_tones_parameter->frame_duration;
1052 p_msg_start->tones_parameter.sequence_duration = p_tones_parameter->sequence_duration;
1053 p_msg_start->tones_parameter.period_duration = p_tones_parameter->period_duration;
1054 p_msg_start->tones_parameter.repetition = p_tones_parameter->repetition;
1055
1056 if (return_path.callback_func == NULL)
1057 {
1058 p_msg_start->return_path.addr_id = return_path.addr_id;
1059 p_msg_start->return_path.callback_func = NULL;
1060 }
1061
1062 else
1063 {
1064 p_msg_start->return_path.callback_func = return_path.callback_func;
1065 }
1066
1067 /* send the messsage to the audio entity */
1068 rvf_send_msg (p_audio_gbl_var->addrId,
1069 p_msg_start);
1070
1071 return (AUDIO_OK);
1072 #else
1073 AUDIO_SEND_TRACE("VM Record not compiled", RV_TRACE_LEVEL_ERROR);
1074 return (AUDIO_ERROR);
1075 #endif
1076 } /*********************** End of audio_vm_record_start function ****************/
1077
1078 /********************************************************************************/
1079 /* */
1080 /* Function Name: audio_vm_record_stop */
1081 /* */
1082 /* Purpose: This function is called to stop a voice memorization Record */
1083 /* generation */
1084 /* */
1085 /* Input Parameters: */
1086 /* Return path. */
1087 /* */
1088 /* Output Parameters: */
1089 /* None. */
1090 /* */
1091 /* Note: */
1092 /* None. */
1093 /* */
1094 /* Revision History: */
1095 /* None. */
1096 /* */
1097 /********************************************************************************/
1098 T_AUDIO_RET audio_vm_record_stop (T_RV_RETURN return_path)
1099 {
1100 #if (VOICE_MEMO)
1101 /* Declare local variables. */
1102 T_RVF_MB_STATUS mb_status = RVF_GREEN;
1103 T_AUDIO_VM_RECORD_STOP *p_msg = NULL;
1104
1105 /************************ audio_vm_record_stop function begins *****************/
1106
1107 if (p_audio_gbl_var == NULL )
1108 {
1109 audio_voice_memo_error_trace(AUDIO_ENTITY_NOT_START);
1110 return(AUDIO_ERROR);
1111 }
1112
1113 /* allocate the memory for the message to send */
1114 mb_status = rvf_get_buf (p_audio_gbl_var->mb_external,
1115 sizeof (T_AUDIO_VM_RECORD_STOP),
1116 (T_RVF_BUFFER **) (&p_msg));
1117
1118 /* If insufficient resources, then report a memory error and abort. */
1119 if (mb_status == RVF_YELLOW)
1120 {
1121 /* deallocate the memory */
1122 rvf_free_buf((T_RVF_BUFFER *)p_msg);
1123 audio_voice_memo_error_trace(AUDIO_ENTITY_NO_MEMORY);
1124 return (AUDIO_ERROR);
1125 }
1126 else
1127 if (mb_status == RVF_RED)
1128 {
1129 audio_voice_memo_error_trace(AUDIO_ENTITY_NO_MEMORY);
1130 return (AUDIO_ERROR);
1131 }
1132
1133 /* fill the message id */
1134 p_msg->os_hdr.msg_id = AUDIO_VM_RECORD_STOP_REQ;
1135
1136 /* fill the address source id */
1137 p_msg->os_hdr.src_addr_id = rvf_get_taskid();
1138 p_msg->os_hdr.dest_addr_id = p_audio_gbl_var->addrId;
1139
1140 if (return_path.callback_func == NULL)
1141 {
1142 p_msg->return_path.addr_id = return_path.addr_id;
1143 p_msg->return_path.callback_func = NULL;
1144 }
1145 else
1146 {
1147 p_msg->return_path.callback_func = return_path.callback_func;
1148 }
1149
1150 /* send the messsage to the audio entity */
1151 rvf_send_msg (p_audio_gbl_var->addrId,
1152 p_msg);
1153
1154 return (AUDIO_OK);
1155 #else
1156 AUDIO_SEND_TRACE("VM Record not compiled", RV_TRACE_LEVEL_ERROR);
1157 return (AUDIO_ERROR);
1158 #endif
1159 } /*********************** End of audio_vm_record_Stop function *****************/
1160
1161 /********************************************************************************/
1162 /* */
1163 /* Function Name: audio_sr_enroll_start */
1164 /* */
1165 /* Purpose: This function is called to start the SR enrollment */
1166 /* */
1167 /* Input Parameters: */
1168 /* SR enrollment parameters */
1169 /* */
1170 /* Output Parameters: */
1171 /* None. */
1172 /* */
1173 /* Note: */
1174 /* None. */
1175 /* */
1176 /* Revision History: */
1177 /* None. */
1178 /* */
1179 /********************************************************************************/
1180 T_AUDIO_RET audio_sr_enroll_start (T_AUDIO_SR_ENROLL_PARAMETER *p_parameter,
1181 T_RV_RETURN return_path)
1182 {
1183 #if (SPEECH_RECO)
1184 /* Declare local variables. */
1185 T_RVF_MB_STATUS mb_status = RVF_GREEN;
1186 T_AUDIO_SR_ENROLL_START *p_msg_start = NULL;
1187 char sr_name[AUDIO_SR_PATH_NAME_MAX_SIZE];
1188 T_FFS_FD ffs_fd, sr_ffs_fd;
1189
1190 /************************ audio_sr_enroll_start function begins ***************/
1191
1192 if (p_audio_gbl_var == NULL )
1193 {
1194 audio_sr_error_trace(AUDIO_ENTITY_NOT_START);
1195 return(AUDIO_ERROR);
1196 }
1197
1198 /* Check the speech sample parameter */
1199 if ( (p_parameter->record_speech != AUDIO_SR_RECORD_SPEECH) &&
1200 (p_parameter->record_speech != AUDIO_SR_NO_RECORD_SPEECH) )
1201 {
1202 audio_sr_error_trace(AUDIO_ENTITY_BAD_PARAMETER);
1203 return(AUDIO_ERROR);
1204 }
1205
1206 /* Create the speech recognition sample file name */
1207 strcpy(sr_name, p_parameter->enroll_name);
1208 strcat(sr_name,"_sr");
1209
1210 #ifndef _WINDOWS
1211 sr_ffs_fd = ffs_open(sr_name,
1212 FFS_O_CREATE | FFS_O_WRONLY | FFS_O_TRUNC | FFS_O_APPEND);
1213 if (sr_ffs_fd <= 0)
1214 {
1215 audio_sr_error_trace(AUDIO_ENTITY_FILE_ERROR);
1216 return(AUDIO_ERROR);
1217 }
1218 #else
1219 sr_ffs_fd = 0x00000100;
1220 #endif
1221
1222 /* Create the speech sample file if it's requested.*/
1223 if (p_parameter->record_speech == AUDIO_SR_RECORD_SPEECH)
1224 {
1225 #ifndef _WINDOWS
1226 ffs_fd = ffs_open(p_parameter->enroll_name,
1227 FFS_O_CREATE | FFS_O_WRONLY | FFS_O_TRUNC | FFS_O_APPEND);
1228 if (ffs_fd <= 0)
1229 {
1230 ffs_close(sr_ffs_fd);
1231 audio_sr_error_trace(AUDIO_ENTITY_FILE_ERROR);
1232 return (AUDIO_ERROR);
1233 }
1234 #else
1235 ffs_fd = 0x00000101;
1236 #endif
1237 }
1238 else
1239 {
1240 ffs_fd = AUDIO_SR_NO_RECORD_SPEECH;
1241 }
1242
1243 /* allocate the memory for the message to send */
1244 mb_status = rvf_get_buf (p_audio_gbl_var->mb_external,
1245 sizeof (T_AUDIO_SR_ENROLL_START),
1246 (T_RVF_BUFFER **) (&p_msg_start));
1247
1248 /* If insufficient resources, then report a memory error and abort. */
1249 if (mb_status == RVF_YELLOW)
1250 {
1251 /* deallocate the memory */
1252 rvf_free_buf((T_RVF_BUFFER *)p_msg_start);
1253 audio_sr_error_trace(AUDIO_ENTITY_NO_MEMORY);
1254 #ifndef _WINDOWS
1255 /* close the file previously open */
1256 ffs_close(sr_ffs_fd);
1257 if (p_parameter->record_speech == AUDIO_SR_RECORD_SPEECH)
1258 {
1259 ffs_close(ffs_fd);
1260 }
1261 #endif
1262 return (AUDIO_ERROR);
1263 }
1264 else
1265 if (mb_status == RVF_RED)
1266 {
1267 audio_sr_error_trace(AUDIO_ENTITY_NO_MEMORY);
1268 #ifndef _WINDOWS
1269 /* close the file previously open */
1270 ffs_close(sr_ffs_fd);
1271 if (p_parameter->record_speech == AUDIO_SR_RECORD_SPEECH)
1272 {
1273 ffs_close(ffs_fd);
1274 }
1275 #endif
1276 return (AUDIO_ERROR);
1277 }
1278
1279 /* fill the message id */
1280 p_msg_start->os_hdr.msg_id = AUDIO_SR_ENROLL_START_REQ;
1281
1282 /* fill the address source id */
1283 p_msg_start->os_hdr.src_addr_id = rvf_get_taskid();
1284 p_msg_start->os_hdr.dest_addr_id = p_audio_gbl_var->addrId;
1285
1286 /* fill the message parameters */
1287 p_msg_start->sr_ffs_fd = sr_ffs_fd;
1288 p_msg_start->voice_ffs_fd = ffs_fd;
1289
1290 if (return_path.callback_func == NULL)
1291 {
1292 p_msg_start->return_path.addr_id = return_path.addr_id;
1293 p_msg_start->return_path.callback_func = NULL;
1294 }
1295 else
1296 {
1297 p_msg_start->return_path.callback_func = return_path.callback_func;
1298 }
1299
1300 /* send the messsage to the audio entity */
1301 rvf_send_msg (p_audio_gbl_var->addrId,
1302 p_msg_start);
1303
1304 return (AUDIO_OK);
1305 #else
1306 AUDIO_SEND_TRACE("Speech Reco not compiled", RV_TRACE_LEVEL_ERROR);
1307 return (AUDIO_ERROR);
1308 #endif
1309 } /*********************** End of audio_enroll_Start function **********************/
1310
1311 /********************************************************************************/
1312 /* */
1313 /* Function Name: audio_sr_enroll_stop */
1314 /* */
1315 /* Purpose: This function is called to stop the SR enrollment */
1316 /* */
1317 /* Input Parameters: */
1318 /* SR enrollment parameters */
1319 /* */
1320 /* Output Parameters: */
1321 /* None. */
1322 /* */
1323 /* Note: */
1324 /* None. */
1325 /* */
1326 /* Revision History: */
1327 /* None. */
1328 /* */
1329 /********************************************************************************/
1330 T_AUDIO_RET audio_sr_enroll_stop (T_RV_RETURN return_path)
1331 {
1332 #if (SPEECH_RECO)
1333 /* Declare local variables. */
1334 T_RVF_MB_STATUS mb_status = RVF_GREEN;
1335 T_AUDIO_SR_ENROLL_STOP *p_msg_start = NULL;
1336
1337 /************************ audio_sr_enroll_start function begins ***************/
1338
1339 if (p_audio_gbl_var == NULL )
1340 {
1341 audio_sr_error_trace(AUDIO_ENTITY_NOT_START);
1342 return(AUDIO_ERROR);
1343 }
1344
1345 /* allocate the memory for the message to send */
1346 mb_status = rvf_get_buf (p_audio_gbl_var->mb_external,
1347 sizeof (T_AUDIO_SR_ENROLL_STOP),
1348 (T_RVF_BUFFER **) (&p_msg_start));
1349
1350 /* If insufficient resources, then report a memory error and abort. */
1351 if (mb_status == RVF_YELLOW)
1352 {
1353 /* deallocate the memory */
1354 rvf_free_buf((T_RVF_BUFFER *)p_msg_start);
1355 audio_sr_error_trace(AUDIO_ENTITY_NO_MEMORY);
1356 return (AUDIO_ERROR);
1357 }
1358 else
1359 if (mb_status == RVF_RED)
1360 {
1361 audio_sr_error_trace(AUDIO_ENTITY_NO_MEMORY);
1362 return (AUDIO_ERROR);
1363 }
1364
1365 /* fill the message id */
1366 p_msg_start->os_hdr.msg_id = AUDIO_SR_ENROLL_STOP_REQ;
1367
1368 /* fill the address source id */
1369 p_msg_start->os_hdr.src_addr_id = rvf_get_taskid();
1370 p_msg_start->os_hdr.dest_addr_id = p_audio_gbl_var->addrId;
1371
1372 /* fill the message parameters */
1373 if (return_path.callback_func == NULL)
1374 {
1375 p_msg_start->return_path.addr_id = return_path.addr_id;
1376 p_msg_start->return_path.callback_func = NULL;
1377 }
1378 else
1379 {
1380 p_msg_start->return_path.callback_func = return_path.callback_func;
1381 }
1382
1383 /* send the messsage to the audio entity */
1384 rvf_send_msg (p_audio_gbl_var->addrId,
1385 p_msg_start);
1386
1387 return (AUDIO_OK);
1388 #else
1389 AUDIO_SEND_TRACE("Speech Reco not compiled", RV_TRACE_LEVEL_ERROR);
1390 return (AUDIO_ERROR);
1391 #endif
1392 } /*********************** End of audio_sr_enroll_stop function *****************/
1393
1394 /********************************************************************************/
1395 /* */
1396 /* Function Name: audio_sr_update_start */
1397 /* */
1398 /* Purpose: This function is called to start the SR update */
1399 /* */
1400 /* Input Parameters: */
1401 /* SR update parameters */
1402 /* */
1403 /* Output Parameters: */
1404 /* None. */
1405 /* */
1406 /* Note: */
1407 /* None. */
1408 /* */
1409 /* Revision History: */
1410 /* None. */
1411 /* */
1412 /********************************************************************************/
1413 T_AUDIO_RET audio_sr_update_start (T_AUDIO_SR_UPDATE_PARAMETER *p_parameter,
1414 T_RV_RETURN return_path)
1415 {
1416 #if (SPEECH_RECO)
1417 /* Declare local variables. */
1418 T_RVF_MB_STATUS mb_status = RVF_GREEN;
1419 T_AUDIO_SR_UPDATE_START *p_msg_start = NULL;
1420 UINT8 i, folder_size=0, path_size;
1421 char sr_name[AUDIO_SR_PATH_NAME_MAX_SIZE],
1422 sr_dir[AUDIO_SR_PATH_NAME_MAX_SIZE],
1423 *p_database;
1424 INT8 model_index, model_number;
1425 #ifndef _WINDOWS
1426 char *p_model_path;
1427 #endif
1428
1429 /************************ audio_sr_update_start function begins ***************/
1430
1431 if (p_audio_gbl_var == NULL )
1432 {
1433 audio_sr_error_trace(AUDIO_ENTITY_NOT_START);
1434 return(AUDIO_ERROR);
1435 }
1436
1437 /* Check the speech sample parameter */
1438 if ( (p_parameter->record_speech != AUDIO_SR_RECORD_SPEECH) &&
1439 (p_parameter->record_speech != AUDIO_SR_NO_RECORD_SPEECH) )
1440 {
1441 audio_sr_error_trace(AUDIO_ENTITY_BAD_PARAMETER);
1442 return(AUDIO_ERROR);
1443 }
1444
1445 /* Create the speech recognition sample file name */
1446 strcpy(sr_name, p_parameter->update_name);
1447 strcat(sr_name,"_sr");
1448
1449 /* Check the number of speech reco model are included in the current folder */
1450 /* in order to know if the update or the update check needs to be run */
1451 path_size = (UINT8)strlen(p_parameter->update_name);
1452 i = 0;
1453 while (i < path_size)
1454 {
1455 if (strncmp(&(p_parameter->update_name[i]), "/", 1) == 0)
1456 {
1457 folder_size = i;
1458 }
1459 i++;
1460 }
1461 if ((folder_size + 1) == path_size)
1462 {
1463 /* this isn't a name but a folder */
1464 audio_sr_error_trace(AUDIO_ENTITY_BAD_PARAMETER);
1465 return(AUDIO_ERROR);
1466 }
1467 /* Create the speech recognition folder name */
1468 strncpy(sr_dir, p_parameter->update_name, folder_size);
1469 sr_dir[folder_size] = 0;
1470
1471 /* check the number of model in the database */
1472 model_number = audio_sr_create_vocabulary_database(sr_dir, (void **)(&p_database));
1473 if (model_number == AUDIO_ERROR)
1474 {
1475 return(AUDIO_ERROR);
1476 }
1477
1478 #ifndef _WINDOWS
1479 /* find the index of the model to updae */
1480 p_model_path = p_database;
1481 model_index == -1;
1482 for (i=0; i<model_number; i++)
1483 {
1484 if ( strcmp(p_model_path, sr_name) == 0 )
1485 {
1486 model_index = i;
1487 }
1488 p_model_path += AUDIO_PATH_NAME_MAX_SIZE;
1489 }
1490 if (model_index == -1)
1491 /* no file correspoding to the model to update */
1492 {
1493 audio_sr_error_trace(AUDIO_ENTITY_FILE_ERROR);
1494 rvf_free_buf((T_RVF_BUFFER *)p_database);
1495 return (AUDIO_ERROR);
1496 }
1497 #else
1498 model_index = 0;
1499 #endif
1500
1501 /* allocate the memory for the message to send */
1502 mb_status = rvf_get_buf (p_audio_gbl_var->mb_external,
1503 sizeof (T_AUDIO_SR_UPDATE_START),
1504 (T_RVF_BUFFER **) (&p_msg_start));
1505
1506 /* If insufficient resources, then report a memory error and abort. */
1507 if (mb_status == RVF_YELLOW)
1508 {
1509 /* deallocate the memory */
1510 rvf_free_buf((T_RVF_BUFFER *)p_database);
1511 rvf_free_buf((T_RVF_BUFFER *)p_msg_start);
1512 audio_sr_error_trace(AUDIO_ENTITY_NO_MEMORY);
1513 return (AUDIO_ERROR);
1514 }
1515 else
1516 if (mb_status == RVF_RED)
1517 {
1518 rvf_free_buf((T_RVF_BUFFER *)p_database);
1519 audio_sr_error_trace(AUDIO_ENTITY_NO_MEMORY);
1520 return (AUDIO_ERROR);
1521 }
1522
1523 /* fill the message id */
1524 p_msg_start->os_hdr.msg_id = AUDIO_SR_UPDATE_START_REQ;
1525
1526 /* fill the address source id */
1527 p_msg_start->os_hdr.src_addr_id = rvf_get_taskid();
1528 p_msg_start->os_hdr.dest_addr_id = p_audio_gbl_var->addrId;
1529
1530 /* fill the message parameters */
1531 p_msg_start->vocabulary_size = model_number;
1532 p_msg_start->model_index = model_index;
1533 p_msg_start->p_database = p_database;
1534 p_msg_start->record_speech = p_parameter->record_speech;
1535
1536 if (return_path.callback_func == NULL)
1537 {
1538 p_msg_start->return_path.addr_id = return_path.addr_id;
1539 p_msg_start->return_path.callback_func = NULL;
1540 }
1541 else
1542 {
1543 p_msg_start->return_path.callback_func = return_path.callback_func;
1544 }
1545
1546 /* send the messsage to the audio entity */
1547 rvf_send_msg (p_audio_gbl_var->addrId,
1548 p_msg_start);
1549
1550 return (AUDIO_OK);
1551 #else
1552 AUDIO_SEND_TRACE("Speech Reco not compiled", RV_TRACE_LEVEL_ERROR);
1553 return (AUDIO_ERROR);
1554 #endif
1555 } /*********************** End of audio_sr_update_start function ****************/
1556
1557 /********************************************************************************/
1558 /* */
1559 /* Function Name: audio_sr_update_stop */
1560 /* */
1561 /* Purpose: This function is called to stop the SR update t */
1562 /* */
1563 /* Input Parameters: */
1564 /* SR update parameters */
1565 /* */
1566 /* Output Parameters: */
1567 /* None. */
1568 /* */
1569 /* Note: */
1570 /* None. */
1571 /* */
1572 /* Revision History: */
1573 /* None. */
1574 /* */
1575 /********************************************************************************/
1576 T_AUDIO_RET audio_sr_update_stop (T_RV_RETURN return_path)
1577 {
1578 #if (SPEECH_RECO)
1579 /* Declare local variables. */
1580 T_RVF_MB_STATUS mb_status = RVF_GREEN;
1581 T_AUDIO_SR_UPDATE_STOP *p_msg_start = NULL;
1582
1583 /************************ audio_sr_update_start function begins ***************/
1584
1585 if (p_audio_gbl_var == NULL )
1586 {
1587 audio_sr_error_trace(AUDIO_ENTITY_NOT_START);
1588 return(AUDIO_ERROR);
1589 }
1590
1591 /* allocate the memory for the message to send */
1592 mb_status = rvf_get_buf (p_audio_gbl_var->mb_external,
1593 sizeof (T_AUDIO_SR_UPDATE_STOP),
1594 (T_RVF_BUFFER **) (&p_msg_start));
1595
1596 /* If insufficient resources, then report a memory error and abort. */
1597 if (mb_status == RVF_YELLOW)
1598 {
1599 /* deallocate the memory */
1600 rvf_free_buf((T_RVF_BUFFER *)p_msg_start);
1601 audio_sr_error_trace(AUDIO_ENTITY_NO_MEMORY);
1602 return (AUDIO_ERROR);
1603 }
1604 else
1605 if (mb_status == RVF_RED)
1606 {
1607 audio_sr_error_trace(AUDIO_ENTITY_NO_MEMORY);
1608 return (AUDIO_ERROR);
1609 }
1610
1611 /* fill the message id */
1612 p_msg_start->os_hdr.msg_id = AUDIO_SR_UPDATE_STOP_REQ;
1613
1614 /* fill the address source id */
1615 p_msg_start->os_hdr.src_addr_id = rvf_get_taskid();
1616 p_msg_start->os_hdr.dest_addr_id = p_audio_gbl_var->addrId;
1617
1618 /* fill the message parameters */
1619 if (return_path.callback_func == NULL)
1620 {
1621 p_msg_start->return_path.addr_id = return_path.addr_id;
1622 p_msg_start->return_path.callback_func = NULL;
1623 }
1624 else
1625 {
1626 p_msg_start->return_path.callback_func = return_path.callback_func;
1627 }
1628
1629 /* send the messsage to the audio entity */
1630 rvf_send_msg (p_audio_gbl_var->addrId,
1631 p_msg_start);
1632
1633 return (AUDIO_OK);
1634 #else
1635 AUDIO_SEND_TRACE("Speech Reco not compiled", RV_TRACE_LEVEL_ERROR);
1636 return (AUDIO_ERROR);
1637 #endif
1638 } /*********************** End of audio_sr_update_stop function *****************/
1639
1640 /********************************************************************************/
1641 /* */
1642 /* Function Name: audio_sr_reco_start */
1643 /* */
1644 /* Purpose: This function is called to start the SR recognition */
1645 /* */
1646 /* Input Parameters: */
1647 /* SR update parameters */
1648 /* */
1649 /* Output Parameters: */
1650 /* None. */
1651 /* */
1652 /* Note: */
1653 /* None. */
1654 /* */
1655 /* Revision History: */
1656 /* None. */
1657 /* */
1658 /********************************************************************************/
1659 T_AUDIO_RET audio_sr_reco_start (T_AUDIO_SR_RECO_PARAMETER *p_parameter,
1660 T_RV_RETURN return_path)
1661 {
1662 #if (SPEECH_RECO)
1663 /* Declare local variables. */
1664 T_RVF_MB_STATUS mb_status = RVF_GREEN;
1665 T_AUDIO_SR_RECO_START *p_msg_start = NULL;
1666 INT8 model_number;
1667 void *p_database;
1668
1669 /************************ audio_sr_reco_start function begins ****************/
1670
1671 if (p_audio_gbl_var == NULL )
1672 {
1673 audio_sr_error_trace(AUDIO_ENTITY_NOT_START);
1674 return(AUDIO_ERROR);
1675 }
1676
1677 /* check if the / is in the end of the directory */
1678 if(strlen(p_parameter->database_directory) == 0)
1679 {
1680 audio_sr_error_trace(AUDIO_ENTITY_BAD_DATABASE);
1681 return(AUDIO_ERROR);
1682 }
1683 else if ( strncmp(&(p_parameter->database_directory[strlen(p_parameter->database_directory) - 1]),
1684 "/", 1) == 0 )
1685 {
1686 audio_sr_error_trace(AUDIO_ENTITY_BAD_DATABASE);
1687 return(AUDIO_ERROR);
1688 }
1689
1690 /* check the number of model in the database */
1691 model_number = audio_sr_create_vocabulary_database(p_parameter->database_directory,
1692 (void **)(&p_database));
1693 if (model_number == AUDIO_ERROR)
1694 {
1695 audio_sr_error_trace(AUDIO_ENTITY_BAD_DATABASE);
1696 return(AUDIO_ERROR);
1697 }
1698
1699 /* allocate the memory for the message to send */
1700 mb_status = rvf_get_buf (p_audio_gbl_var->mb_external,
1701 sizeof (T_AUDIO_SR_RECO_START),
1702 (T_RVF_BUFFER **) (&p_msg_start));
1703
1704 /* If insufficient resources, then report a memory error and abort. */
1705 if (mb_status == RVF_YELLOW)
1706 {
1707 /* deallocate the memory */
1708 rvf_free_buf((T_RVF_BUFFER *)p_database);
1709 rvf_free_buf((T_RVF_BUFFER *)p_msg_start);
1710 audio_sr_error_trace(AUDIO_ENTITY_NO_MEMORY);
1711 return (AUDIO_ERROR);
1712 }
1713 else
1714 if (mb_status == RVF_RED)
1715 {
1716 rvf_free_buf((T_RVF_BUFFER *)p_database);
1717 audio_sr_error_trace(AUDIO_ENTITY_NO_MEMORY);
1718 return (AUDIO_ERROR);
1719 }
1720
1721 /* fill the message id */
1722 p_msg_start->os_hdr.msg_id = AUDIO_SR_RECO_START_REQ;
1723
1724 /* fill the address source id */
1725 p_msg_start->os_hdr.src_addr_id = rvf_get_taskid();
1726 p_msg_start->os_hdr.dest_addr_id = p_audio_gbl_var->addrId;
1727
1728 /* fill the message parameters */
1729 p_msg_start->vocabulary_size = model_number;
1730 p_msg_start->p_database = p_database;
1731
1732 if (return_path.callback_func == NULL)
1733 {
1734 p_msg_start->return_path.addr_id = return_path.addr_id;
1735 p_msg_start->return_path.callback_func = NULL;
1736 }
1737 else
1738 {
1739 p_msg_start->return_path.callback_func = return_path.callback_func;
1740 }
1741
1742 /* send the messsage to the audio entity */
1743 rvf_send_msg (p_audio_gbl_var->addrId,
1744 p_msg_start);
1745
1746 return (AUDIO_OK);
1747 #else
1748 AUDIO_SEND_TRACE("Speech Reco not compiled", RV_TRACE_LEVEL_ERROR);
1749 return (AUDIO_ERROR);
1750 #endif
1751 } /*********************** End of audio_sr_reco_Start function ******************/
1752
1753 /********************************************************************************/
1754 /* */
1755 /* Function Name: audio_sr_reco_stop */
1756 /* */
1757 /* Purpose: This function is called to stop the SR recognition */
1758 /* */
1759 /* Input Parameters: */
1760 /* SR reco parameters */
1761 /* */
1762 /* Output Parameters: */
1763 /* None. */
1764 /* */
1765 /* Note: */
1766 /* None. */
1767 /* */
1768 /* Revision History: */
1769 /* None. */
1770 /* */
1771 /********************************************************************************/
1772 T_AUDIO_RET audio_sr_reco_stop (T_RV_RETURN return_path)
1773 {
1774 #if (SPEECH_RECO)
1775 /* Declare local variables. */
1776 T_RVF_MB_STATUS mb_status = RVF_GREEN;
1777 T_AUDIO_SR_RECO_STOP *p_msg_start = NULL;
1778
1779 /************************ audio_sr_reco_stop function begins ******************/
1780
1781 if (p_audio_gbl_var == NULL )
1782 {
1783 audio_sr_error_trace(AUDIO_ENTITY_NOT_START);
1784 return(AUDIO_ERROR);
1785 }
1786
1787 /* allocate the memory for the message to send */
1788 mb_status = rvf_get_buf (p_audio_gbl_var->mb_external,
1789 sizeof (T_AUDIO_SR_RECO_STOP),
1790 (T_RVF_BUFFER **) (&p_msg_start));
1791
1792 /* If insufficient resources, then report a memory error and abort. */
1793 if (mb_status == RVF_YELLOW)
1794 {
1795 /* deallocate the memory */
1796 rvf_free_buf((T_RVF_BUFFER *)p_msg_start);
1797 audio_sr_error_trace(AUDIO_ENTITY_NO_MEMORY);
1798 return (AUDIO_ERROR);
1799 }
1800 else
1801 if (mb_status == RVF_RED)
1802 {
1803 audio_sr_error_trace(AUDIO_ENTITY_NO_MEMORY);
1804 return (AUDIO_ERROR);
1805 }
1806
1807 /* fill the message id */
1808 p_msg_start->os_hdr.msg_id = AUDIO_SR_RECO_STOP_REQ;
1809
1810 /* fill the address source id */
1811 p_msg_start->os_hdr.src_addr_id = rvf_get_taskid();
1812 p_msg_start->os_hdr.dest_addr_id = p_audio_gbl_var->addrId;
1813
1814 /* fill the message parameters */
1815 if (return_path.callback_func == NULL)
1816 {
1817 p_msg_start->return_path.addr_id = return_path.addr_id;
1818 p_msg_start->return_path.callback_func = NULL;
1819 }
1820 else
1821 {
1822 p_msg_start->return_path.callback_func = return_path.callback_func;
1823 }
1824
1825 /* send the messsage to the audio entity */
1826 rvf_send_msg (p_audio_gbl_var->addrId,
1827 p_msg_start);
1828
1829 return (AUDIO_OK);
1830 #else
1831 AUDIO_SEND_TRACE("Speech Reco not compiled", RV_TRACE_LEVEL_ERROR);
1832 return (AUDIO_ERROR);
1833 #endif
1834 } /*********************** End of audio_sr_reco_stop function *******************/
1835
1836 /********************************************************************************/
1837 /* */
1838 /* Function Name: audio_full_access_write */
1839 /* */
1840 /* Purpose: This function is called to configure the audio mode */
1841 /* */
1842 /* Input Parameters: */
1843 /* audio configuration */
1844 /* */
1845 /* Output Parameters: */
1846 /* None. */
1847 /* */
1848 /* Note: */
1849 /* None. */
1850 /* */
1851 /* Revision History: */
1852 /* None. */
1853 /* */
1854 /********************************************************************************/
1855 T_AUDIO_RET audio_full_access_write (T_AUDIO_FULL_ACCESS_WRITE *p_parameter,
1856 T_RV_RETURN return_path)
1857 {
1858 UINT8 size;
1859 INT8 i;
1860 T_RVF_MB_STATUS mb_status = RVF_GREEN;
1861 T_AUDIO_MODE_FULL_ACCESS_WRITE_REQ *p_msg_start = NULL;
1862 void *p_data_buffer = NULL;
1863 INT8 *p_read, *p_write;
1864
1865 /************************ audio_full_access_write function begins ***********************/
1866
1867 if (p_audio_gbl_var == NULL )
1868 {
1869 audio_mode_error_trace(AUDIO_ENTITY_NOT_START);
1870 return(AUDIO_ERROR);
1871 }
1872
1873 /* check if the data exist */
1874 if (p_parameter->data == NULL)
1875 {
1876 audio_mode_error_trace(AUDIO_ENTITY_BAD_PARAMETER);
1877 return(AUDIO_ERROR);
1878 }
1879
1880 switch (p_parameter->variable_indentifier)
1881 {
1882 case AUDIO_PATH_USED:
1883 {
1884 if ( (*((T_AUDIO_VOICE_PATH_SETTING *)p_parameter->data) != AUDIO_GSM_VOICE_PATH) &&
1885 (*((T_AUDIO_VOICE_PATH_SETTING *)p_parameter->data) != AUDIO_BLUETOOTH_CORDLESS_VOICE_PATH) &&
1886 (*((T_AUDIO_VOICE_PATH_SETTING *)p_parameter->data) != AUDIO_BLUETOOTH_HEADSET) &&
1887 (*((T_AUDIO_VOICE_PATH_SETTING *)p_parameter->data) != AUDIO_DAI_ENCODER) &&
1888 (*((T_AUDIO_VOICE_PATH_SETTING *)p_parameter->data) != AUDIO_DAI_DECODER) &&
1889 (*((T_AUDIO_VOICE_PATH_SETTING *)p_parameter->data) != AUDIO_DAI_ACOUSTIC) )
1890 {
1891 audio_mode_error_trace(AUDIO_ENTITY_BAD_PARAMETER);
1892 return (AUDIO_ERROR);
1893 }
1894
1895 size = sizeof(T_AUDIO_VOICE_PATH_SETTING);
1896 break;
1897 }
1898 case AUDIO_MICROPHONE_MODE:
1899 {
1900 if ( (*((INT8 *)p_parameter->data) != AUDIO_MICROPHONE_HANDHELD) &&
1901 (*((INT8 *)p_parameter->data) != AUDIO_MICROPHONE_HANDFREE) &&
1902 (*((INT8 *)p_parameter->data) != AUDIO_MICROPHONE_HEADSET) )
1903 {
1904 audio_mode_error_trace(AUDIO_ENTITY_BAD_PARAMETER);
1905 return (AUDIO_ERROR);
1906 }
1907
1908 size = sizeof(INT8 );
1909 break;
1910 }
1911 case AUDIO_MICROPHONE_GAIN:
1912 {
1913 if (*((INT8 *)p_parameter->data) != AUDIO_MICROPHONE_MUTE)
1914 {
1915 if ( (*((INT8 *)p_parameter->data) < -12) ||
1916 (*((INT8 *)p_parameter->data) > 12) )
1917 {
1918 audio_mode_error_trace(AUDIO_ENTITY_BAD_PARAMETER);
1919 return (AUDIO_ERROR);
1920 }
1921 }
1922
1923 size = sizeof(INT8 );
1924 break;
1925 }
1926 case AUDIO_MICROPHONE_EXTRA_GAIN:
1927 {
1928 if ( (*((INT8 *)p_parameter->data) != AUDIO_MICROPHONE_AUX_GAIN_28_2dB) &&
1929 (*((INT8 *)p_parameter->data) != AUDIO_MICROPHONE_AUX_GAIN_4_6dB) )
1930 {
1931 audio_mode_error_trace(AUDIO_ENTITY_BAD_PARAMETER);
1932 return (AUDIO_ERROR);
1933 }
1934
1935 size = sizeof(INT8 );
1936 break;
1937 }
1938 case AUDIO_MICROPHONE_OUTPUT_BIAS:
1939 {
1940 if ( (*((INT8 *)p_parameter->data) != AUDIO_MICROPHONE_OUTPUT_BIAS_2_0V) &&
1941 (*((INT8 *)p_parameter->data) != AUDIO_MICROPHONE_OUTPUT_BIAS_2_5V) )
1942 {
1943 audio_mode_error_trace(AUDIO_ENTITY_BAD_PARAMETER);
1944 return (AUDIO_ERROR);
1945 }
1946
1947 size = sizeof(INT8 );
1948 break;
1949 }
1950 case AUDIO_MICROPHONE_FIR:
1951 {
1952 size = sizeof(T_AUDIO_FIR_COEF);
1953 break;
1954 }
1955 case AUDIO_SPEAKER_MODE:
1956 {
1957 if ( (*((INT8 *)p_parameter->data) != AUDIO_SPEAKER_HANDHELD) &&
1958 (*((INT8 *)p_parameter->data) != AUDIO_SPEAKER_HANDFREE) &&
1959 (*((INT8 *)p_parameter->data) != AUDIO_SPEAKER_HEADSET) &&
1960 (*((INT8 *)p_parameter->data) != AUDIO_SPEAKER_BUZZER) &&
1961 (*((INT8 *)p_parameter->data) != AUDIO_SPEAKER_HANDHELD_HANDFREE) )
1962 {
1963 audio_mode_error_trace(AUDIO_ENTITY_BAD_PARAMETER);
1964 return (AUDIO_ERROR);
1965 }
1966
1967 size = sizeof(INT8 );
1968 break;
1969 }
1970 case AUDIO_SPEAKER_GAIN:
1971 {
1972 if ( (*((INT8 *)p_parameter->data) < -6) ||
1973 (*((INT8 *)p_parameter->data) > 6) )
1974 {
1975 audio_mode_error_trace(AUDIO_ENTITY_BAD_PARAMETER);
1976 return (AUDIO_ERROR);
1977 }
1978
1979 size = sizeof(INT8 );
1980 break;
1981 }
1982 case AUDIO_SPEAKER_FILTER:
1983 {
1984 if ( (*((INT8 *)p_parameter->data) != AUDIO_SPEAKER_FILTER_ON) &&
1985 (*((INT8 *)p_parameter->data) != AUDIO_SPEAKER_FILTER_OFF) )
1986 {
1987 audio_mode_error_trace(AUDIO_ENTITY_BAD_PARAMETER);
1988 return (AUDIO_ERROR);
1989 }
1990
1991 size = sizeof(INT8 );
1992 break;
1993 }
1994 case AUDIO_SPEAKER_FIR:
1995 {
1996 size = sizeof(T_AUDIO_FIR_COEF);
1997 break;
1998 }
1999 case AUDIO_SPEAKER_BUZZER_STATE:
2000 {
2001 if ( (*((INT8 *)p_parameter->data) != AUDIO_SPEAKER_BUZZER_ON) &&
2002 (*((INT8 *)p_parameter->data) != AUDIO_SPEAKER_BUZZER_OFF) )
2003 {
2004 audio_mode_error_trace(AUDIO_ENTITY_BAD_PARAMETER);
2005 return (AUDIO_ERROR);
2006 }
2007
2008 size = sizeof(INT8 );
2009 break;
2010 }
2011 case AUDIO_MICROPHONE_SPEAKER_LOOP_SIDETONE:
2012 {
2013 i = ((*((INT8 *)p_parameter->data))-1)%3;
2014
2015 if ( (*((INT8 *)p_parameter->data) != AUDIO_SIDETONE_OPEN) &&
2016 ( (*((INT8 *)p_parameter->data) < -23) ||
2017 (*((INT8 *)p_parameter->data) > 1) ||
2018 (i != 0) ) )
2019 {
2020 audio_mode_error_trace(AUDIO_ENTITY_BAD_PARAMETER);
2021 return (AUDIO_ERROR);
2022 }
2023
2024 size = sizeof(INT8 );
2025 break;
2026 }
2027 case AUDIO_MICROPHONE_SPEAKER_LOOP_AEC:
2028 {
2029 T_AUDIO_AEC_CFG *aec_param;
2030 aec_param = (T_AUDIO_AEC_CFG *)p_parameter->data;
2031
2032 #if (L1_NEW_AEC)
2033 if ( ((aec_param->aec_enable != AUDIO_AEC_ENABLE) &&
2034 (aec_param->aec_enable != AUDIO_AEC_DISABLE)) ||
2035 ((aec_param->aec_visibility != AUDIO_AEC_VISIBILITY_ENABLE) &&
2036 (aec_param->aec_visibility != AUDIO_AEC_VISIBILITY_DISABLE)) ||
2037 ((aec_param->continuous_filtering != TRUE) &&
2038 (aec_param->continuous_filtering != FALSE)) ||
2039 ((aec_param->noise_suppression_enable != AUDIO_NOISE_SUPPRESSION_ENABLE) &&
2040 (aec_param->noise_suppression_enable != AUDIO_NOISE_SUPPRESSION_DISABLE)) ||
2041 ((aec_param->noise_suppression_level != AUDIO_NOISE_NO_LIMITATION) &&
2042 (aec_param->noise_suppression_level != AUDIO_NOISE_6dB) &&
2043 (aec_param->noise_suppression_level != AUDIO_NOISE_12dB) &&
2044 (aec_param->noise_suppression_level != AUDIO_NOISE_18dB)) )
2045 #else
2046 if ( (aec_param->aec_enable != AUDIO_AEC_ENABLE) &&
2047 (aec_param->aec_enable != AUDIO_AEC_DISABLE) &&
2048 (aec_param->aec_mode != AUDIO_SHORT_ECHO) &&
2049 (aec_param->aec_mode != AUDIO_LONG_ECHO) &&
2050 (aec_param->echo_suppression_level != AUDIO_ECHO_0dB) &&
2051 (aec_param->echo_suppression_level != AUDIO_ECHO_6dB) &&
2052 (aec_param->echo_suppression_level != AUDIO_ECHO_12dB) &&
2053 (aec_param->echo_suppression_level != AUDIO_ECHO_18dB) &&
2054 (aec_param->noise_suppression_enable != AUDIO_NOISE_SUPPRESSION_ENABLE) &&
2055 (aec_param->noise_suppression_enable != AUDIO_NOISE_SUPPRESSION_DISABLE) &&
2056 (aec_param->noise_suppression_level != AUDIO_NOISE_NO_LIMITATION) &&
2057 (aec_param->noise_suppression_enable != AUDIO_NOISE_6dB) &&
2058 (aec_param->noise_suppression_level != AUDIO_NOISE_12dB) &&
2059 (aec_param->noise_suppression_level != AUDIO_NOISE_18dB) )
2060 #endif
2061 {
2062 audio_mode_error_trace(AUDIO_ENTITY_BAD_PARAMETER);
2063 return (AUDIO_ERROR);
2064 }
2065
2066 size = sizeof(T_AUDIO_AEC_CFG);
2067 break;
2068 }
2069 case AUDIO_SPEAKER_VOLUME_LEVEL:
2070 {
2071 if ( (((T_AUDIO_SPEAKER_LEVEL *)p_parameter->data)->audio_speaker_level != AUDIO_SPEAKER_VOLUME_MUTE) &&
2072 (((T_AUDIO_SPEAKER_LEVEL *)p_parameter->data)->audio_speaker_level != AUDIO_SPEAKER_VOLUME_0dB) &&
2073 (((T_AUDIO_SPEAKER_LEVEL *)p_parameter->data)->audio_speaker_level != AUDIO_SPEAKER_VOLUME_6dB) &&
2074 (((T_AUDIO_SPEAKER_LEVEL *)p_parameter->data)->audio_speaker_level != AUDIO_SPEAKER_VOLUME_12dB) &&
2075 (((T_AUDIO_SPEAKER_LEVEL *)p_parameter->data)->audio_speaker_level != AUDIO_SPEAKER_VOLUME_18dB) &&
2076 (((T_AUDIO_SPEAKER_LEVEL *)p_parameter->data)->audio_speaker_level != AUDIO_SPEAKER_VOLUME_24dB) )
2077 {
2078 audio_mode_error_trace(AUDIO_ENTITY_BAD_PARAMETER);
2079 return (AUDIO_ERROR);
2080 }
2081
2082 size = sizeof(T_AUDIO_SPEAKER_LEVEL);
2083 break;
2084 }
2085 default :
2086 {
2087 audio_mode_error_trace(AUDIO_ENTITY_BAD_PARAMETER);
2088 return (AUDIO_ERROR);
2089 }
2090 }
2091
2092 /* allocate the memory for the message to send */
2093 mb_status = rvf_get_buf (p_audio_gbl_var->mb_external,
2094 sizeof (T_AUDIO_MODE_FULL_ACCESS_WRITE_REQ),
2095 (T_RVF_BUFFER **) (&p_msg_start));
2096
2097 /* If insufficient resources, then report a memory error and abort. */
2098 if (mb_status == RVF_YELLOW)
2099 {
2100 /* deallocate the memory */
2101 rvf_free_buf((T_RVF_BUFFER *)p_msg_start);
2102 audio_mode_error_trace(AUDIO_ENTITY_NO_MEMORY);
2103 return (AUDIO_ERROR);
2104 }
2105 else
2106 if (mb_status == RVF_RED)
2107 {
2108 audio_mode_error_trace(AUDIO_ENTITY_NO_MEMORY);
2109 return (AUDIO_ERROR);
2110 }
2111
2112 /* allocate the memory for the data to write */
2113 mb_status = rvf_get_buf (p_audio_gbl_var->mb_external,
2114 size,
2115 (T_RVF_BUFFER **) (&p_data_buffer));
2116
2117 /* If insufficient resources, then report a memory error and abort. */
2118 if (mb_status == RVF_YELLOW)
2119 {
2120 /* deallocate the memory */
2121 rvf_free_buf((T_RVF_BUFFER *)p_msg_start);
2122 rvf_free_buf((T_RVF_BUFFER *)p_data_buffer);
2123 audio_mode_error_trace(AUDIO_ENTITY_NO_MEMORY);
2124 return (AUDIO_ERROR);
2125 }
2126 else
2127 if (mb_status == RVF_RED)
2128 {
2129 rvf_free_buf((T_RVF_BUFFER *)p_msg_start);
2130 audio_mode_error_trace(AUDIO_ENTITY_NO_MEMORY);
2131 return (AUDIO_ERROR);
2132 }
2133
2134 /* fill the message parameters */
2135 p_msg_start->audio_parameter.data = p_data_buffer;
2136
2137 p_read = (INT8 *)(p_parameter->data);
2138 p_write = (INT8 *)p_data_buffer;
2139 for (i=0; i<size; i++)
2140 {
2141 *p_write++ = *p_read++;
2142 }
2143
2144 p_msg_start->audio_parameter.variable_indentifier = p_parameter->variable_indentifier;
2145
2146 /* fill the message id */
2147 p_msg_start->os_hdr.msg_id = AUDIO_MODE_WRITE_REQ;
2148
2149 /* fill the task source id */
2150 p_msg_start->os_hdr.src_addr_id = rvf_get_taskid();
2151 p_msg_start->os_hdr.dest_addr_id = p_audio_gbl_var->addrId;
2152
2153 if (return_path.callback_func == NULL)
2154 {
2155 p_msg_start->return_path.addr_id = return_path.addr_id;
2156 p_msg_start->return_path.callback_func = NULL;
2157 }
2158 else
2159 {
2160 p_msg_start->return_path.callback_func = return_path.callback_func;
2161 }
2162
2163 /* send the messsage to the audio entity */
2164 rvf_send_msg (p_audio_gbl_var->addrId,
2165 p_msg_start);
2166
2167 return (AUDIO_OK);
2168 /************************ Enf of audio_full_access_write function ***********************/
2169 }
2170
2171 /********************************************************************************/
2172 /* */
2173 /* Function Name: audio_full_access_read */
2174 /* */
2175 /* Purpose: This function is called to read the current audio mode. */
2176 /* */
2177 /* Input Parameters: */
2178 /* None. */
2179 /* */
2180 /* Output Parameters: */
2181 /* Status */
2182 /* Audio settings */
2183 /* */
2184 /* Note: */
2185 /* None. */
2186 /* */
2187 /* Revision History: */
2188 /* None. */
2189 /* */
2190 /********************************************************************************/
2191 T_AUDIO_RET audio_full_access_read (T_AUDIO_FULL_ACCESS_READ *p_parameter)
2192 {
2193 T_AUDIO_RET status = AUDIO_ERROR;
2194
2195 /************************ audio_full_access_write function begins ***********************/
2196
2197 if (p_audio_gbl_var == NULL )
2198 {
2199 audio_mode_error_trace(AUDIO_ENTITY_NOT_START);
2200 return(AUDIO_ERROR);
2201 }
2202
2203 switch (p_parameter->variable_indentifier)
2204 {
2205 case AUDIO_PATH_USED:
2206 {
2207 AUDIO_SEND_TRACE("AUDIO MODE FULL ACCESS READ: voice path", RV_TRACE_LEVEL_DEBUG_LOW);
2208 status = audio_mode_voice_path_read((T_AUDIO_VOICE_PATH_SETTING *)p_parameter->data);
2209 break;
2210 }
2211 case AUDIO_MICROPHONE_MODE:
2212 {
2213 AUDIO_SEND_TRACE("AUDIO MODE FULL ACCESS READ: microphone mode", RV_TRACE_LEVEL_DEBUG_LOW);
2214 status = audio_mode_microphone_mode_read((INT8 *)p_parameter->data);
2215 break;
2216 }
2217 case AUDIO_MICROPHONE_GAIN:
2218 {
2219 AUDIO_SEND_TRACE("AUDIO MODE FULL ACCESS READ: microphone gain", RV_TRACE_LEVEL_DEBUG_LOW);
2220 status = audio_mode_microphone_gain_read((INT8 *)p_parameter->data);
2221 break;
2222 }
2223 case AUDIO_MICROPHONE_EXTRA_GAIN:
2224 {
2225 AUDIO_SEND_TRACE("AUDIO MODE FULL ACCESS READ: microphone extra gain", RV_TRACE_LEVEL_DEBUG_LOW);
2226 status = audio_mode_microphone_extra_gain_read((INT8 *)p_parameter->data);
2227 break;
2228 }
2229 case AUDIO_MICROPHONE_OUTPUT_BIAS:
2230 {
2231 AUDIO_SEND_TRACE("AUDIO MODE FULL ACCESS READ: output bias", RV_TRACE_LEVEL_DEBUG_LOW);
2232 status = audio_mode_microphone_output_bias_read((INT8 *)p_parameter->data);
2233 break;
2234 }
2235 case AUDIO_MICROPHONE_FIR:
2236 {
2237 AUDIO_SEND_TRACE("AUDIO MODE FULL ACCESS READ: microphone FIR", RV_TRACE_LEVEL_DEBUG_LOW);
2238 status = audio_mode_microphone_fir_read((T_AUDIO_FIR_COEF *)p_parameter->data);
2239 break;
2240 }
2241 case AUDIO_SPEAKER_MODE:
2242 {
2243 AUDIO_SEND_TRACE("AUDIO MODE FULL ACCESS READ: speaker mode", RV_TRACE_LEVEL_DEBUG_LOW);
2244 status = audio_mode_speaker_mode_read((INT8 *)p_parameter->data);
2245 break;
2246 }
2247 case AUDIO_SPEAKER_GAIN:
2248 {
2249 AUDIO_SEND_TRACE("AUDIO MODE FULL ACCESS READ: speaker gain", RV_TRACE_LEVEL_DEBUG_LOW);
2250 status = audio_mode_speaker_gain_read((INT8 *)p_parameter->data);
2251 break;
2252 }
2253 case AUDIO_SPEAKER_FILTER:
2254 {
2255 AUDIO_SEND_TRACE("AUDIO MODE FULL ACCESS READ: speaker filter", RV_TRACE_LEVEL_DEBUG_LOW);
2256 status = audio_mode_speaker_filter_read((INT8 *)p_parameter->data);
2257 break;
2258 }
2259 case AUDIO_SPEAKER_FIR:
2260 {
2261 AUDIO_SEND_TRACE("AUDIO MODE FULL ACCESS READ: speaker_FIR", RV_TRACE_LEVEL_DEBUG_LOW);
2262 status = audio_mode_speaker_fir_read((T_AUDIO_FIR_COEF *)p_parameter->data);
2263 break;
2264 }
2265 case AUDIO_SPEAKER_BUZZER_STATE:
2266 {
2267 AUDIO_SEND_TRACE("AUDIO MODE FULL ACCESS READ: speaker buzzer", RV_TRACE_LEVEL_DEBUG_LOW);
2268 status = audio_mode_speaker_buzzer_read((INT8 *)p_parameter->data);
2269 break;
2270 }
2271 case AUDIO_MICROPHONE_SPEAKER_LOOP_SIDETONE:
2272 {
2273 AUDIO_SEND_TRACE("AUDIO MODE FULL ACCESS READ: sidetone gain", RV_TRACE_LEVEL_DEBUG_LOW);
2274 status = audio_mode_sidetone_gain_read((INT8 *)p_parameter->data);
2275 break;
2276 }
2277 case AUDIO_MICROPHONE_SPEAKER_LOOP_AEC:
2278 {
2279 AUDIO_SEND_TRACE("AUDIO MODE FULL ACCESS READ: AEC", RV_TRACE_LEVEL_DEBUG_LOW);
2280 status = audio_mode_aec_read((T_AUDIO_AEC_CFG *)p_parameter->data);
2281 break;
2282 }
2283 case AUDIO_SPEAKER_VOLUME_LEVEL:
2284 {
2285 AUDIO_SEND_TRACE("AUDIO MODE FULL ACCESS READ: volume", RV_TRACE_LEVEL_DEBUG_LOW);
2286 status = audio_mode_speaker_volume_read((T_AUDIO_SPEAKER_LEVEL *)p_parameter->data);
2287 break;
2288 }
2289 }
2290
2291 return(status);
2292
2293 /************************ Enf of audio_full_access_write function ***********************/
2294 }
2295
2296 /********************************************************************************/
2297 /* */
2298 /* Function Name: audio_mode_save */
2299 /* */
2300 /* Purpose: This function is called to save the current audio mode. */
2301 /* */
2302 /* Input Parameters: */
2303 /* audio mode file name. */
2304 /* */
2305 /* Output Parameters: */
2306 /* Status */
2307 /* */
2308 /* Note: */
2309 /* None. */
2310 /* */
2311 /* Revision History: */
2312 /* None. */
2313 /* */
2314 /********************************************************************************/
2315 T_AUDIO_RET audio_mode_save (T_AUDIO_MODE_SAVE *p_parameter, T_RV_RETURN return_path)
2316 {
2317 /************************ audio_full_access_write function begins ***********************/
2318 char audio_mode_path_name[AUDIO_PATH_NAME_MAX_SIZE];
2319 T_FFS_FD audio_mode_ffs_fd, audio_volume_ffs_fd;
2320 T_AUDIO_MODE_SAVE_REQ *p_msg_start;
2321 T_RVF_MB_STATUS mb_status = RVF_GREEN;
2322
2323 if (p_audio_gbl_var == NULL )
2324 {
2325 audio_mode_error_trace(AUDIO_ENTITY_NOT_START);
2326 return(AUDIO_ERROR);
2327 }
2328
2329 /* Create the audio mode path name */
2330 audio_mode_path_name[0] = 0;
2331 strcpy(audio_mode_path_name,"/aud/");
2332 strcpy(&(audio_mode_path_name[5]), p_parameter->audio_mode_filename);
2333 strcat(audio_mode_path_name,".cfg");
2334
2335 /* Open the FFS file */
2336 #ifndef _WINDOWS
2337 audio_mode_ffs_fd = ffs_open(audio_mode_path_name,
2338 FFS_O_CREATE | FFS_O_WRONLY | FFS_O_TRUNC | FFS_O_APPEND);
2339 if (audio_mode_ffs_fd <= 0)
2340 {
2341 audio_mode_error_trace(AUDIO_ENTITY_FILE_ERROR);
2342 return(AUDIO_ERROR);
2343 }
2344 #else
2345 audio_mode_ffs_fd = 0x00000110;
2346 #endif
2347
2348 /* Create the volume path name */
2349 audio_mode_path_name[5] = 0;
2350 strcpy(&(audio_mode_path_name[5]), p_parameter->audio_mode_filename);
2351 strcat(audio_mode_path_name,".vol");
2352
2353 /* Open the FFS file */
2354 #ifndef _WINDOWS
2355 audio_volume_ffs_fd = ffs_open(audio_mode_path_name,
2356 FFS_O_CREATE | FFS_O_WRONLY | FFS_O_TRUNC | FFS_O_APPEND);
2357 if (audio_volume_ffs_fd <= 0)
2358 {
2359 ffs_close(audio_mode_ffs_fd);
2360 audio_mode_error_trace(AUDIO_ENTITY_FILE_ERROR);
2361 return(AUDIO_ERROR);
2362 }
2363 #else
2364 audio_volume_ffs_fd = 0x00000111;
2365 #endif
2366
2367 /* allocate the memory for the message to send */
2368 mb_status = rvf_get_buf (p_audio_gbl_var->mb_external,
2369 sizeof (T_AUDIO_MODE_SAVE_REQ),
2370 (T_RVF_BUFFER **) (&p_msg_start));
2371
2372 /* If insufficient resources, then report a memory error and abort. */
2373 if (mb_status == RVF_YELLOW)
2374 {
2375 /* deallocate the memory */
2376 rvf_free_buf((T_RVF_BUFFER *)p_msg_start);
2377 audio_mode_error_trace(AUDIO_ENTITY_NO_MEMORY);
2378 return (AUDIO_ERROR);
2379 }
2380 else
2381 if (mb_status == RVF_RED)
2382 {
2383 audio_mode_error_trace(AUDIO_ENTITY_NO_MEMORY);
2384 return (AUDIO_ERROR);
2385 }
2386
2387 /* fill the message parameters */
2388 p_msg_start->audio_ffs_fd = audio_mode_ffs_fd;
2389 p_msg_start->audio_volume_ffs_fd = audio_volume_ffs_fd;
2390
2391 /* fill the message id */
2392 p_msg_start->os_hdr.msg_id = AUDIO_MODE_SAVE_REQ;
2393
2394 /* fill the task source id */
2395 p_msg_start->os_hdr.src_addr_id = rvf_get_taskid();
2396 p_msg_start->os_hdr.dest_addr_id = p_audio_gbl_var->addrId;
2397
2398 if (return_path.callback_func == NULL)
2399 {
2400 p_msg_start->return_path.addr_id = return_path.addr_id;
2401 p_msg_start->return_path.callback_func = NULL;
2402 }
2403 else
2404 {
2405 p_msg_start->return_path.callback_func = return_path.callback_func;
2406 }
2407
2408 /* send the messsage to the audio entity */
2409 rvf_send_msg (p_audio_gbl_var->addrId,
2410 p_msg_start);
2411
2412 return (AUDIO_OK);
2413 /************************ Enf of audio_full_access_write function ***********************/
2414 }
2415 /********************************************************************************/
2416 /* */
2417 /* Function Name: audio_mode_save */
2418 /* */
2419 /* Purpose: This function is called to load an audio mode. */
2420 /* */
2421 /* Input Parameters: */
2422 /* audio mode file name. */
2423 /* */
2424 /* Output Parameters: */
2425 /* Status */
2426 /* */
2427 /* Note: */
2428 /* None. */
2429 /* */
2430 /* Revision History: */
2431 /* None. */
2432 /* */
2433 /********************************************************************************/
2434 T_AUDIO_RET audio_mode_load (T_AUDIO_MODE_LOAD *p_parameter, T_RV_RETURN return_path)
2435 {
2436 /************************ audio_full_access_write function begins ***********************/
2437 char audio_path_name[AUDIO_PATH_NAME_MAX_SIZE];
2438 T_FFS_FD audio_mode_ffs_fd, audio_volume_ffs_fd;
2439 T_AUDIO_MODE_LOAD_REQ *p_msg_start;
2440 T_RVF_MB_STATUS mb_status = RVF_GREEN;
2441
2442 if (p_audio_gbl_var == NULL )
2443 {
2444 audio_mode_error_trace(AUDIO_ENTITY_NOT_START);
2445 return(AUDIO_ERROR);
2446 }
2447
2448 /* Create the audio mode path name */
2449 audio_path_name[0] = 0;
2450 strcpy(audio_path_name,"/aud/");
2451 strcpy(&(audio_path_name[5]), p_parameter->audio_mode_filename);
2452 strcat(audio_path_name,".cfg");
2453
2454 /* Open the FFS file */
2455 #ifndef _WINDOWS
2456 audio_mode_ffs_fd = ffs_open(audio_path_name,
2457 FFS_O_RDONLY);
2458 if (audio_mode_ffs_fd <= 0)
2459 {
2460 audio_mode_error_trace(AUDIO_ENTITY_FILE_ERROR);
2461 return(AUDIO_ERROR);
2462 }
2463 #else
2464 audio_mode_ffs_fd = 0x00001000;
2465 #endif
2466
2467 /* Create the volume path name */
2468 audio_path_name[5] = 0;
2469 strcpy(&(audio_path_name[5]), p_parameter->audio_mode_filename);
2470 strcat(audio_path_name,".vol");
2471
2472 /* Open the FFS file */
2473 #ifndef _WINDOWS
2474 audio_volume_ffs_fd = ffs_open(audio_path_name,
2475 FFS_O_RDONLY);
2476 if (audio_volume_ffs_fd <= 0)
2477 {
2478 ffs_close(audio_mode_ffs_fd);
2479 audio_mode_error_trace(AUDIO_ENTITY_FILE_ERROR);
2480 return(AUDIO_ERROR);
2481 }
2482 #else
2483 audio_volume_ffs_fd = 0x00001001;
2484 #endif
2485
2486 /* allocate the memory for the message to send */
2487 mb_status = rvf_get_buf (p_audio_gbl_var->mb_external,
2488 sizeof (T_AUDIO_MODE_LOAD_REQ),
2489 (T_RVF_BUFFER **) (&p_msg_start));
2490
2491 /* If insufficient resources, then report a memory error and abort. */
2492 if (mb_status == RVF_YELLOW)
2493 {
2494 /* deallocate the memory */
2495 rvf_free_buf((T_RVF_BUFFER *)p_msg_start);
2496 audio_mode_error_trace(AUDIO_ENTITY_NO_MEMORY);
2497 return (AUDIO_ERROR);
2498 }
2499 else
2500 if (mb_status == RVF_RED)
2501 {
2502 audio_mode_error_trace(AUDIO_ENTITY_NO_MEMORY);
2503 return (AUDIO_ERROR);
2504 }
2505
2506 /* fill the message parameters */
2507 p_msg_start->audio_ffs_fd = audio_mode_ffs_fd;
2508 p_msg_start->audio_volume_ffs_fd = audio_volume_ffs_fd;
2509 strcpy(p_msg_start->audio_volume_path_name , audio_path_name);
2510
2511 /* fill the message id */
2512 p_msg_start->os_hdr.msg_id = AUDIO_MODE_LOAD_REQ;
2513
2514 /* fill the task source id */
2515 p_msg_start->os_hdr.src_addr_id = rvf_get_taskid();
2516 p_msg_start->os_hdr.dest_addr_id = p_audio_gbl_var->addrId;
2517
2518 if (return_path.callback_func == NULL)
2519 {
2520 p_msg_start->return_path.addr_id = return_path.addr_id;
2521 p_msg_start->return_path.callback_func = NULL;
2522 }
2523 else
2524 {
2525 p_msg_start->return_path.callback_func = return_path.callback_func;
2526 }
2527
2528 /* send the messsage to the audio entity */
2529 rvf_send_msg (p_audio_gbl_var->addrId,
2530 p_msg_start);
2531
2532 return (AUDIO_OK);
2533 /************************ Enf of audio_full_access_write function ***********************/
2534 }
2535
2536 /********************************************************************************/
2537 /* */
2538 /* Function Name: audio_speaker_volume */
2539 /* */
2540 /* Purpose: This function is called to change the current speaker volume. */
2541 /* */
2542 /* Input Parameters: */
2543 /* speaker volume command. */
2544 /* */
2545 /* Output Parameters: */
2546 /* Status */
2547 /* */
2548 /* Note: */
2549 /* None. */
2550 /* */
2551 /* Revision History: */
2552 /* None. */
2553 /* */
2554 /********************************************************************************/
2555 T_AUDIO_RET audio_speaker_volume (T_AUDIO_SPEAKER_VOLUME volume, T_RV_RETURN return_path)
2556 {
2557 /************************ audio_speaker_volume function begins ***********************/
2558 T_AUDIO_SPEAKER_VOLUME_REQ *p_msg_start;
2559 T_RVF_MB_STATUS mb_status = RVF_GREEN;
2560
2561 if (p_audio_gbl_var == NULL )
2562 {
2563 audio_mode_error_trace(AUDIO_ENTITY_NOT_START);
2564 return(AUDIO_ERROR);
2565 }
2566
2567 /* Check if an audio mode is already loaded */
2568 if (p_audio_gbl_var->audio_mode_var.audio_volume_var.audio_volume_path_name[0] == 0)
2569 {
2570 audio_mode_error_trace(AUDIO_ENTITY_AUDIO_MODE_NO_LOADED);
2571 return (AUDIO_ERROR);
2572 }
2573
2574 /* Check parameters */
2575 if ( (volume.volume_action != AUDIO_SPEAKER_VOLUME_INCREASE) &&
2576 (volume.volume_action != AUDIO_SPEAKER_VOLUME_DECREASE) &&
2577 (volume.volume_action != AUDIO_SPEAKER_VOLUME_SET) )
2578 {
2579 audio_mode_error_trace(AUDIO_ENTITY_BAD_PARAMETER);
2580 return (AUDIO_ERROR);
2581 }
2582
2583 if ( (volume.value != AUDIO_SPEAKER_VOLUME_MUTE) &&
2584 (volume.value != AUDIO_SPEAKER_VOLUME_24dB) &&
2585 (volume.value != AUDIO_SPEAKER_VOLUME_18dB) &&
2586 (volume.value != AUDIO_SPEAKER_VOLUME_12dB) &&
2587 (volume.value != AUDIO_SPEAKER_VOLUME_6dB) &&
2588 (volume.value != AUDIO_SPEAKER_VOLUME_0dB) )
2589 {
2590 audio_mode_error_trace(AUDIO_ENTITY_BAD_PARAMETER);
2591 return (AUDIO_ERROR);
2592 }
2593
2594 /* allocate the memory for the message to send */
2595 mb_status = rvf_get_buf (p_audio_gbl_var->mb_external,
2596 sizeof (T_AUDIO_SPEAKER_VOLUME_REQ),
2597 (T_RVF_BUFFER **) (&p_msg_start));
2598
2599 /* If insufficient resources, then report a memory error and abort. */
2600 if (mb_status == RVF_YELLOW)
2601 {
2602 /* deallocate the memory */
2603 rvf_free_buf((T_RVF_BUFFER *)p_msg_start);
2604 audio_mode_error_trace(AUDIO_ENTITY_NO_MEMORY);
2605 return (AUDIO_ERROR);
2606 }
2607 else
2608 if (mb_status == RVF_RED)
2609 {
2610 audio_mode_error_trace(AUDIO_ENTITY_NO_MEMORY);
2611 return (AUDIO_ERROR);
2612 }
2613
2614 /* fill the message parameters */
2615 p_msg_start->volume.value = volume.value;
2616 p_msg_start->volume.volume_action = volume.volume_action;
2617
2618 /* fill the message id */
2619 p_msg_start->os_hdr.msg_id = AUDIO_SPEAKER_VOLUME_REQ;
2620
2621 /* fill the task source id */
2622 p_msg_start->os_hdr.src_addr_id = rvf_get_taskid();
2623 p_msg_start->os_hdr.dest_addr_id = p_audio_gbl_var->addrId;
2624
2625 if (return_path.callback_func == NULL)
2626 {
2627 p_msg_start->return_path.addr_id = return_path.addr_id;
2628 p_msg_start->return_path.callback_func = NULL;
2629 }
2630 else
2631 {
2632 p_msg_start->return_path.callback_func = return_path.callback_func;
2633 }
2634
2635 /* send the messsage to the audio entity */
2636 rvf_send_msg (p_audio_gbl_var->addrId,
2637 p_msg_start);
2638
2639 return (AUDIO_OK);
2640 /************************ Enf of audio_full_access_write function ***********************/
2641 }
2642
2643
2644 /********************************************************************************/
2645 /* */
2646 /* Function Name: audio_melody_E2_start */
2647 /* */
2648 /* Purpose: This function is called to initiate the melody E2 generation */
2649 /* */
2650 /* Input Parameters: */
2651 /* Audio Melody E2 Parameters, */
2652 /* Return path. */
2653 /* */
2654 /* Output Parameters: */
2655 /* Validation of the melody E2 parameters. */
2656 /* */
2657 /* Note: */
2658 /* None. */
2659 /* */
2660 /* Revision History: */
2661 /* None. */
2662 /* */
2663 /********************************************************************************/
2664 T_AUDIO_RET audio_melody_E2_start (T_AUDIO_MELODY_E2_PARAMETER *p_parameter,
2665 T_RV_RETURN return_path)
2666 {
2667 #if (MELODY_E2)
2668 /* Declare local variables. */
2669 T_RVF_MB_STATUS mb_status = RVF_GREEN;
2670 T_AUDIO_MELODY_E2_START *p_msg_start = NULL;
2671
2672 T_FFS_FD ffs_fd;
2673
2674 /************************ audio_melody_E2_start function begins ****************/
2675
2676 if (p_audio_gbl_var == NULL )
2677 {
2678 audio_melody_E2_error_trace(AUDIO_ENTITY_NOT_START);
2679 return(AUDIO_ERROR);
2680 }
2681
2682 /* check if the melody E2 file exist */
2683 #ifndef _WINDOWS
2684 ffs_fd = ffs_open(p_parameter->melody_E2_name, FFS_O_RDONLY);
2685 if (ffs_fd <= 0)
2686 {
2687 audio_melody_E2_error_trace(AUDIO_ENTITY_FILE_ERROR);
2688 return (AUDIO_ERROR);
2689 }
2690 #else
2691 ffs_fd = 0x00001010;
2692 #endif
2693
2694 /* allocate the memory for the message to send */
2695 mb_status = rvf_get_buf (p_audio_gbl_var->mb_external,
2696 sizeof (T_AUDIO_MELODY_E2_START),
2697 (T_RVF_BUFFER **) (&p_msg_start));
2698
2699 /* If insufficient resources, then report a memory error and abort.*/
2700 if (mb_status == RVF_YELLOW)
2701 {
2702 /* deallocate the memory */
2703 rvf_free_buf((T_RVF_BUFFER *)p_msg_start);
2704 audio_melody_E2_error_trace(AUDIO_ENTITY_NO_MEMORY);
2705
2706 /* close the file previously open */
2707 #ifndef _WINDOWS
2708 ffs_close(ffs_fd);
2709 #endif
2710 return (AUDIO_ERROR);
2711 }
2712 else
2713 if (mb_status == RVF_RED)
2714 {
2715 audio_melody_E2_error_trace(AUDIO_ENTITY_NO_MEMORY);
2716 /* close the file previously open */
2717 #ifndef _WINDOWS
2718 ffs_close(ffs_fd);
2719 #endif
2720 return (AUDIO_ERROR);
2721 }
2722
2723 /* fill the message id */
2724 p_msg_start->os_hdr.msg_id = AUDIO_MELODY_E2_START_REQ;
2725
2726 /* fill the address source id */
2727 p_msg_start->os_hdr.src_addr_id = rvf_get_taskid();
2728 p_msg_start->os_hdr.dest_addr_id = p_audio_gbl_var->addrId;
2729
2730 /* fill the message parameters */
2731 /* the ffs_fd */
2732 p_msg_start->audio_E2_ffs_fd = ffs_fd;
2733
2734 /* the name */
2735 strcpy(p_msg_start->melody_E2_parameter.melody_E2_name,
2736 p_parameter->melody_E2_name);
2737
2738 /* the loopback */
2739 if ( (p_parameter->E2_loopback == AUDIO_MELODY_NO_LOOPBACK) ||
2740 (p_parameter->E2_loopback == AUDIO_MELODY_LOOPBACK) )
2741 {
2742 p_msg_start->melody_E2_parameter.E2_loopback = p_parameter->E2_loopback;
2743 }
2744 else
2745 {
2746 /* Wrong parameter */
2747 audio_melody_E2_error_trace(AUDIO_ENTITY_BAD_PARAMETER);
2748 /* deallocate the memory */
2749 rvf_free_buf((T_RVF_BUFFER *)p_msg_start);
2750 /* close the file previously open */
2751 #ifndef _WINDOWS
2752 ffs_close(ffs_fd);
2753 #endif
2754 return (AUDIO_ERROR);
2755 }
2756
2757 /* the melody mode */
2758 if ( (p_parameter->melody_E2_mode == AUDIO_MELODY_GAME_MODE) ||
2759 (p_parameter->melody_E2_mode == AUDIO_MELODY_NORMAL_MODE) )
2760 {
2761 p_msg_start->melody_E2_parameter.melody_E2_mode = p_parameter->melody_E2_mode;
2762 }
2763 else
2764 {
2765 /* Wrong parameter */
2766 audio_melody_E2_error_trace(AUDIO_ENTITY_BAD_PARAMETER);
2767 /* deallocate the memory */
2768 rvf_free_buf((T_RVF_BUFFER *)p_msg_start);
2769 /* close the file previously open */
2770 #ifndef _WINDOWS
2771 ffs_close(ffs_fd);
2772 #endif
2773 return (AUDIO_ERROR);
2774 }
2775
2776 if (return_path.callback_func == NULL)
2777 {
2778 p_msg_start->return_path.addr_id = return_path.addr_id;
2779 p_msg_start->return_path.callback_func = NULL;
2780 }
2781
2782 else
2783 {
2784 p_msg_start->return_path.callback_func = return_path.callback_func;
2785 }
2786
2787 /* send the messsage to the audio entity */
2788 rvf_send_msg (p_audio_gbl_var->addrId,
2789 p_msg_start);
2790
2791 return (AUDIO_OK);
2792 #else
2793 AUDIO_SEND_TRACE("Melody E2 not compiled", RV_TRACE_LEVEL_ERROR);
2794 return (AUDIO_ERROR);
2795 #endif
2796 } /*********************** End of audio_melody_E2_Start function ****************/
2797
2798 /********************************************************************************/
2799 /* */
2800 /* Function Name: audio_melody_E2_stop */
2801 /* */
2802 /* Purpose: This function is called to stop a melody_E2 generation */
2803 /* */
2804 /* Input Parameters: */
2805 /* Audio Melody E2 Parameters, */
2806 /* Return path. */
2807 /* */
2808 /* Output Parameters: */
2809 /* Validation of the melody E2 parameters. */
2810 /* */
2811 /* Note: */
2812 /* None. */
2813 /* */
2814 /* Revision History: */
2815 /* None. */
2816 /* */
2817 /********************************************************************************/
2818 T_AUDIO_RET audio_melody_E2_stop (T_AUDIO_MELODY_E2_STOP_PARAMETER *p_parameter,
2819 T_RV_RETURN return_path)
2820 {
2821 #if (MELODY_E2)
2822 /* Declare local variables. */
2823 T_RVF_MB_STATUS mb_status = RVF_GREEN;
2824 T_AUDIO_MELODY_E2_STOP *p_msg = NULL;
2825
2826 /********************** audio_melody_E2_stop function begins ****************/
2827
2828 if (p_audio_gbl_var == NULL )
2829 {
2830 audio_melody_E2_error_trace(AUDIO_ENTITY_NOT_START);
2831 return(AUDIO_ERROR);
2832 }
2833
2834 /* allocate the memory for the message to send */
2835 mb_status = rvf_get_buf (p_audio_gbl_var->mb_external,
2836 sizeof (T_AUDIO_MELODY_E2_STOP),
2837 (T_RVF_BUFFER **) (&p_msg));
2838
2839 /* If insufficient resources, then report a memory error and abort */
2840 if (mb_status == RVF_YELLOW)
2841 {
2842 /* deallocate the memory */
2843 rvf_free_buf((T_RVF_BUFFER *)p_msg);
2844 audio_melody_E2_error_trace(AUDIO_ENTITY_NO_MEMORY);
2845 return (AUDIO_ERROR);
2846 }
2847 else
2848 if (mb_status == RVF_RED)
2849 {
2850 audio_melody_E2_error_trace(AUDIO_ENTITY_NO_MEMORY);
2851 return (AUDIO_ERROR);
2852 }
2853
2854 /* fill the message id */
2855 p_msg->os_hdr.msg_id = AUDIO_MELODY_E2_STOP_REQ;
2856
2857 /* fill the address source id */
2858 p_msg->os_hdr.src_addr_id = rvf_get_taskid();
2859 p_msg->os_hdr.dest_addr_id = p_audio_gbl_var->addrId;
2860
2861
2862 /* fill the message parameters */
2863 /* the name */
2864 strcpy(p_msg->melody_E2_name,
2865 p_parameter->melody_E2_name);
2866
2867 /* the return path */
2868 if (return_path.callback_func == NULL)
2869 {
2870 p_msg->return_path.addr_id = return_path.addr_id;
2871 p_msg->return_path.callback_func = NULL;
2872 }
2873 else
2874 {
2875 p_msg->return_path.callback_func = return_path.callback_func;
2876 }
2877
2878 /* send the messsage to the audio entity */
2879 rvf_send_msg (p_audio_gbl_var->addrId,
2880 p_msg);
2881
2882 return (AUDIO_OK);
2883
2884 #else
2885 AUDIO_SEND_TRACE("Melody E2 not compiled", RV_TRACE_LEVEL_ERROR);
2886 return (AUDIO_ERROR);
2887 #endif
2888 } /*********************** End of audio_melody_E2_Stop function *****************/
2889
2890 /********************************************************************************/
2891 /* */
2892 /* Function Name: audio_melody_E2_load_file_instruments */
2893 /* */
2894 /* Purpose: This function is called in order to load the instruments file */
2895 /* used in the melody E2 format (.lsi file) */
2896 /* */
2897 /* Input Parameters: */
2898 /* File name of the melody. */
2899 /* */
2900 /* Output Parameters: */
2901 /* Validation of the melody E2 load file instruments parameters. */
2902 /* */
2903 /* Note: */
2904 /* None. */
2905 /* */
2906 /* Revision History: */
2907 /* None. */
2908 /* */
2909 /********************************************************************************/
2910 T_AUDIO_RET audio_melody_E2_load_file_instruments (
2911 T_AUDIO_MELODY_E2_LOAD_FILE_INSTR_PARAMETER *p_parameter)
2912 {
2913 #if (MELODY_E2)
2914 /**** Declare local variables ****/
2915 #ifndef _WINDOWS
2916 /* FFS File descriptor type */
2917 T_FFS_FD ffs_fd_1, ffs_fd_2;
2918 T_FFS_STAT stat;
2919 T_FFS_SIZE size = 0;
2920
2921 INT8 i;
2922
2923 /* basic structure of the .lsi file */
2924 T_AUDIO_MELODY_E2_ID_NAME file_E2;
2925 #endif
2926 /* Nb of instruments in the .lsi file */
2927 INT8 nb_of_instruments = 0;
2928
2929
2930 /*************** audio_melody_E2_load_file_instruments function begins ********/
2931
2932 if (p_audio_gbl_var == NULL )
2933 {
2934 audio_melody_E2_error_trace(AUDIO_ENTITY_NOT_START);
2935 return(AUDIO_ERROR);
2936 }
2937
2938 /* Before to start the file download, check if the melody is OFF */
2939 if ((p_audio_gbl_var->melody_E2_0.state != AUDIO_MELODY_E2_IDLE ) &&
2940 (p_audio_gbl_var->melody_E2_1.state != AUDIO_MELODY_E2_IDLE ))
2941 {
2942 /* The instrument file can't be downloaded */
2943 audio_melody_E2_error_trace (AUDIO_ERROR_DOWNLOAD);
2944 return (AUDIO_ERROR);
2945 }
2946
2947 /**** Find the size of the .lsi file ****/
2948 /* the .lsi file is stores into the flash */
2949 /* check if the .lsi file exists */
2950 #ifndef _WINDOWS
2951
2952 ffs_fd_1 = ffs_open(p_parameter->melody_E2_file_name, FFS_O_RDONLY );
2953
2954 if (ffs_fd_1 < EFFS_OK)
2955 {
2956 audio_melody_E2_error_trace(AUDIO_ENTITY_LOAD_FILE_INSTR_ERROR);
2957 return (AUDIO_ERROR);
2958 }
2959
2960 ffs_stat(p_parameter->melody_E2_file_name,&stat);
2961
2962
2963 /* check if the file contains some data */
2964 if (stat.size ==0)
2965 {
2966 /* the file doesn't contains data */
2967 /* an error is generated */
2968 audio_melody_E2_error_trace(AUDIO_ENTITY_FILE_ERROR);
2969 return(AUDIO_ERROR);
2970 }
2971
2972 /* the file exists and contains data */
2973 /* Nb of instruments in the file */
2974 nb_of_instruments = stat.size / (sizeof(T_AUDIO_MELODY_E2_ID_NAME));
2975
2976
2977 /**** check if the melody E2 load instruments files (.mwa file) exist ****/
2978 /* open the .mwa file */
2979 for (i=0;i< nb_of_instruments;i++)
2980 {
2981 /* Load the instruments file from the FFS */
2982 if (ffs_read ( ffs_fd_1,
2983 (&file_E2),
2984 (sizeof(INT8) + AUDIO_PATH_NAME_MAX_SIZE)) < EFFS_OK )
2985 {
2986 AUDIO_SEND_TRACE("AUDIO MELODY E2: impossible to load the .lsi file", RV_TRACE_LEVEL_ERROR);
2987
2988 /* Close the file */
2989 ffs_close(ffs_fd_1);
2990
2991 return (AUDIO_ERROR);
2992 }
2993
2994 ffs_fd_2 = ffs_open( file_E2.melody_name,
2995 FFS_O_RDONLY );
2996
2997 if (ffs_fd_2 < EFFS_OK)
2998 {
2999 AUDIO_SEND_TRACE("AUDIO MELODY E2: impossible to open the .mwa file instruments", RV_TRACE_LEVEL_ERROR);
3000
3001 /* Close the .mwa file */
3002 ffs_close(ffs_fd_1);
3003 ffs_close(ffs_fd_2);
3004
3005 return (AUDIO_ERROR);
3006 }
3007
3008 /* Close the file */
3009 ffs_close(ffs_fd_2);
3010 }
3011 ffs_close(ffs_fd_1);
3012 #endif
3013
3014 /* Copy the new .lsi name */
3015 strcpy (p_audio_gbl_var->melody_E2_load_file_instruments.instrument_file_name,
3016 p_parameter->melody_E2_file_name);
3017
3018 /* Copy the number of instrument listed by this .lsi file */
3019 p_audio_gbl_var->melody_E2_load_file_instruments.nb_of_instruments
3020 = nb_of_instruments;
3021
3022 p_audio_gbl_var->melody_E2_load_file_instruments.file_downloaded = TRUE;
3023
3024 return (AUDIO_OK);
3025
3026 #else
3027 AUDIO_SEND_TRACE("Melody E2 not compiled", RV_TRACE_LEVEL_ERROR);
3028 return (AUDIO_ERROR);
3029 #endif
3030 } /*************** End of audio_melody_E2_load_file_instrument function **************/
3031
3032
3033 /********************************************************************************/
3034 /* */
3035 /* Function Name: audio_amr_record_to_ffs_start/stop */
3036 /* */
3037 /* Purpose: This function is called in order to start/stop the recording of */
3038 /* a AMR-MMS in Flash */
3039 /* */
3040 /* Input Parameters: */
3041 /* Record parameters */
3042 /* Return_path */
3043 /* */
3044 /* Output Parameters: */
3045 /* Validation of the parameters. */
3046 /* */
3047 /* Note: */
3048 /* None. */
3049 /* */
3050 /* Revision History: */
3051 /* None. */
3052 /* */
3053 /********************************************************************************/
3054 T_AUDIO_RET audio_amr_record_to_ffs_start (T_AUDIO_AMR_RECORD_TO_FFS_PARAMETER *p_record_parameter,
3055 T_RV_RETURN return_path)
3056 {
3057 #if (AUDIO_NEW_FFS_MANAGER)&&(L1_VOICE_MEMO_AMR)
3058 /* Declare local variables. */
3059 T_AUDIO_VM_AMR_RECORD_TO_FFS_START *p_msg_start = NULL;
3060 T_RVF_MB_STATUS mb_status = RVF_GREEN;
3061 T_FFS_FD ffs_fd;
3062
3063 /************************ audio_amr_record_to_ffs_start function begins **************/
3064 if (p_audio_gbl_var == NULL )
3065 {
3066 audio_voice_memo_amr_error_trace(AUDIO_ENTITY_NOT_START);
3067 return(AUDIO_ERROR);
3068 }
3069
3070 /* check if the voice memo record file already exists */
3071 ffs_fd = ffs_open(p_record_parameter->memo_name,
3072 FFS_O_CREATE | FFS_O_WRONLY | FFS_O_TRUNC | FFS_O_APPEND);
3073 if ( ffs_fd <= 0)
3074 {
3075 audio_voice_memo_amr_error_trace(AUDIO_ENTITY_FILE_ERROR);
3076 return (AUDIO_ERROR);
3077 }
3078
3079 /* check parameters */
3080 if ( ((p_record_parameter->compression_mode != AUDIO_AMR_NO_COMPRESSION_MODE ) &&
3081 (p_record_parameter->compression_mode != AUDIO_AMR_COMPRESSION_MODE ))||
3082 ((p_record_parameter->amr_vocoder != AUDIO_AMR_VOCODER_4_75) &&
3083 (p_record_parameter->amr_vocoder != AUDIO_AMR_VOCODER_5_15) &&
3084 (p_record_parameter->amr_vocoder != AUDIO_AMR_VOCODER_5_90) &&
3085 (p_record_parameter->amr_vocoder != AUDIO_AMR_VOCODER_6_70) &&
3086 (p_record_parameter->amr_vocoder != AUDIO_AMR_VOCODER_7_40) &&
3087 (p_record_parameter->amr_vocoder != AUDIO_AMR_VOCODER_7_95) &&
3088 (p_record_parameter->amr_vocoder != AUDIO_AMR_VOCODER_10_2) &&
3089 (p_record_parameter->amr_vocoder != AUDIO_AMR_VOCODER_12_2))
3090 )
3091 {
3092 audio_voice_memo_amr_error_trace(AUDIO_ENTITY_BAD_PARAMETER);
3093 ffs_close(ffs_fd);
3094 return (AUDIO_ERROR);
3095 }
3096
3097 /* allocate the memory for the message to send */
3098 mb_status = rvf_get_buf (p_audio_gbl_var->mb_external,
3099 sizeof (T_AUDIO_VM_AMR_RECORD_TO_FFS_START),
3100 (T_RVF_BUFFER **) (&p_msg_start));
3101
3102 /* If insufficient resources, then report a memory error and abort. */
3103 if (mb_status == RVF_YELLOW)
3104 {
3105 /* deallocate the memory */
3106 rvf_free_buf((T_RVF_BUFFER *)p_msg_start);
3107 audio_voice_memo_amr_error_trace(AUDIO_ENTITY_NO_MEMORY);
3108 ffs_close(ffs_fd);
3109 return (AUDIO_ERROR);
3110 }
3111 else if (mb_status == RVF_RED)
3112 {
3113 audio_voice_memo_amr_error_trace(AUDIO_ENTITY_NO_MEMORY);
3114 ffs_close(ffs_fd);
3115 return (AUDIO_ERROR);
3116 }
3117
3118 /* fill the message id */
3119 p_msg_start->os_hdr.msg_id = AUDIO_VM_AMR_RECORD_TO_FFS_START_REQ;
3120
3121 /* fill the address source id */
3122 p_msg_start->os_hdr.src_addr_id = rvf_get_taskid();
3123 p_msg_start->os_hdr.dest_addr_id = p_audio_gbl_var->addrId;
3124
3125 /* fill the message parameters */
3126 p_msg_start->audio_ffs_fd = ffs_fd;
3127 p_msg_start->compression_mode = p_record_parameter->compression_mode;
3128 p_msg_start->memo_duration = p_record_parameter->memo_duration;
3129 p_msg_start->microphone_gain = p_record_parameter->microphone_gain;
3130 p_msg_start->amr_vocoder = p_record_parameter->amr_vocoder;
3131
3132 if (return_path.callback_func == NULL)
3133 {
3134 p_msg_start->return_path.addr_id = return_path.addr_id;
3135 p_msg_start->return_path.callback_func = NULL;
3136 }
3137 else
3138 {
3139 p_msg_start->return_path.callback_func = return_path.callback_func;
3140 }
3141
3142 /* send the messsage to the audio entity */
3143 rvf_send_msg (p_audio_gbl_var->addrId, p_msg_start);
3144
3145 return (AUDIO_OK);
3146 #else // (AUDIO_NEW_FFS_MANAGER)&&(L1_VOICE_MEMO_AMR)
3147 AUDIO_SEND_TRACE("Voice Memo AMR not compiled", RV_TRACE_LEVEL_DEBUG_LOW);
3148 return (AUDIO_ERROR);
3149 #endif // (AUDIO_NEW_FFS_MANAGER)&&(L1_VOICE_MEMO_AMR)
3150 } /*********************** End of audio_amr_record_to_ffs_start function ****************/
3151
3152 T_AUDIO_RET audio_amr_record_to_ffs_stop (void)
3153 {
3154 #if (AUDIO_NEW_FFS_MANAGER)&&(L1_VOICE_MEMO_AMR)
3155 /* Declare local variables. */
3156 T_AUDIO_VM_AMR_RECORD_STOP *p_msg_stop = NULL;
3157 T_RVF_MB_STATUS mb_status = RVF_GREEN;
3158
3159 /************************ audio_amr_record_to_ffs_stop function begins **************/
3160 if (p_audio_gbl_var == NULL )
3161 {
3162 audio_voice_memo_amr_error_trace(AUDIO_ENTITY_NOT_START);
3163 return(AUDIO_ERROR);
3164 }
3165
3166 /* allocate the memory for the message to send */
3167 mb_status = rvf_get_buf (p_audio_gbl_var->mb_external,
3168 sizeof (T_AUDIO_VM_AMR_RECORD_STOP),
3169 (T_RVF_BUFFER **) (&p_msg_stop));
3170
3171 /* If insufficient resources, then report a memory error and abort. */
3172 if (mb_status == RVF_YELLOW)
3173 {
3174 /* deallocate the memory */
3175 rvf_free_buf((T_RVF_BUFFER *)p_msg_stop);
3176 audio_voice_memo_amr_error_trace(AUDIO_ENTITY_NO_MEMORY);
3177 return (AUDIO_ERROR);
3178 }
3179 else if (mb_status == RVF_RED)
3180 {
3181 audio_voice_memo_amr_error_trace(AUDIO_ENTITY_NO_MEMORY);
3182 return (AUDIO_ERROR);
3183 }
3184
3185 /* fill the message id */
3186 p_msg_stop->os_hdr.msg_id = AUDIO_VM_AMR_RECORD_TO_FFS_STOP_REQ;
3187
3188 /* fill the address source id */
3189 p_msg_stop->os_hdr.src_addr_id = rvf_get_taskid();
3190 p_msg_stop->os_hdr.dest_addr_id = p_audio_gbl_var->addrId;
3191
3192 /* send the messsage to the audio entity */
3193 rvf_send_msg (p_audio_gbl_var->addrId, p_msg_stop);
3194
3195 return (AUDIO_OK);
3196 #else // (AUDIO_NEW_FFS_MANAGER)&&(L1_VOICE_MEMO_AMR)
3197 AUDIO_SEND_TRACE("Voice Memo AMR not compiled", RV_TRACE_LEVEL_DEBUG_LOW);
3198 return (AUDIO_ERROR);
3199 #endif // (AUDIO_NEW_FFS_MANAGER)&&(L1_VOICE_MEMO_AMR)
3200 } /*********************** End of audio_amr_record_to_ffs_stop function ****************/
3201
3202 /********************************************************************************/
3203 /* */
3204 /* Function Name: audio_mms_record_to_ffs_start/stop */
3205 /* */
3206 /* Purpose: This function is called in order to start/stop the recording of */
3207 /* a AMR-MMS in Flash (MMS header added) */
3208 /* */
3209 /* Input Parameters: */
3210 /* Record parameters */
3211 /* Return_path */
3212 /* */
3213 /* Output Parameters: */
3214 /* Validation of the parameters. */
3215 /* */
3216 /* Note: */
3217 /* None. */
3218 /* */
3219 /* Revision History: */
3220 /* None. */
3221 /* */
3222 /********************************************************************************/
3223 T_AUDIO_RET audio_mms_record_to_ffs_start (T_AUDIO_MMS_RECORD_TO_FFS_PARAMETER *p_record_parameter,
3224 T_RV_RETURN return_path)
3225 {
3226 #if (AUDIO_NEW_FFS_MANAGER)&&(L1_VOICE_MEMO_AMR)
3227 /* Declare local variables. */
3228 T_AUDIO_VM_AMR_RECORD_TO_FFS_START *p_msg_start = NULL;
3229 T_RVF_MB_STATUS mb_status = RVF_GREEN;
3230 T_FFS_FD ffs_fd;
3231 UINT8 temp[6] = "#!AMR\n";
3232
3233 /************************ audio_amr_record_to_ffs_start function begins **************/
3234 if (p_audio_gbl_var == NULL )
3235 {
3236 audio_voice_memo_amr_error_trace(AUDIO_ENTITY_NOT_START);
3237 return(AUDIO_ERROR);
3238 }
3239
3240 /* check if the voice memo record file already exists */
3241 ffs_fd = ffs_open(p_record_parameter->memo_name,
3242 FFS_O_CREATE | FFS_O_WRONLY | FFS_O_TRUNC | FFS_O_APPEND);
3243 if ( ffs_fd <= 0)
3244 {
3245 audio_voice_memo_amr_error_trace(AUDIO_ENTITY_FILE_ERROR);
3246 return (AUDIO_ERROR);
3247 }
3248
3249 /* check parameters */
3250 if ( ((p_record_parameter->compression_mode != AUDIO_AMR_NO_COMPRESSION_MODE ) &&
3251 (p_record_parameter->compression_mode != AUDIO_AMR_COMPRESSION_MODE ))||
3252 ((p_record_parameter->amr_vocoder != AUDIO_AMR_VOCODER_4_75) &&
3253 (p_record_parameter->amr_vocoder != AUDIO_AMR_VOCODER_5_15) &&
3254 (p_record_parameter->amr_vocoder != AUDIO_AMR_VOCODER_5_90) &&
3255 (p_record_parameter->amr_vocoder != AUDIO_AMR_VOCODER_6_70) &&
3256 (p_record_parameter->amr_vocoder != AUDIO_AMR_VOCODER_7_40) &&
3257 (p_record_parameter->amr_vocoder != AUDIO_AMR_VOCODER_7_95) &&
3258 (p_record_parameter->amr_vocoder != AUDIO_AMR_VOCODER_10_2) &&
3259 (p_record_parameter->amr_vocoder != AUDIO_AMR_VOCODER_12_2))
3260 )
3261 {
3262 audio_voice_memo_amr_error_trace(AUDIO_ENTITY_BAD_PARAMETER);
3263 ffs_close(ffs_fd);
3264 return (AUDIO_ERROR);
3265 }
3266
3267 /* allocate the memory for the message to send */
3268 mb_status = rvf_get_buf (p_audio_gbl_var->mb_external,
3269 sizeof (T_AUDIO_VM_AMR_RECORD_TO_FFS_START),
3270 (T_RVF_BUFFER **) (&p_msg_start));
3271
3272 /* If insufficient resources, then report a memory error and abort. */
3273 if (mb_status == RVF_YELLOW)
3274 {
3275 /* deallocate the memory */
3276 rvf_free_buf((T_RVF_BUFFER *)p_msg_start);
3277 audio_voice_memo_amr_error_trace(AUDIO_ENTITY_NO_MEMORY);
3278 ffs_close(ffs_fd);
3279 return (AUDIO_ERROR);
3280 }
3281 else if (mb_status == RVF_RED)
3282 {
3283 audio_voice_memo_amr_error_trace(AUDIO_ENTITY_NO_MEMORY);
3284 ffs_close(ffs_fd);
3285 return (AUDIO_ERROR);
3286 }
3287
3288 /* fill the message id */
3289 p_msg_start->os_hdr.msg_id = AUDIO_VM_AMR_RECORD_TO_FFS_START_REQ;
3290
3291 /* fill the address source id */
3292 p_msg_start->os_hdr.src_addr_id = rvf_get_taskid();
3293 p_msg_start->os_hdr.dest_addr_id = p_audio_gbl_var->addrId;
3294
3295 /* fill the message parameters */
3296 p_msg_start->audio_ffs_fd = ffs_fd;
3297 p_msg_start->compression_mode = p_record_parameter->compression_mode;
3298 p_msg_start->memo_duration = p_record_parameter->memo_duration;
3299 p_msg_start->microphone_gain = p_record_parameter->microphone_gain;
3300 p_msg_start->amr_vocoder = p_record_parameter->amr_vocoder;
3301
3302 // write magix string #!AMR\n
3303 ffs_write(ffs_fd, temp, 6);
3304
3305 if (return_path.callback_func == NULL)
3306 {
3307 p_msg_start->return_path.addr_id = return_path.addr_id;
3308 p_msg_start->return_path.callback_func = NULL;
3309 }
3310 else
3311 {
3312 p_msg_start->return_path.callback_func = return_path.callback_func;
3313 }
3314
3315 /* send the messsage to the audio entity */
3316 rvf_send_msg (p_audio_gbl_var->addrId, p_msg_start);
3317
3318 return (AUDIO_OK);
3319 #else // (AUDIO_NEW_FFS_MANAGER)&&(L1_VOICE_MEMO_AMR)
3320 AUDIO_SEND_TRACE("Voice Memo AMR not compiled", RV_TRACE_LEVEL_DEBUG_LOW);
3321 return (AUDIO_ERROR);
3322 #endif // (AUDIO_NEW_FFS_MANAGER)&&(L1_VOICE_MEMO_AMR)
3323 } /*********************** End of audio_mms_record_to_ffs_start function ****************/
3324
3325 T_AUDIO_RET audio_mms_record_to_ffs_stop (void)
3326 {
3327 return audio_amr_record_to_ffs_stop();
3328 } /*********************** End of audio_mms_record_to_ffs_stop function ****************/
3329
3330 /********************************************************************************/
3331 /* */
3332 /* Function Name: audio_amr_play_from_ffs_start/stop */
3333 /* */
3334 /* Purpose: This function is called in order to start/stop the playing of */
3335 /* a AMR-MMS from Flash */
3336 /* */
3337 /* Input Parameters: */
3338 /* Play parameters */
3339 /* Return_path */
3340 /* */
3341 /* Output Parameters: */
3342 /* Validation of the parameters. */
3343 /* */
3344 /* Note: */
3345 /* None. */
3346 /* */
3347 /* Revision History: */
3348 /* None. */
3349 /* */
3350 /********************************************************************************/
3351 T_AUDIO_RET audio_amr_play_from_ffs_start (T_AUDIO_AMR_PLAY_FROM_FFS_PARAMETER *p_play_parameter,
3352 T_RV_RETURN return_path)
3353 {
3354 #if (AUDIO_NEW_FFS_MANAGER)&&(L1_VOICE_MEMO_AMR)
3355 /* Declare local variables. */
3356 T_AUDIO_VM_AMR_PLAY_FROM_FFS_START *p_msg_start = NULL;
3357 T_RVF_MB_STATUS mb_status = RVF_GREEN;
3358 T_FFS_FD ffs_fd;
3359
3360 /************************ audio_amr_play_from_ffs_start function begins **************/
3361
3362 if (p_audio_gbl_var == NULL )
3363 {
3364 audio_voice_memo_amr_error_trace(AUDIO_ENTITY_NOT_START);
3365 return(AUDIO_ERROR);
3366 }
3367
3368 /* check if the voice memo play file already exists */
3369 ffs_fd = ffs_open(p_play_parameter->memo_name, FFS_O_RDONLY);
3370 if ( ffs_fd <= 0)
3371 {
3372 audio_voice_memo_amr_error_trace(AUDIO_ENTITY_FILE_ERROR);
3373 return (AUDIO_ERROR);
3374 }
3375
3376 /* allocate the memory for the message to send */
3377 mb_status = rvf_get_buf (p_audio_gbl_var->mb_external,
3378 sizeof (T_AUDIO_VM_AMR_PLAY_FROM_FFS_START),
3379 (T_RVF_BUFFER **) (&p_msg_start));
3380
3381 /* If insufficient resources, then report a memory error and abort. */
3382 if (mb_status == RVF_YELLOW)
3383 {
3384 /* deallocate the memory */
3385 rvf_free_buf((T_RVF_BUFFER *)p_msg_start);
3386 audio_voice_memo_amr_error_trace(AUDIO_ENTITY_NO_MEMORY);
3387 ffs_close(ffs_fd);
3388 return (AUDIO_ERROR);
3389 }
3390 else if (mb_status == RVF_RED)
3391 {
3392 audio_voice_memo_amr_error_trace(AUDIO_ENTITY_NO_MEMORY);
3393 ffs_close(ffs_fd);
3394 return (AUDIO_ERROR);
3395 }
3396
3397 /* fill the message id */
3398 p_msg_start->os_hdr.msg_id = AUDIO_VM_AMR_PLAY_FROM_FFS_START_REQ;
3399
3400 /* fill the address source id */
3401 p_msg_start->os_hdr.src_addr_id = rvf_get_taskid();
3402 p_msg_start->os_hdr.dest_addr_id = p_audio_gbl_var->addrId;
3403
3404 /* fill the message parameters */
3405 p_msg_start->audio_ffs_fd = ffs_fd;
3406
3407 if (return_path.callback_func == NULL)
3408 {
3409 p_msg_start->return_path.addr_id = return_path.addr_id;
3410 p_msg_start->return_path.callback_func = NULL;
3411 }
3412 else
3413 {
3414 p_msg_start->return_path.callback_func = return_path.callback_func;
3415 }
3416
3417 /* send the messsage to the audio entity */
3418 rvf_send_msg (p_audio_gbl_var->addrId, p_msg_start);
3419
3420 return (AUDIO_OK);
3421 #else // (AUDIO_NEW_FFS_MANAGER)&&(L1_VOICE_MEMO_AMR)
3422 AUDIO_SEND_TRACE("Voice Memo AMR not compiled", RV_TRACE_LEVEL_DEBUG_LOW);
3423 return (AUDIO_ERROR);
3424 #endif // (AUDIO_NEW_FFS_MANAGER)&&(L1_VOICE_MEMO_AMR)
3425 } /*********************** End of audio_amr_play_from_ffs_start function ****************/
3426
3427 T_AUDIO_RET audio_amr_play_from_ffs_stop (void)
3428 {
3429 #if (AUDIO_NEW_FFS_MANAGER)&&(L1_VOICE_MEMO_AMR)
3430 /* Declare local variables. */
3431 T_AUDIO_VM_AMR_PLAY_STOP *p_msg_stop = NULL;
3432 T_RVF_MB_STATUS mb_status = RVF_GREEN;
3433
3434 /************************ audio_amr_play_from_ffs_stop function begins **************/
3435 if (p_audio_gbl_var == NULL )
3436 {
3437 audio_voice_memo_amr_error_trace(AUDIO_ENTITY_NOT_START);
3438 return(AUDIO_ERROR);
3439 }
3440
3441 /* allocate the memory for the message to send */
3442 mb_status = rvf_get_buf (p_audio_gbl_var->mb_external,
3443 sizeof (T_AUDIO_VM_AMR_PLAY_STOP),
3444 (T_RVF_BUFFER **) (&p_msg_stop));
3445
3446 /* If insufficient resources, then report a memory error and abort. */
3447 if (mb_status == RVF_YELLOW)
3448 {
3449 /* deallocate the memory */
3450 rvf_free_buf((T_RVF_BUFFER *)p_msg_stop);
3451 audio_voice_memo_amr_error_trace(AUDIO_ENTITY_NO_MEMORY);
3452 return (AUDIO_ERROR);
3453 }
3454 else if (mb_status == RVF_RED)
3455 {
3456 audio_voice_memo_amr_error_trace(AUDIO_ENTITY_NO_MEMORY);
3457 return (AUDIO_ERROR);
3458 }
3459
3460 /* fill the message id */
3461 p_msg_stop->os_hdr.msg_id = AUDIO_VM_AMR_PLAY_FROM_FFS_STOP_REQ;
3462
3463 /* fill the address source id */
3464 p_msg_stop->os_hdr.src_addr_id = rvf_get_taskid();
3465 p_msg_stop->os_hdr.dest_addr_id = p_audio_gbl_var->addrId;
3466
3467 /* send the messsage to the audio entity */
3468 rvf_send_msg (p_audio_gbl_var->addrId, p_msg_stop);
3469
3470 return (AUDIO_OK);
3471 #else // (AUDIO_NEW_FFS_MANAGER)&&(L1_VOICE_MEMO_AMR)
3472 AUDIO_SEND_TRACE("Voice Memo AMR not compiled", RV_TRACE_LEVEL_DEBUG_LOW);
3473 return (AUDIO_ERROR);
3474 #endif // (AUDIO_NEW_FFS_MANAGER)&&(L1_VOICE_MEMO_AMR)
3475 } /*********************** End of audio_amr_play_from_ffs_stop function ****************/
3476
3477 /********************************************************************************/
3478 /* */
3479 /* Function Name: audio_mms_play_from_ffs_start/stop */
3480 /* */
3481 /* Purpose: This function is called in order to start/stop the playing of */
3482 /* a AMR-MMS from Flash (MMS header handled) */
3483 /* */
3484 /* Input Parameters: */
3485 /* Play parameters */
3486 /* Return_path */
3487 /* */
3488 /* Output Parameters: */
3489 /* Validation of the parameters. */
3490 /* */
3491 /* Note: */
3492 /* None. */
3493 /* */
3494 /* Revision History: */
3495 /* None. */
3496 /* */
3497 /********************************************************************************/
3498 T_AUDIO_RET audio_mms_play_from_ffs_start (T_AUDIO_MMS_PLAY_FROM_FFS_PARAMETER *p_play_parameter,
3499 T_RV_RETURN return_path)
3500 {
3501 #if (AUDIO_NEW_FFS_MANAGER)&&(L1_VOICE_MEMO_AMR)
3502 /* Declare local variables. */
3503 T_AUDIO_VM_AMR_PLAY_FROM_FFS_START *p_msg_start = NULL;
3504 T_RVF_MB_STATUS mb_status = RVF_GREEN;
3505 T_FFS_FD ffs_fd;
3506 UINT8 temp[6];
3507
3508 /************************ audio_amr_play_from_ffs_start function begins **************/
3509
3510 if (p_audio_gbl_var == NULL )
3511 {
3512 audio_voice_memo_amr_error_trace(AUDIO_ENTITY_NOT_START);
3513 return(AUDIO_ERROR);
3514 }
3515
3516 /* check if the voice memo play file already exists */
3517 ffs_fd = ffs_open(p_play_parameter->memo_name, FFS_O_RDONLY);
3518 if ( ffs_fd <= 0)
3519 {
3520 audio_voice_memo_amr_error_trace(AUDIO_ENTITY_FILE_ERROR);
3521 return (AUDIO_ERROR);
3522 }
3523 // read magic string #!AMR\n
3524 ffs_read(ffs_fd, temp, 6);
3525
3526 /* allocate the memory for the message to send */
3527 mb_status = rvf_get_buf (p_audio_gbl_var->mb_external,
3528 sizeof (T_AUDIO_VM_AMR_PLAY_FROM_FFS_START),
3529 (T_RVF_BUFFER **) (&p_msg_start));
3530
3531 /* If insufficient resources, then report a memory error and abort. */
3532 if (mb_status == RVF_YELLOW)
3533 {
3534 /* deallocate the memory */
3535 rvf_free_buf((T_RVF_BUFFER *)p_msg_start);
3536 audio_voice_memo_amr_error_trace(AUDIO_ENTITY_NO_MEMORY);
3537 ffs_close(ffs_fd);
3538 return (AUDIO_ERROR);
3539 }
3540 else if (mb_status == RVF_RED)
3541 {
3542 audio_voice_memo_amr_error_trace(AUDIO_ENTITY_NO_MEMORY);
3543 ffs_close(ffs_fd);
3544 return (AUDIO_ERROR);
3545 }
3546
3547 /* fill the message id */
3548 p_msg_start->os_hdr.msg_id = AUDIO_VM_AMR_PLAY_FROM_FFS_START_REQ;
3549
3550 /* fill the address source id */
3551 p_msg_start->os_hdr.src_addr_id = rvf_get_taskid();
3552 p_msg_start->os_hdr.dest_addr_id = p_audio_gbl_var->addrId;
3553
3554 /* fill the message parameters */
3555 p_msg_start->audio_ffs_fd = ffs_fd;
3556
3557 if (return_path.callback_func == NULL)
3558 {
3559 p_msg_start->return_path.addr_id = return_path.addr_id;
3560 p_msg_start->return_path.callback_func = NULL;
3561 }
3562 else
3563 {
3564 p_msg_start->return_path.callback_func = return_path.callback_func;
3565 }
3566
3567 /* send the messsage to the audio entity */
3568 rvf_send_msg (p_audio_gbl_var->addrId, p_msg_start);
3569
3570 return (AUDIO_OK);
3571 #else // (AUDIO_NEW_FFS_MANAGER)&&(L1_VOICE_MEMO_AMR)
3572 AUDIO_SEND_TRACE("Voice Memo AMR not compiled", RV_TRACE_LEVEL_DEBUG_LOW);
3573 return (AUDIO_ERROR);
3574 #endif // (AUDIO_NEW_FFS_MANAGER)&&(L1_VOICE_MEMO_AMR)
3575 } /*********************** End of audio_mms_play_from_ffs_start function ****************/
3576
3577 T_AUDIO_RET audio_mms_play_from_ffs_stop (void)
3578 {
3579 return audio_amr_play_from_ffs_stop();
3580 }
3581
3582 /********************************************************************************/
3583 /* */
3584 /* Function Name: audio_amr_record_to_ram_start/stop */
3585 /* */
3586 /* Purpose: This function is called in order to record a MMS */
3587 /* in RAM */
3588 /* */
3589 /* Input Parameters: */
3590 /* Record Parameters */
3591 /* Return_path */
3592 /* */
3593 /* Output Parameters: */
3594 /* Validation of the parameters. */
3595 /* */
3596 /* Note: */
3597 /* None. */
3598 /* */
3599 /* Revision History: */
3600 /* None. */
3601 /* */
3602 /********************************************************************************/
3603 T_AUDIO_RET audio_amr_record_to_ram_start (T_AUDIO_AMR_RECORD_TO_RAM_PARAMETER *p_record_parameter,
3604 T_RV_RETURN return_path)
3605 {
3606 #if (AUDIO_RAM_MANAGER)&&(L1_VOICE_MEMO_AMR)
3607 /* Declare local variables. */
3608 T_AUDIO_VM_AMR_RECORD_TO_RAM_START *p_msg_start = NULL;
3609 T_RVF_MB_STATUS mb_status = RVF_GREEN;
3610
3611 /************************ audio_amr_record_to_ram_start function begins **************/
3612
3613 if (p_audio_gbl_var == NULL )
3614 {
3615 audio_voice_memo_amr_error_trace(AUDIO_ENTITY_NOT_START);
3616 return(AUDIO_ERROR);
3617 }
3618
3619 if ( (p_record_parameter->p_buffer == NULL) ||
3620 ((p_record_parameter->compression_mode != AUDIO_AMR_NO_COMPRESSION_MODE ) &&
3621 (p_record_parameter->compression_mode != AUDIO_AMR_COMPRESSION_MODE ))||
3622 ((p_record_parameter->amr_vocoder != AUDIO_AMR_VOCODER_4_75) &&
3623 (p_record_parameter->amr_vocoder != AUDIO_AMR_VOCODER_5_15) &&
3624 (p_record_parameter->amr_vocoder != AUDIO_AMR_VOCODER_5_90) &&
3625 (p_record_parameter->amr_vocoder != AUDIO_AMR_VOCODER_6_70) &&
3626 (p_record_parameter->amr_vocoder != AUDIO_AMR_VOCODER_7_40) &&
3627 (p_record_parameter->amr_vocoder != AUDIO_AMR_VOCODER_7_95) &&
3628 (p_record_parameter->amr_vocoder != AUDIO_AMR_VOCODER_10_2) &&
3629 (p_record_parameter->amr_vocoder != AUDIO_AMR_VOCODER_12_2))
3630 )
3631 {
3632 audio_voice_memo_amr_error_trace(AUDIO_ENTITY_BAD_PARAMETER);
3633 return (AUDIO_ERROR);
3634 }
3635
3636 /* allocate the memory for the message to send */
3637 mb_status = rvf_get_buf (p_audio_gbl_var->mb_external,
3638 sizeof (T_AUDIO_VM_AMR_RECORD_TO_RAM_START),
3639 (T_RVF_BUFFER **) (&p_msg_start));
3640
3641 /* If insufficient resources, then report a memory error and abort. */
3642 if (mb_status == RVF_YELLOW)
3643 {
3644 /* deallocate the memory */
3645 rvf_free_buf((T_RVF_BUFFER *)p_msg_start);
3646 audio_voice_memo_amr_error_trace(AUDIO_ENTITY_NO_MEMORY);
3647 return (AUDIO_ERROR);
3648 }
3649 else if (mb_status == RVF_RED)
3650 {
3651 audio_voice_memo_amr_error_trace(AUDIO_ENTITY_NO_MEMORY);
3652 return (AUDIO_ERROR);
3653 }
3654
3655 /* fill the message id */
3656 p_msg_start->os_hdr.msg_id = AUDIO_VM_AMR_RECORD_TO_RAM_START_REQ;
3657
3658 /* fill the address source id */
3659 p_msg_start->os_hdr.src_addr_id = rvf_get_taskid();
3660 p_msg_start->os_hdr.dest_addr_id = p_audio_gbl_var->addrId;
3661
3662 /* fill the message parameters */
3663 p_msg_start->p_buffer = p_record_parameter->p_buffer;
3664 p_msg_start->compression_mode = p_record_parameter->compression_mode;
3665 p_msg_start->memo_duration = p_record_parameter->memo_duration;
3666 p_msg_start->microphone_gain = p_record_parameter->microphone_gain;
3667 p_msg_start->amr_vocoder = p_record_parameter->amr_vocoder;
3668
3669 if (return_path.callback_func == NULL)
3670 {
3671 p_msg_start->return_path.addr_id = return_path.addr_id;
3672 p_msg_start->return_path.callback_func = NULL;
3673 }
3674 else
3675 {
3676 p_msg_start->return_path.callback_func = return_path.callback_func;
3677 }
3678
3679 /* send the messsage to the audio entity */
3680 rvf_send_msg (p_audio_gbl_var->addrId, p_msg_start);
3681
3682 return (AUDIO_OK);
3683 #else // (AUDIO_RAM_MANAGER)&&(L1_VOICE_MEMO_AMR)
3684 AUDIO_SEND_TRACE("Voice Memo AMR not compiled", RV_TRACE_LEVEL_DEBUG_LOW);
3685 return (AUDIO_ERROR);
3686 #endif // (AUDIO_RAM_MANAGER)&&(L1_VOICE_MEMO_AMR)
3687 } /*********************** End of audio_amr_record_to_ram_start function ****************/
3688
3689 T_AUDIO_RET audio_amr_record_to_ram_stop (void)
3690 {
3691 #if (AUDIO_RAM_MANAGER)&&(L1_VOICE_MEMO_AMR)
3692 /* Declare local variables. */
3693 T_AUDIO_VM_AMR_RECORD_STOP *p_msg_stop = NULL;
3694 T_RVF_MB_STATUS mb_status = RVF_GREEN;
3695
3696 /************************ audio_amr_record_to_ram_stop function begins **************/
3697
3698 if (p_audio_gbl_var == NULL )
3699 {
3700 audio_voice_memo_amr_error_trace(AUDIO_ENTITY_NOT_START);
3701 return(AUDIO_ERROR);
3702 }
3703
3704 /* allocate the memory for the message to send */
3705 mb_status = rvf_get_buf (p_audio_gbl_var->mb_external,
3706 sizeof (T_AUDIO_VM_AMR_RECORD_STOP),
3707 (T_RVF_BUFFER **) (&p_msg_stop));
3708
3709 /* If insufficient resources, then report a memory error and abort. */
3710 if (mb_status == RVF_YELLOW)
3711 {
3712 /* deallocate the memory */
3713 rvf_free_buf((T_RVF_BUFFER *)p_msg_stop);
3714 audio_voice_memo_amr_error_trace(AUDIO_ENTITY_NO_MEMORY);
3715 return (AUDIO_ERROR);
3716 }
3717 else if (mb_status == RVF_RED)
3718 {
3719 audio_voice_memo_amr_error_trace(AUDIO_ENTITY_NO_MEMORY);
3720 return (AUDIO_ERROR);
3721 }
3722
3723 /* fill the message id */
3724 p_msg_stop->os_hdr.msg_id = AUDIO_VM_AMR_RECORD_TO_RAM_STOP_REQ;
3725
3726 /* fill the address source id */
3727 p_msg_stop->os_hdr.src_addr_id = rvf_get_taskid();
3728 p_msg_stop->os_hdr.dest_addr_id = p_audio_gbl_var->addrId;
3729
3730 /* send the messsage to the audio entity */
3731 rvf_send_msg (p_audio_gbl_var->addrId, p_msg_stop);
3732
3733 return (AUDIO_OK);
3734 #else // (AUDIO_RAM_MANAGER)&&(L1_VOICE_MEMO_AMR)
3735 AUDIO_SEND_TRACE("Voice Memo AMR not compiled", RV_TRACE_LEVEL_DEBUG_LOW);
3736 return (AUDIO_ERROR);
3737 #endif // (AUDIO_RAM_MANAGER)&&(L1_VOICE_MEMO_AMR)
3738 } /*********************** End of audio_amr_record_to_ram_stop function ****************/
3739
3740 T_AUDIO_RET audio_amr_play_from_ram_start (T_AUDIO_AMR_PLAY_FROM_RAM_PARAMETER *p_play_parameter,
3741 T_RV_RETURN return_path)
3742 {
3743 #if (AUDIO_RAM_MANAGER)&&(L1_VOICE_MEMO_AMR)
3744 /* Declare local variables. */
3745 T_AUDIO_VM_AMR_PLAY_FROM_RAM_START *p_msg_start = NULL;
3746 T_RVF_MB_STATUS mb_status = RVF_GREEN;
3747
3748 /************************ audio_amr_play_from_ram_start function begins **************/
3749 if (p_audio_gbl_var == NULL )
3750 {
3751 audio_voice_memo_amr_error_trace(AUDIO_ENTITY_NOT_START);
3752 return(AUDIO_ERROR);
3753 }
3754
3755 /* check parameters */
3756 if (p_play_parameter->p_buffer == NULL)
3757 {
3758 audio_voice_memo_amr_error_trace(AUDIO_ENTITY_BAD_PARAMETER);
3759 return (AUDIO_ERROR);
3760 }
3761
3762 /* allocate the memory for the message to send */
3763 mb_status = rvf_get_buf (p_audio_gbl_var->mb_external,
3764 sizeof (T_AUDIO_VM_AMR_PLAY_FROM_RAM_START),
3765 (T_RVF_BUFFER **) (&p_msg_start));
3766
3767 /* If insufficient resources, then report a memory error and abort. */
3768 if (mb_status == RVF_YELLOW)
3769 {
3770 /* deallocate the memory */
3771 rvf_free_buf((T_RVF_BUFFER *)p_msg_start);
3772 audio_voice_memo_amr_error_trace(AUDIO_ENTITY_NO_MEMORY);
3773 return (AUDIO_ERROR);
3774 }
3775 else if (mb_status == RVF_RED)
3776 {
3777 audio_voice_memo_amr_error_trace(AUDIO_ENTITY_NO_MEMORY);
3778 return (AUDIO_ERROR);
3779 }
3780
3781 /* fill the message id */
3782 p_msg_start->os_hdr.msg_id = AUDIO_VM_AMR_PLAY_FROM_RAM_START_REQ;
3783
3784 /* fill the address source id */
3785 p_msg_start->os_hdr.src_addr_id = rvf_get_taskid();
3786 p_msg_start->os_hdr.dest_addr_id = p_audio_gbl_var->addrId;
3787
3788 /* fill the message parameters */
3789 p_msg_start->p_buffer = p_play_parameter->p_buffer;
3790 p_msg_start->buffer_size = p_play_parameter->buffer_size;
3791
3792 if (return_path.callback_func == NULL)
3793 {
3794 p_msg_start->return_path.addr_id = return_path.addr_id;
3795 p_msg_start->return_path.callback_func = NULL;
3796 }
3797 else
3798 {
3799 p_msg_start->return_path.callback_func = return_path.callback_func;
3800 }
3801
3802 /* send the messsage to the audio entity */
3803 rvf_send_msg (p_audio_gbl_var->addrId, p_msg_start);
3804
3805 return (AUDIO_OK);
3806 #else // (AUDIO_RAM_MANAGER)&&(L1_VOICE_MEMO_AMR)
3807 AUDIO_SEND_TRACE("Voice Memo AMR not compiled", RV_TRACE_LEVEL_DEBUG_LOW);
3808 return (AUDIO_ERROR);
3809 #endif // (AUDIO_RAM_MANAGER)&&(L1_VOICE_MEMO_AMR)
3810 } /*********************** End of audio_amr_play_from_ram_start function ****************/
3811
3812 T_AUDIO_RET audio_amr_play_from_ram_stop (void)
3813 {
3814 #if (AUDIO_RAM_MANAGER)&&(L1_VOICE_MEMO_AMR)
3815 /* Declare local variables. */
3816 T_AUDIO_VM_AMR_PLAY_STOP *p_msg_stop = NULL;
3817 T_RVF_MB_STATUS mb_status = RVF_GREEN;
3818
3819 /************************ audio_amr_play_from_ram_stop function begins **************/
3820 if (p_audio_gbl_var == NULL )
3821 {
3822 audio_voice_memo_amr_error_trace(AUDIO_ENTITY_NOT_START);
3823 return(AUDIO_ERROR);
3824 }
3825
3826 /* allocate the memory for the message to send */
3827 mb_status = rvf_get_buf (p_audio_gbl_var->mb_external,
3828 sizeof (T_AUDIO_VM_AMR_PLAY_STOP),
3829 (T_RVF_BUFFER **) (&p_msg_stop));
3830
3831 /* If insufficient resources, then report a memory error and abort. */
3832 if (mb_status == RVF_YELLOW)
3833 {
3834 /* deallocate the memory */
3835 rvf_free_buf((T_RVF_BUFFER *)p_msg_stop);
3836 audio_voice_memo_amr_error_trace(AUDIO_ENTITY_NO_MEMORY);
3837 return (AUDIO_ERROR);
3838 }
3839 else if (mb_status == RVF_RED)
3840 {
3841 audio_voice_memo_amr_error_trace(AUDIO_ENTITY_NO_MEMORY);
3842 return (AUDIO_ERROR);
3843 }
3844
3845 /* fill the message id */
3846 p_msg_stop->os_hdr.msg_id = AUDIO_VM_AMR_PLAY_FROM_RAM_STOP_REQ;
3847
3848 /* fill the address source id */
3849 p_msg_stop->os_hdr.src_addr_id = rvf_get_taskid();
3850 p_msg_stop->os_hdr.dest_addr_id = p_audio_gbl_var->addrId;
3851
3852 /* send the messsage to the audio entity */
3853 rvf_send_msg (p_audio_gbl_var->addrId, p_msg_stop);
3854
3855 return (AUDIO_OK);
3856 #else // (AUDIO_RAM_MANAGER)&&(L1_VOICE_MEMO_AMR)
3857 AUDIO_SEND_TRACE("Voice Memo AMR not compiled", RV_TRACE_LEVEL_DEBUG_LOW);
3858 return (AUDIO_ERROR);
3859 #endif // (AUDIO_RAM_MANAGER)&&(L1_VOICE_MEMO_AMR)
3860 } /*********************** End of audio_amr_play_from_ram_stop function ****************/
3861
3862 /********************************************************************************/
3863 /* */
3864 /* Function Name: audio_driver_init_vm_amr_record_session */
3865 /* */
3866 /* Purpose: This function is called in order to initialize VM AMR record */
3867 /* */
3868 /* Input Parameters: */
3869 /* Specific VM AMR record parameters */
3870 /* Driver parameters */
3871 /* Return path */
3872 /* */
3873 /* Output Parameters: */
3874 /* Validation of the parameters */
3875 /* */
3876 /* Note: */
3877 /* None. */
3878 /* */
3879 /* Revision History: */
3880 /* None. */
3881 /* */
3882 /********************************************************************************/
3883 T_AUDIO_RET audio_driver_init_vm_amr_record_session(T_AUDIO_DRIVER_VM_AMR_RECORD_PARAMETER *p_record_parameter,
3884 T_AUDIO_DRIVER_PARAMETER *p_driver_parameter,
3885 T_RV_RETURN return_path)
3886 {
3887 #if (L1_VOICE_MEMO_AMR)
3888 /* Declare local variables. */
3889 T_RVF_MB_STATUS mb_status = RVF_GREEN;
3890 T_AUDIO_DRIVER_INIT_VM_AMR_RECORD_SESSION *p_msg = NULL;
3891
3892 /************************ function begins ****************/
3893
3894 /* check entity started */
3895 if (p_audio_gbl_var == NULL )
3896 {
3897 audio_driver_error_trace(AUDIO_ENTITY_NOT_START);
3898 return(AUDIO_ERROR);
3899 }
3900
3901 /* If bad voice memo record parameters, then report an error and abort.*/
3902 if ( ((p_record_parameter->compression_mode != AUDIO_AMR_NO_COMPRESSION_MODE ) &&
3903 (p_record_parameter->compression_mode != AUDIO_AMR_COMPRESSION_MODE ))||
3904 ((p_record_parameter->amr_vocoder != AUDIO_AMR_VOCODER_4_75) &&
3905 (p_record_parameter->amr_vocoder != AUDIO_AMR_VOCODER_5_15) &&
3906 (p_record_parameter->amr_vocoder != AUDIO_AMR_VOCODER_5_90) &&
3907 (p_record_parameter->amr_vocoder != AUDIO_AMR_VOCODER_6_70) &&
3908 (p_record_parameter->amr_vocoder != AUDIO_AMR_VOCODER_7_40) &&
3909 (p_record_parameter->amr_vocoder != AUDIO_AMR_VOCODER_7_95) &&
3910 (p_record_parameter->amr_vocoder != AUDIO_AMR_VOCODER_10_2) &&
3911 (p_record_parameter->amr_vocoder != AUDIO_AMR_VOCODER_12_2))||
3912 (p_driver_parameter->buffer_size < AUDIO_VM_AMR_MAX_SAMPLE_SIZE_16BIT)||
3913 ((p_driver_parameter->nb_buffer < 2)||
3914 (p_driver_parameter->nb_buffer > AUDIO_DRIVER_MAX_BUFFER_PER_SESSION))
3915 )
3916 {
3917 audio_driver_error_trace(AUDIO_ENTITY_BAD_PARAMETER);
3918 return (AUDIO_ERROR);
3919 }
3920
3921 /* allocate the memory for the message to send */
3922 mb_status = rvf_get_buf (p_audio_gbl_var->mb_internal,
3923 sizeof (T_AUDIO_DRIVER_INIT_VM_AMR_RECORD_SESSION),
3924 (T_RVF_BUFFER **) (&p_msg));
3925
3926 /* If insufficient resources, then report a memory error and abort. */
3927 if (mb_status == RVF_YELLOW)
3928 {
3929 /* deallocate the memory */
3930 rvf_free_buf((T_RVF_BUFFER *)p_msg);
3931 audio_driver_error_trace(AUDIO_ENTITY_NO_MEMORY);
3932 return (AUDIO_ERROR);
3933 }
3934 else
3935 if (mb_status == RVF_RED)
3936 {
3937 audio_driver_error_trace(AUDIO_ENTITY_NO_MEMORY);
3938 return (AUDIO_ERROR);
3939 }
3940
3941 /* fill message id */
3942 p_msg->os_hdr.msg_id = AUDIO_DRIVER_INIT_VM_AMR_RECORD_SESSION;
3943 p_msg->os_hdr.dest_addr_id = p_audio_gbl_var->addrId;
3944
3945 /* fill the message parameters */
3946 p_msg->compression_mode = p_record_parameter->compression_mode;
3947 p_msg->memo_duration = p_record_parameter->memo_duration;
3948 p_msg->microphone_gain = p_record_parameter->microphone_gain;
3949 p_msg->amr_vocoder = p_record_parameter->amr_vocoder;
3950
3951 /* fill parameters */
3952 p_msg->driver_parameter.buffer_size = p_driver_parameter->buffer_size;
3953 p_msg->driver_parameter.nb_buffer = p_driver_parameter->nb_buffer;
3954
3955 if (return_path.callback_func == NULL)
3956 {
3957 p_msg->return_path.addr_id = return_path.addr_id;
3958 p_msg->return_path.callback_func = NULL;
3959 }
3960 else
3961 p_msg->return_path.callback_func = return_path.callback_func;
3962
3963 /* send the messsage to the audio entity */
3964 rvf_send_msg (p_audio_gbl_var->addrId, p_msg);
3965
3966 return (AUDIO_OK);
3967 #else // L1_VOICE_MEMO_AMR
3968 AUDIO_SEND_TRACE("Voice Memo AMR not compiled", RV_TRACE_LEVEL_DEBUG_LOW);
3969 return (AUDIO_ERROR);
3970 #endif // L1_VOICE_MEMO_AMR
3971 }
3972
3973 /********************************************************************************/
3974 /* */
3975 /* Function Name: audio_driver_init_vm_amr_play_session */
3976 /* */
3977 /* Purpose: This function is called in order to initialize VM AMR play */
3978 /* */
3979 /* Input Parameters: */
3980 /* Specific VM AMR play parameters */
3981 /* Driver parameters */
3982 /* Return path */
3983 /* */
3984 /* Output Parameters: */
3985 /* Validation of the parameters */
3986 /* */
3987 /* Note: */
3988 /* None. */
3989 /* */
3990 /* Revision History: */
3991 /* None. */
3992 /* */
3993 /********************************************************************************/
3994 T_AUDIO_RET audio_driver_init_vm_amr_play_session(T_AUDIO_DRIVER_PARAMETER *p_driver_parameter, T_RV_RETURN return_path)
3995 {
3996 #if (L1_VOICE_MEMO_AMR)
3997 /* Declare local variables. */
3998 T_RVF_MB_STATUS mb_status = RVF_GREEN;
3999 T_AUDIO_DRIVER_INIT_VM_AMR_PLAY_SESSION *p_msg = NULL;
4000
4001 /************************ audio_keybeep_stop function begins ****************/
4002
4003 if (p_audio_gbl_var == NULL )
4004 {
4005 audio_driver_error_trace(AUDIO_ENTITY_NOT_START);
4006 return(AUDIO_ERROR);
4007 }
4008
4009 /* If bad voice memo record parameters, then report an error and abort.*/
4010 if ( (p_driver_parameter->buffer_size < AUDIO_VM_AMR_MAX_SAMPLE_SIZE_16BIT)||
4011 ((p_driver_parameter->nb_buffer < 2)||
4012 (p_driver_parameter->nb_buffer > AUDIO_DRIVER_MAX_BUFFER_PER_SESSION))
4013 )
4014 {
4015 audio_driver_error_trace(AUDIO_ENTITY_BAD_PARAMETER);
4016 return (AUDIO_ERROR);
4017 }
4018
4019 /* allocate the memory for the message to send */
4020 mb_status = rvf_get_buf (p_audio_gbl_var->mb_internal,
4021 sizeof (T_AUDIO_DRIVER_INIT_VM_AMR_PLAY_SESSION),
4022 (T_RVF_BUFFER **) (&p_msg));
4023
4024 /* If insufficient resources, then report a memory error and abort. */
4025 if (mb_status == RVF_YELLOW)
4026 {
4027 /* deallocate the memory */
4028 rvf_free_buf((T_RVF_BUFFER *)p_msg);
4029 audio_driver_error_trace(AUDIO_ENTITY_NO_MEMORY);
4030 return (AUDIO_ERROR);
4031 }
4032 else
4033 if (mb_status == RVF_RED)
4034 {
4035 audio_driver_error_trace(AUDIO_ENTITY_NO_MEMORY);
4036 return (AUDIO_ERROR);
4037 }
4038
4039 /* fill the message id */
4040 p_msg->os_hdr.msg_id = AUDIO_DRIVER_INIT_VM_AMR_PLAY_SESSION;
4041 p_msg->os_hdr.dest_addr_id = p_audio_gbl_var->addrId;
4042
4043 /* fill parameters */
4044 p_msg->driver_parameter.buffer_size = p_driver_parameter->buffer_size;
4045 p_msg->driver_parameter.nb_buffer = p_driver_parameter->nb_buffer;
4046
4047 if (return_path.callback_func == NULL)
4048 {
4049 p_msg->return_path.addr_id = return_path.addr_id;
4050 p_msg->return_path.callback_func = NULL;
4051 }
4052 else
4053 p_msg->return_path.callback_func = return_path.callback_func;
4054
4055 /* send the messsage to the audio entity */
4056 rvf_send_msg (p_audio_gbl_var->addrId, p_msg);
4057
4058 return (AUDIO_OK);
4059 #else // L1_VOICE_MEMO_AMR
4060 AUDIO_SEND_TRACE("Voice Memo AMR not compiled", RV_TRACE_LEVEL_DEBUG_LOW);
4061 return (AUDIO_ERROR);
4062 #endif // L1_VOICE_MEMO_AMR
4063 }
4064
4065 /********************************************************************************/
4066 /* */
4067 /* Function Name: audio_driver_..._session */
4068 /* */
4069 /* Purpose: This function is called in order to start/stop/free session */
4070 /* */
4071 /* Input Parameters: */
4072 /* channel identifier */
4073 /* Return path */
4074 /* */
4075 /* Output Parameters: */
4076 /* Validation of the parameters */
4077 /* */
4078 /* Note: */
4079 /* None. */
4080 /* */
4081 /* Revision History: */
4082 /* None. */
4083 /* */
4084 /********************************************************************************/
4085 T_AUDIO_RET audio_driver_start_session(UINT8 channel_id, T_RV_RETURN notification_return_path)
4086 {
4087 return audio_driver_handle_session(AUDIO_DRIVER_START_SESSION, channel_id, notification_return_path);
4088 }
4089
4090 T_AUDIO_RET audio_driver_stop_session(UINT8 channel_id)
4091 {
4092 T_RV_RETURN return_path;
4093
4094 return_path.callback_func = NULL;
4095 return_path.addr_id = 0;
4096
4097 return audio_driver_handle_session(AUDIO_DRIVER_STOP_SESSION, channel_id, return_path);
4098 }
4099
4100 T_AUDIO_RET audio_driver_free_session(UINT8 channel_id, T_RV_RETURN return_path)
4101 {
4102 return audio_driver_handle_session(AUDIO_DRIVER_FREE_SESSION, channel_id, return_path);
4103 }
4104
4105 T_AUDIO_RET audio_driver_handle_session(UINT32 msg_id, UINT8 channel_id, T_RV_RETURN return_path)
4106 {
4107 #if (L1_AUDIO_DRIVER)
4108 /* Declare local variables. */
4109 T_RVF_MB_STATUS mb_status = RVF_GREEN;
4110 T_AUDIO_DRIVER_HANDLE_SESSION *p_msg = NULL;
4111
4112 /************************ audio_driver_handle_session function begins ****************/
4113
4114 if (p_audio_gbl_var == NULL )
4115 {
4116 audio_driver_error_trace(AUDIO_ENTITY_NOT_START);
4117 return(AUDIO_ERROR);
4118 }
4119
4120 /* If bad voice memo record parameters, then report an error and abort.*/
4121 if (channel_id >= AUDIO_DRIVER_MAX_CHANNEL)
4122 {
4123 audio_driver_error_trace(AUDIO_ENTITY_BAD_PARAMETER);
4124 return (AUDIO_ERROR);
4125 }
4126
4127 /* allocate the memory for the message to send */
4128 mb_status = rvf_get_buf (p_audio_gbl_var->mb_external,
4129 sizeof (T_AUDIO_DRIVER_HANDLE_SESSION),
4130 (T_RVF_BUFFER **) (&p_msg));
4131
4132 /* If insufficient resources, then report a memory error and abort. */
4133 if (mb_status == RVF_YELLOW)
4134 {
4135 /* deallocate the memory */
4136 rvf_free_buf((T_RVF_BUFFER *)p_msg);
4137 audio_voice_memo_amr_error_trace(AUDIO_ENTITY_NO_MEMORY);
4138 return (AUDIO_ERROR);
4139 }
4140 else
4141 if (mb_status == RVF_RED)
4142 {
4143 audio_voice_memo_amr_error_trace(AUDIO_ENTITY_NO_MEMORY);
4144 return (AUDIO_ERROR);
4145 }
4146
4147 /* fill the message id */
4148 p_msg->os_hdr.msg_id = msg_id;
4149 p_msg->os_hdr.dest_addr_id = p_audio_gbl_var->addrId;
4150
4151 /* fill the message parameters */
4152 p_msg->channel_id = channel_id;
4153
4154 if (return_path.callback_func == NULL)
4155 {
4156 p_msg->return_path.addr_id = return_path.addr_id;
4157 p_msg->return_path.callback_func = NULL;
4158 }
4159 else
4160 p_msg->return_path.callback_func = return_path.callback_func;
4161
4162 /* send the messsage to the audio entity */
4163 rvf_send_msg (p_audio_gbl_var->addrId, p_msg);
4164
4165 return (AUDIO_OK);
4166 #else
4167 AUDIO_SEND_TRACE("Audio Driver not compiled", RV_TRACE_LEVEL_DEBUG_LOW);
4168 return(AUDIO_ERROR);
4169 #endif
4170 }
4171
4172 T_AUDIO_RET audio_driver_get_play_buffer(UINT8 channel_id, UINT8 **pp_buffer)
4173 {
4174 #if (L1_AUDIO_DRIVER)
4175 T_AUDIO_DRIVER_SESSION *p_session;
4176 UINT8 index_appli;
4177
4178 /* Test CHANNEL_ID */
4179 if (channel_id >= AUDIO_DRIVER_MAX_CHANNEL)
4180 {
4181 AUDIO_SEND_TRACE("AUDIO DRIVER GET BUFFER: channel_id not valid", RV_TRACE_LEVEL_DEBUG_LOW);
4182 return (AUDIO_ERROR);
4183 }
4184
4185 /* get driver session */
4186 p_session = &(p_audio_gbl_var->audio_driver_session[channel_id]);
4187 index_appli = p_session->session_info.index_appli;
4188
4189 /* channel must be initialized */
4190 if (p_session->session_info.state == AUDIO_DRIVER_CHANNEL_WAIT_INIT)
4191 {
4192 AUDIO_SEND_TRACE("AUDIO DRIVER GET BUFFER: channel not initialized", RV_TRACE_LEVEL_DEBUG_LOW);
4193 return (AUDIO_ERROR);
4194 }
4195
4196 /* play buffer must have been used after a previous call of this API */
4197 if (p_session->session_info.play_api_state != AUDIO_PLAY_API_STATE_GET_BUF)
4198 {
4199 AUDIO_SEND_TRACE("AUDIO DRIVER GET BUFFER: PLAY not called after GET", RV_TRACE_LEVEL_DEBUG_LOW);
4200 return (AUDIO_ERROR);
4201 }
4202
4203 /* test if next buffer is available */
4204 if (index_appli != p_session->session_info.index_l1)
4205 {
4206 *pp_buffer = (UINT8 *)(p_session->session_info.buffer[index_appli].p_start_pointer);
4207 AUDIO_SEND_TRACE_PARAM("AUDIO DRIVER GET BUFFER: buffer", *pp_buffer, RV_TRACE_LEVEL_DEBUG_LOW);
4208 p_session->session_info.play_api_state = AUDIO_PLAY_API_STATE_PLAY_BUF;
4209 }
4210 else
4211 {
4212 AUDIO_SEND_TRACE("AUDIO DRIVER GET BUFFER: no buffer available", RV_TRACE_LEVEL_DEBUG_LOW);
4213 return (AUDIO_ERROR);
4214 }
4215
4216 /* 1st time, index_l1 = 0xFF. At 1st play, layer1 becomes valid so we put 0
4217 This way, appli can't circle round buffers when in WAIT_START state */
4218 if (p_session->session_info.state == AUDIO_DRIVER_CHANNEL_WAIT_START)
4219 p_session->session_info.index_l1 = 0;
4220
4221 return (AUDIO_OK);
4222 #else
4223 AUDIO_SEND_TRACE("Audio Driver not compiled", RV_TRACE_LEVEL_DEBUG_LOW);
4224 return(AUDIO_ERROR);
4225 #endif
4226 }
4227
4228 T_AUDIO_RET audio_driver_play_buffer(UINT8 channel_id, UINT8 *p_buffer)
4229 {
4230 #if (L1_AUDIO_DRIVER)
4231 T_AUDIO_DRIVER_SESSION *p_session;
4232
4233 /* Test CHANNEL_ID */
4234 if (channel_id >= AUDIO_DRIVER_MAX_CHANNEL)
4235 {
4236 AUDIO_SEND_TRACE("AUDIO DRIVER PLAY BUFFER: channel_id not valid", RV_TRACE_LEVEL_DEBUG_LOW);
4237 return (AUDIO_ERROR);
4238 }
4239
4240 /* get driver session */
4241 p_session = &(p_audio_gbl_var->audio_driver_session[channel_id]);
4242
4243 /* channel must be initialized */
4244 if (p_session->session_info.state == AUDIO_DRIVER_CHANNEL_WAIT_INIT)
4245 {
4246 AUDIO_SEND_TRACE("AUDIO DRIVER PLAY BUFFER: channel not initialized", RV_TRACE_LEVEL_DEBUG_LOW);
4247 //p_session->session_info.play_api_state = AUDIO_PLAY_API_STATE_GET_BUF;
4248 return (AUDIO_ERROR);
4249 }
4250
4251 /* get buffer must have been called before */
4252 if (p_session->session_info.play_api_state != AUDIO_PLAY_API_STATE_PLAY_BUF)
4253 {
4254 AUDIO_SEND_TRACE("AUDIO DRIVER GET BUFFER: GET not called before play", RV_TRACE_LEVEL_DEBUG_LOW);
4255 return (AUDIO_ERROR);
4256 }
4257
4258 /* check validity of buffer */
4259 if ( p_buffer !=
4260 ((UINT8 *)(p_session->session_info.buffer[p_session->session_info.index_appli].p_start_pointer)))
4261 {
4262 AUDIO_SEND_TRACE_PARAM("AUDIO DRIVER PLAY BUFFER: buffer is not valid", p_buffer, RV_TRACE_LEVEL_DEBUG_LOW);
4263 return (AUDIO_ERROR);
4264 }
4265
4266 /* increment index_appli */
4267 AUDIO_SEND_TRACE_PARAM("AUDIO DRIVER PLAY BUFFER:", p_session->session_info.index_appli, RV_TRACE_LEVEL_DEBUG_LOW);
4268 p_session->session_info.play_api_state = AUDIO_PLAY_API_STATE_GET_BUF;
4269 p_session->session_info.index_appli++;
4270
4271 if (p_session->session_info.index_appli == p_session->session_req.nb_buffer)
4272 p_session->session_info.index_appli = 0;
4273
4274 return (AUDIO_OK);
4275 #else
4276 AUDIO_SEND_TRACE("Audio Driver not compiled", RV_TRACE_LEVEL_DEBUG_LOW);
4277 return(AUDIO_ERROR);
4278 #endif
4279
4280 }
4281
4282 T_AUDIO_RET Side_Tone_Mute()
4283 {
4284 T_RV_RETURN return_path = { NULL, 0 };
4285 T_AUDIO_FULL_ACCESS_WRITE audioPara;
4286 INT8 value = AUDIO_SIDETONE_OPEN;
4287
4288 audioPara.variable_indentifier = AUDIO_MICROPHONE_SPEAKER_LOOP_SIDETONE;
4289 audioPara.data = &value;
4290
4291 return audio_full_access_write(&audioPara, return_path);
4292 }
4293
4294 void Side_Tone_Write(INT8 gain)
4295 {
4296 T_RV_RETURN return_path = { NULL, 0 };
4297 T_AUDIO_FULL_ACCESS_WRITE audioPara;
4298 INT8 value = gain;
4299
4300 audioPara.variable_indentifier = AUDIO_MICROPHONE_SPEAKER_LOOP_SIDETONE;
4301 audioPara.data = &value;
4302
4303 audio_full_access_write(&audioPara, return_path);
4304 }
4305
4306 T_AUDIO_RET Side_Tone_Read()
4307 {
4308 T_RV_RETURN return_path = { NULL, 0 };
4309 T_AUDIO_FULL_ACCESS_READ audioPara;
4310 INT8 value;
4311
4312 audioPara.variable_indentifier = AUDIO_MICROPHONE_SPEAKER_LOOP_SIDETONE;
4313 audioPara.data = &value;
4314
4315 audio_full_access_read(&audioPara);
4316
4317 return value;
4318 }
4319
4320 #endif // #ifdef RVM_AUDIO_MAIN_SWE