FreeCalypso > hg > tcs211-c139
comparison chipsetsw/services/Audio/audio_vm_amr_record.c @ 0:509db1a7b7b8
initial import: leo2moko-r1
author | Space Falcon <falcon@ivan.Harhan.ORG> |
---|---|
date | Mon, 01 Jun 2015 03:24:05 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:509db1a7b7b8 |
---|---|
1 /****************************************************************************/ | |
2 /* */ | |
3 /* File Name: audio_vm_amr_record.c */ | |
4 /* */ | |
5 /* Purpose: This file contains all the functions used to manage the */ | |
6 /* Voice Memorization AMR record task. */ | |
7 /* */ | |
8 /* Version 0.1 */ | |
9 /* */ | |
10 /* Date Modification */ | |
11 /* ------------------------------------ */ | |
12 /* ?? ?? 2002 Create */ | |
13 /* */ | |
14 /* Author */ | |
15 /* Stephanie Gerthoux */ | |
16 /* */ | |
17 /* (C) Copyright 2001 by Texas Instruments Incorporated, All Rights Reserved*/ | |
18 /****************************************************************************/ | |
19 | |
20 #include "rv/rv_defined_swe.h" | |
21 #ifdef RVM_AUDIO_MAIN_SWE | |
22 #ifndef _WINDOWS | |
23 #include "config/swconfig.cfg" | |
24 #include "config/sys.cfg" | |
25 #include "config/chipset.cfg" | |
26 #endif | |
27 | |
28 /* include the usefull L1 header */ | |
29 #include "l1_confg.h" | |
30 | |
31 #if (L1_VOICE_MEMO_AMR) | |
32 #include "rv/rv_general.h" | |
33 #include "rvm/rvm_gen.h" | |
34 #include "audio/audio_features_i.h" | |
35 #include "audio/audio_ffs_i.h" | |
36 #include "audio/audio_api.h" | |
37 #include "audio/audio_structs_i.h" | |
38 #include "audio/audio_var_i.h" | |
39 #include "audio/audio_messages_i.h" | |
40 #include "rvf/rvf_target.h" | |
41 #include "audio/audio_const_i.h" | |
42 #include "audio/audio_error_hdlr_i.h" | |
43 | |
44 /* include the usefull L1 header */ | |
45 #define BOOL_FLAG | |
46 #define CHAR_FLAG | |
47 #include "l1_types.h" | |
48 #include "l1audio_cust.h" | |
49 #include "l1audio_msgty.h" | |
50 #include "l1audio_signa.h" | |
51 | |
52 #include "audio/audio_macro_i.h" | |
53 | |
54 /********************************************************************************/ | |
55 /* */ | |
56 /* Function Name: audio_vm_amr_record_send_status */ | |
57 /* */ | |
58 /* Purpose: This function sends the voice memorization AMR record status */ | |
59 /* to the entity. */ | |
60 /* */ | |
61 /* Input Parameters: */ | |
62 /* status, */ | |
63 /* return path */ | |
64 /* */ | |
65 /* Output Parameters: */ | |
66 /* None. */ | |
67 /* */ | |
68 /* Note: */ | |
69 /* None. */ | |
70 /* */ | |
71 /* Revision History: */ | |
72 /* None. */ | |
73 /* */ | |
74 /********************************************************************************/ | |
75 #if (AUDIO_MEM_MANAGER) | |
76 void audio_vm_amr_record_send_status (T_AUDIO_RET status, | |
77 UINT32 recorded_size, | |
78 T_RV_RETURN return_path) | |
79 { | |
80 T_AUDIO_AMR_RECORD_STATUS *p_send_message; | |
81 T_RVF_MB_STATUS mb_status = RVF_RED; | |
82 | |
83 /* allocate the message buffer */ | |
84 while (mb_status == RVF_RED) | |
85 { | |
86 mb_status = rvf_get_buf (p_audio_gbl_var->mb_external, | |
87 sizeof (T_AUDIO_AMR_RECORD_STATUS), | |
88 (T_RVF_BUFFER **) (&p_send_message)); | |
89 | |
90 /* If insufficient resources, then report a memory error and abort. */ | |
91 /* and wait until more ressource is given */ | |
92 if (mb_status == RVF_RED) | |
93 { | |
94 audio_voice_memo_amr_error_trace(AUDIO_ENTITY_NO_MEMORY); | |
95 rvf_delay(RVF_MS_TO_TICKS(1000)); | |
96 } | |
97 } | |
98 | |
99 /*fill the header of the message */ | |
100 p_send_message->os_hdr.msg_id = AUDIO_AMR_RECORD_TO_MEM_STATUS_MSG; | |
101 | |
102 /* fill the status parameters */ | |
103 p_send_message->status = status; | |
104 if (recorded_size == 0) | |
105 p_send_message->recorded_duration = 0; | |
106 else | |
107 p_send_message->recorded_duration = recorded_size; | |
108 | |
109 /* send message or call callback */ | |
110 if (return_path.callback_func == NULL) | |
111 { | |
112 rvf_send_msg (return_path.addr_id, p_send_message); | |
113 } | |
114 else | |
115 { | |
116 (*return_path.callback_func)((void *)(p_send_message)); | |
117 rvf_free_buf((T_RVF_BUFFER *)p_send_message); | |
118 } | |
119 } | |
120 | |
121 void audio_vm_amr_record_to_memory_manager (T_RV_HDR *p_message) | |
122 { | |
123 /* Declare local variables. */ | |
124 T_RV_HDR *p_send_message; | |
125 T_RVF_MB_STATUS mb_status; | |
126 T_RV_RETURN return_path; | |
127 | |
128 /**************** audio_vm_amr_record_to_memory_manager function begins ***********************/ | |
129 switch(p_audio_gbl_var->audio_vm_amr_record.state) | |
130 { | |
131 case AUDIO_IDLE: | |
132 { | |
133 switch (p_message->msg_id) | |
134 { | |
135 case AUDIO_VM_AMR_RECORD_TO_FFS_START_REQ: | |
136 case AUDIO_VM_AMR_RECORD_TO_RAM_START_REQ: | |
137 { | |
138 T_AUDIO_DRIVER_VM_AMR_RECORD_PARAMETER parameter; | |
139 T_AUDIO_DRIVER_PARAMETER driver_parameter; | |
140 | |
141 switch (p_message->msg_id) | |
142 { | |
143 case AUDIO_VM_AMR_RECORD_TO_FFS_START_REQ: | |
144 { | |
145 /* save the return path + ffs_fd */ | |
146 #if (AUDIO_RAM_MANAGER) | |
147 p_audio_gbl_var->audio_vm_amr_record.audio_ram_fd = NULL; | |
148 #endif | |
149 p_audio_gbl_var->audio_vm_amr_record.return_path.callback_func = | |
150 ((T_AUDIO_VM_AMR_RECORD_TO_FFS_START *)p_message)->return_path.callback_func; | |
151 p_audio_gbl_var->audio_vm_amr_record.return_path.addr_id = | |
152 ((T_AUDIO_VM_AMR_RECORD_TO_FFS_START*)p_message)->return_path.addr_id; | |
153 #if (AUDIO_NEW_FFS_MANAGER) | |
154 p_audio_gbl_var->audio_vm_amr_record.ffs_fd = | |
155 ((T_AUDIO_VM_AMR_RECORD_TO_FFS_START *)p_message)->audio_ffs_fd; | |
156 #endif | |
157 | |
158 /* fill AMR parameters and driver parameters */ | |
159 parameter.memo_duration = ((T_AUDIO_VM_AMR_RECORD_TO_FFS_START *)p_message)->memo_duration; | |
160 parameter.compression_mode = ((T_AUDIO_VM_AMR_RECORD_TO_FFS_START *)p_message)->compression_mode; | |
161 parameter.microphone_gain = ((T_AUDIO_VM_AMR_RECORD_TO_FFS_START *)p_message)->microphone_gain; | |
162 parameter.amr_vocoder = ((T_AUDIO_VM_AMR_RECORD_TO_FFS_START *)p_message)->amr_vocoder; | |
163 } | |
164 break; | |
165 case AUDIO_VM_AMR_RECORD_TO_RAM_START_REQ: | |
166 { | |
167 /* save the return path + p_buffer */ | |
168 #if (AUDIO_NEW_FFS_MANAGER) | |
169 p_audio_gbl_var->audio_vm_amr_record.ffs_fd = NULL; | |
170 #endif | |
171 p_audio_gbl_var->audio_vm_amr_record.return_path.callback_func = | |
172 ((T_AUDIO_VM_AMR_RECORD_TO_RAM_START *)p_message)->return_path.callback_func; | |
173 p_audio_gbl_var->audio_vm_amr_record.return_path.addr_id = | |
174 ((T_AUDIO_VM_AMR_RECORD_TO_RAM_START*)p_message)->return_path.addr_id; | |
175 #if (AUDIO_RAM_MANAGER) | |
176 p_audio_gbl_var->audio_vm_amr_record.audio_ram_fd = | |
177 ((T_AUDIO_VM_AMR_RECORD_TO_RAM_START *)p_message)->p_buffer; | |
178 #endif | |
179 | |
180 /* fill AMR parameters and driver parameters */ | |
181 parameter.memo_duration = ((T_AUDIO_VM_AMR_RECORD_TO_RAM_START *)p_message)->memo_duration; | |
182 parameter.compression_mode = ((T_AUDIO_VM_AMR_RECORD_TO_RAM_START *)p_message)->compression_mode; | |
183 parameter.microphone_gain = ((T_AUDIO_VM_AMR_RECORD_TO_RAM_START *)p_message)->microphone_gain; | |
184 parameter.amr_vocoder = ((T_AUDIO_VM_AMR_RECORD_TO_RAM_START *)p_message)->amr_vocoder; | |
185 } | |
186 break; | |
187 } | |
188 | |
189 driver_parameter.nb_buffer = AUDIO_VM_AMR_RECORD_NB_BUFFER; | |
190 driver_parameter.buffer_size = AUDIO_VM_AMR_RECORD_SIZE; | |
191 | |
192 /* return_path for driver */ | |
193 return_path.callback_func = NULL; | |
194 return_path.addr_id = p_audio_gbl_var->addrId; | |
195 | |
196 /* Init driver */ | |
197 audio_driver_init_vm_amr_record_session(¶meter, &driver_parameter, return_path); | |
198 | |
199 p_audio_gbl_var->audio_vm_amr_record.state = AUDIO_WAIT_CHANNEL_ID; | |
200 } | |
201 break; | |
202 case AUDIO_VM_AMR_RECORD_TO_FFS_STOP_REQ: | |
203 case AUDIO_VM_AMR_RECORD_TO_RAM_STOP_REQ: | |
204 { | |
205 audio_voice_memo_amr_error_trace(AUDIO_ERROR_STOP_EVENT); | |
206 /* do not send a status message because of pre-emption issues | |
207 An automatic stop can pre-empt a stop request. A status is sent + back in state idle | |
208 then the stop request is received and another status is sent, which can be misinterpreted */ | |
209 } | |
210 break; | |
211 } | |
212 } | |
213 break; | |
214 | |
215 case AUDIO_WAIT_CHANNEL_ID: | |
216 { | |
217 switch (p_message->msg_id) | |
218 { | |
219 case AUDIO_DRIVER_INIT_STATUS_MSG: | |
220 { | |
221 /* check init is successfull otherwise, send status AUDIO_ERROR */ | |
222 if (((T_AUDIO_DRIVER_INIT_STATUS *)p_message)->status == AUDIO_OK) | |
223 { | |
224 /* get channel id */ | |
225 p_audio_gbl_var->audio_vm_amr_record.channel_id = ((T_AUDIO_DRIVER_INIT_STATUS *)p_message)->channel_id; | |
226 | |
227 /* Send the Start message to MEM */ | |
228 mb_status = rvf_get_buf (p_audio_gbl_var->mb_internal, | |
229 sizeof (T_AUDIO_MEM_START), | |
230 (T_RVF_BUFFER **) (&p_send_message)); | |
231 | |
232 /* If insufficient resources, then report a memory error and abort. */ | |
233 if (mb_status == RVF_RED) | |
234 { | |
235 audio_voice_memo_amr_error_trace(AUDIO_ENTITY_NO_MEMORY); | |
236 // TODO: use blocking function from GSP | |
237 return; | |
238 } | |
239 | |
240 /* fill the header of the message */ | |
241 ((T_AUDIO_MEM_START *)p_send_message)->os_hdr.msg_id = AUDIO_MEM_START_REQ; | |
242 | |
243 /* fill the parameters */ | |
244 ((T_AUDIO_MEM_START *)p_send_message)->session_id = AUDIO_VM_AMR_RECORD_SESSION_ID; | |
245 ((T_AUDIO_MEM_START *)p_send_message)->channel_id = p_audio_gbl_var->audio_vm_amr_record.channel_id; | |
246 ((T_AUDIO_MEM_START *)p_send_message)->size = AUDIO_VM_AMR_RECORD_SIZE*2; | |
247 #if (AUDIO_NEW_FFS_MANAGER) | |
248 ((T_AUDIO_MEM_START *)p_send_message)->audio_ffs_fd = p_audio_gbl_var->audio_vm_amr_record.ffs_fd; | |
249 #endif | |
250 #if (AUDIO_RAM_MANAGER) | |
251 ((T_AUDIO_MEM_START *)p_send_message)->audio_ram_fd = p_audio_gbl_var->audio_vm_amr_record.audio_ram_fd; | |
252 #endif | |
253 | |
254 /* send the message to the entity */ | |
255 rvf_send_msg ( p_audio_gbl_var->audio_ffs_addrId, p_send_message); | |
256 | |
257 /* change state */ | |
258 p_audio_gbl_var->audio_vm_amr_record.state = AUDIO_WAIT_STOP; | |
259 } | |
260 else | |
261 { | |
262 audio_voice_memo_amr_error_trace(AUDIO_ERROR_START_EVENT); | |
263 audio_vm_amr_record_send_status (AUDIO_ERROR, 0, | |
264 p_audio_gbl_var->audio_vm_amr_record.return_path); | |
265 /* change state */ | |
266 p_audio_gbl_var->audio_vm_amr_record.state = AUDIO_IDLE; | |
267 } | |
268 } | |
269 break; | |
270 case AUDIO_VM_AMR_RECORD_TO_FFS_STOP_REQ: | |
271 #if (AUDIO_RAM_MANAGER) | |
272 if (p_audio_gbl_var->audio_vm_amr_record.audio_ram_fd != NULL) | |
273 { | |
274 audio_voice_memo_amr_error_trace(AUDIO_ERROR_STOP_EVENT); | |
275 return; | |
276 } | |
277 #endif | |
278 /* change state */ | |
279 p_audio_gbl_var->audio_vm_amr_record.state = AUDIO_WAIT_CHANNEL_ID_TO_STOP; | |
280 break; | |
281 case AUDIO_VM_AMR_RECORD_TO_RAM_STOP_REQ: | |
282 #if (AUDIO_NEW_FFS_MANAGER) | |
283 if (p_audio_gbl_var->audio_vm_amr_record.ffs_fd != NULL) | |
284 { | |
285 audio_voice_memo_amr_error_trace(AUDIO_ERROR_STOP_EVENT); | |
286 return; | |
287 } | |
288 #endif | |
289 /* change state */ | |
290 p_audio_gbl_var->audio_vm_amr_record.state = AUDIO_WAIT_CHANNEL_ID_TO_STOP; | |
291 break; | |
292 } | |
293 } // case AUDIO_WAIT_CHANNEL_ID: | |
294 break; | |
295 | |
296 case AUDIO_WAIT_STOP: | |
297 { | |
298 switch (p_message->msg_id) | |
299 { | |
300 case AUDIO_VM_AMR_RECORD_TO_FFS_STOP_REQ: | |
301 case AUDIO_VM_AMR_RECORD_TO_RAM_STOP_REQ: | |
302 { | |
303 // we handle a RAM stop when New_ffs is running as an error | |
304 #if (AUDIO_NEW_FFS_MANAGER) | |
305 if ((p_message->msg_id == AUDIO_VM_AMR_RECORD_TO_RAM_STOP_REQ)&& | |
306 (p_audio_gbl_var->audio_vm_amr_record.ffs_fd != NULL)) | |
307 { | |
308 audio_voice_memo_amr_error_trace(AUDIO_ERROR_STOP_EVENT); | |
309 return; | |
310 } | |
311 #endif | |
312 // we handle a New_ffs stop when RAM is running as an error | |
313 #if (AUDIO_RAM_MANAGER) | |
314 if ((p_message->msg_id == AUDIO_VM_AMR_RECORD_TO_FFS_STOP_REQ)&& | |
315 (p_audio_gbl_var->audio_vm_amr_record.audio_ram_fd != NULL)) | |
316 { | |
317 audio_voice_memo_amr_error_trace(AUDIO_ERROR_STOP_EVENT); | |
318 return; | |
319 } | |
320 #endif | |
321 /* Send the Stop message to MEM manager */ | |
322 mb_status = rvf_get_buf (p_audio_gbl_var->mb_internal, | |
323 sizeof (T_AUDIO_MEM_STOP), | |
324 (T_RVF_BUFFER **) (&p_send_message)); | |
325 | |
326 /* If insufficient resources, then report a memory error and abort. */ | |
327 if (mb_status == RVF_RED) | |
328 { | |
329 audio_voice_memo_amr_error_trace(AUDIO_ENTITY_NO_MEMORY); | |
330 return; | |
331 } | |
332 | |
333 /* fill message */ | |
334 ((T_AUDIO_MEM_STOP *)p_send_message)->os_hdr.msg_id = AUDIO_MEM_STOP_REQ; | |
335 ((T_AUDIO_MEM_STOP *)p_send_message)->channel_id = p_audio_gbl_var->audio_vm_amr_record.channel_id; | |
336 | |
337 /* send the message to the entity */ | |
338 rvf_send_msg (p_audio_gbl_var->audio_ffs_addrId, p_send_message); | |
339 | |
340 p_audio_gbl_var->audio_vm_amr_record.state = AUDIO_WAIT_STOP_CON; | |
341 } | |
342 break; | |
343 case AUDIO_MEM_STATUS_MSG: | |
344 { | |
345 if (((T_AUDIO_MEM_STATUS *)p_message)->status_type == AUDIO_STOP_STATUS) | |
346 { | |
347 /* should be useless as it is an automatic stop so AUDIO_OK */ | |
348 if (((T_AUDIO_MEM_STATUS *)p_message)->status == AUDIO_OK) | |
349 { | |
350 audio_vm_amr_record_send_status (AUDIO_OK, ((T_AUDIO_MEM_STATUS *)p_message)->recorded_size, | |
351 p_audio_gbl_var->audio_vm_amr_record.return_path); | |
352 p_audio_gbl_var->audio_vm_amr_record.state = AUDIO_IDLE; | |
353 } | |
354 } | |
355 if (((T_AUDIO_MEM_STATUS *)p_message)->status_type == AUDIO_START_STATUS) | |
356 { | |
357 /* MEM could not find a free mem channel */ | |
358 if (((T_AUDIO_MEM_STATUS *)p_message)->status == AUDIO_ERROR) | |
359 { | |
360 audio_vm_amr_record_send_status (AUDIO_ERROR, 0, | |
361 p_audio_gbl_var->audio_vm_amr_record.return_path); | |
362 p_audio_gbl_var->audio_vm_amr_record.state = AUDIO_IDLE; | |
363 } | |
364 } | |
365 } | |
366 break; | |
367 } | |
368 } | |
369 break; | |
370 case AUDIO_WAIT_STOP_CON: | |
371 { | |
372 switch (p_message->msg_id) | |
373 { | |
374 case AUDIO_MEM_STATUS_MSG: | |
375 { | |
376 if (((T_AUDIO_MEM_STATUS *)p_message)->status_type == AUDIO_STOP_STATUS) | |
377 { | |
378 audio_vm_amr_record_send_status (AUDIO_OK, ((T_AUDIO_MEM_STATUS *)p_message)->recorded_size, | |
379 p_audio_gbl_var->audio_vm_amr_record.return_path); | |
380 p_audio_gbl_var->audio_vm_amr_record.state = AUDIO_IDLE; | |
381 } | |
382 } | |
383 break; | |
384 case AUDIO_VM_AMR_RECORD_TO_FFS_STOP_REQ: | |
385 case AUDIO_VM_AMR_RECORD_TO_RAM_STOP_REQ: | |
386 audio_voice_memo_amr_error_trace(AUDIO_ERROR_STOP_EVENT); | |
387 break; | |
388 } | |
389 } | |
390 break; | |
391 case AUDIO_WAIT_CHANNEL_ID_TO_STOP: | |
392 { | |
393 switch (p_message->msg_id) | |
394 { | |
395 case AUDIO_DRIVER_INIT_STATUS_MSG: | |
396 { | |
397 if (((T_AUDIO_DRIVER_INIT_STATUS *)p_message)->status == AUDIO_OK) | |
398 { | |
399 /* get channel_id */ | |
400 p_audio_gbl_var->audio_vm_amr_record.channel_id = ((T_AUDIO_DRIVER_INIT_STATUS *)p_message)->channel_id; | |
401 | |
402 audio_driver_stop_session(p_audio_gbl_var->audio_vm_amr_record.channel_id); | |
403 | |
404 /* change state */ | |
405 p_audio_gbl_var->audio_vm_amr_record.state = AUDIO_WAIT_DRIVER_STOP_CON; | |
406 } | |
407 else | |
408 { | |
409 /* close file */ | |
410 #if (AUDIO_NEW_FFS_MANAGER) | |
411 if (p_audio_gbl_var->audio_vm_amr_record.ffs_fd != NULL) | |
412 { | |
413 if ( ffs_close(p_audio_gbl_var->audio_vm_amr_record.ffs_fd) != EFFS_OK ) | |
414 { | |
415 audio_ffs_error_trace(AUDIO_ENTITY_FILE_NO_CLOSE); | |
416 } | |
417 AUDIO_SEND_TRACE("AUDIO VM AMR RECORD: close FFS file", RV_TRACE_LEVEL_DEBUG_LOW); | |
418 } | |
419 #endif | |
420 | |
421 audio_vm_amr_record_send_status (AUDIO_OK, 0, | |
422 p_audio_gbl_var->audio_vm_amr_record.return_path); | |
423 | |
424 /* change state */ | |
425 p_audio_gbl_var->audio_vm_amr_record.state = AUDIO_IDLE; | |
426 } | |
427 } | |
428 break; | |
429 case AUDIO_VM_AMR_RECORD_TO_FFS_STOP_REQ: | |
430 case AUDIO_VM_AMR_RECORD_TO_RAM_STOP_REQ: | |
431 audio_voice_memo_amr_error_trace(AUDIO_ERROR_STOP_EVENT); | |
432 break; | |
433 } | |
434 } // case AUDIO_WAIT_CHANNEL_ID_TO_STOP: | |
435 break; | |
436 case AUDIO_WAIT_DRIVER_STOP_CON: | |
437 { | |
438 switch (p_message->msg_id) | |
439 { | |
440 case AUDIO_DRIVER_STATUS_MSG: | |
441 { | |
442 if (((T_AUDIO_DRIVER_STATUS *)p_message)->status_type == AUDIO_STOP_STATUS) | |
443 { | |
444 /* close file */ | |
445 #if (AUDIO_NEW_FFS_MANAGER) | |
446 if (p_audio_gbl_var->audio_vm_amr_record.ffs_fd != NULL) | |
447 { | |
448 if ( ffs_close(p_audio_gbl_var->audio_vm_amr_record.ffs_fd) != EFFS_OK ) | |
449 { | |
450 audio_ffs_error_trace(AUDIO_ENTITY_FILE_NO_CLOSE); | |
451 } | |
452 AUDIO_SEND_TRACE("AUDIO VM AMR RECORD: close FFS file", RV_TRACE_LEVEL_DEBUG_LOW); | |
453 } | |
454 #endif | |
455 | |
456 audio_vm_amr_record_send_status (AUDIO_OK, 0, | |
457 p_audio_gbl_var->audio_vm_amr_record.return_path); | |
458 p_audio_gbl_var->audio_vm_amr_record.state = AUDIO_IDLE; | |
459 } | |
460 } | |
461 break; | |
462 case AUDIO_VM_AMR_RECORD_TO_FFS_STOP_REQ: | |
463 case AUDIO_VM_AMR_RECORD_TO_RAM_STOP_REQ: | |
464 audio_voice_memo_amr_error_trace(AUDIO_ERROR_STOP_EVENT); | |
465 break; | |
466 } | |
467 } //case AUDIO_WAIT_DRIVER_STOP_CON: | |
468 break; | |
469 } | |
470 } /*********************** End of audio_vm_amr_record_to_memory_manager function **********************/ | |
471 #endif // AUDIO_MEM_MANAGER | |
472 | |
473 /********************************************************************************/ | |
474 /* */ | |
475 /* Function Name: audio_driver_vm_amr_record_convert_parameter */ | |
476 /* */ | |
477 /* Purpose: Convert the voice memorization record parameters from the */ | |
478 /* entity to the l1 parameters */ | |
479 /* */ | |
480 /* Input Parameters: */ | |
481 /* session_id of the voice memo record */ | |
482 /* id of the voice memo record */ | |
483 /* */ | |
484 /* Output Parameters: */ | |
485 /* layer 1 voice memo record message */ | |
486 /* */ | |
487 /* Note: */ | |
488 /* None. */ | |
489 /* */ | |
490 /* Revision History: */ | |
491 /* None. */ | |
492 /* */ | |
493 /********************************************************************************/ | |
494 void audio_driver_vm_amr_record_convert_parameter(T_AUDIO_DRIVER_INIT_VM_AMR_RECORD_SESSION *entity_parameter, | |
495 T_MMI_VM_AMR_RECORD_REQ *l1_parameter) | |
496 { | |
497 /* session id : specifies the customer data identification corresponding to */ | |
498 /* this voice memorization */ | |
499 l1_parameter->session_id = AUDIO_VM_AMR_RECORD_SESSION_ID; | |
500 l1_parameter->maximum_size = entity_parameter->memo_duration + SC_VM_AMR_END_MASK_SIZE; | |
501 l1_parameter->dtx_used = (BOOL)(entity_parameter->compression_mode); | |
502 l1_parameter->record_coeff_ul = (UINT16)(entity_parameter->microphone_gain); | |
503 l1_parameter->amr_vocoder = (UINT16)(entity_parameter->amr_vocoder); | |
504 } | |
505 | |
506 /********************************************************************************/ | |
507 /* */ | |
508 /* Function Name: audio_driver_vm_amr_record_manager */ | |
509 /* */ | |
510 /* Purpose: This function is called to manage a voice memorization record */ | |
511 /* manager */ | |
512 /* */ | |
513 /* Input Parameters: */ | |
514 /* Message to the audio entity */ | |
515 /* */ | |
516 /* Output Parameters: */ | |
517 /* None. */ | |
518 /* */ | |
519 /* Note: */ | |
520 /* None. */ | |
521 /* */ | |
522 /* Revision History: */ | |
523 /* None. */ | |
524 /* */ | |
525 /********************************************************************************/ | |
526 T_AUDIO_RET audio_driver_vm_amr_record_manager (T_RV_HDR *p_message, T_AUDIO_DRIVER_SESSION *p_session) | |
527 { | |
528 /**************** audio_driver_vm_amr_record_manager function begins ***********************/ | |
529 switch(p_session->session_info.state) | |
530 { | |
531 case AUDIO_DRIVER_CHANNEL_WAIT_INIT: | |
532 { | |
533 /* allocate the buffer for the message to the L1 */ | |
534 p_session->session_req.p_l1_send_message = | |
535 audio_allocate_l1_message(sizeof(T_MMI_VM_AMR_RECORD_REQ)); | |
536 | |
537 if (p_session->session_req.p_l1_send_message != NULL ) | |
538 { | |
539 /* Convert the entity parameters to the audio L1 parameters */ | |
540 audio_driver_vm_amr_record_convert_parameter((T_AUDIO_DRIVER_INIT_VM_AMR_RECORD_SESSION*)p_message, | |
541 p_session->session_req.p_l1_send_message); | |
542 return (AUDIO_OK); | |
543 } | |
544 return (AUDIO_ERROR); | |
545 } | |
546 break; | |
547 | |
548 case AUDIO_DRIVER_CHANNEL_WAIT_START: | |
549 { | |
550 /* send the start voice memo record message to the L1 */ | |
551 audio_send_l1_message(MMI_VM_AMR_RECORD_START_REQ, | |
552 p_session->session_req.p_l1_send_message); | |
553 return (AUDIO_OK); | |
554 } | |
555 break; | |
556 | |
557 case AUDIO_DRIVER_CHANNEL_WAIT_STOP: | |
558 { | |
559 /* send the stop command to the audio L1 */ | |
560 /* allocate the buffer for the message to the L1 */ | |
561 void *p_send_message = audio_allocate_l1_message(0); | |
562 if ( p_send_message != NULL) | |
563 { | |
564 /* send the stop command to the audio L1 */ | |
565 audio_send_l1_message(MMI_VM_AMR_RECORD_STOP_REQ, p_send_message); | |
566 return (AUDIO_OK); | |
567 } | |
568 return (AUDIO_ERROR); | |
569 } | |
570 break; | |
571 case AUDIO_DRIVER_CHANNEL_WAIT_START_CON_TO_STOP: | |
572 { | |
573 /* only STOP is handled here */ | |
574 /* send the stop command to the audio L1 */ | |
575 /* allocate the buffer for the message to the L1 */ | |
576 void *p_send_message = audio_allocate_l1_message(0); | |
577 if ( p_send_message != NULL) | |
578 { | |
579 /* send the stop command to the audio L1 */ | |
580 audio_send_l1_message(MMI_VM_AMR_RECORD_STOP_REQ, p_send_message); | |
581 return (AUDIO_OK); | |
582 } | |
583 return (AUDIO_ERROR); | |
584 } | |
585 break; | |
586 } | |
587 } /*********************** End of audio_vm_record_manager function **********************/ | |
588 | |
589 #endif /* VM_AMR_RECORD */ | |
590 #endif /* RVM_AUDIO_MAIN_SWE */ |