comparison src/cs/services/audio/audio_keybeep.c @ 519:838eeafb0051

Main and Audio source directories lowercased
author Mychaela Falconia <falcon@freecalypso.org>
date Sun, 22 Jul 2018 07:41:05 +0000
parents src/cs/services/Audio/audio_keybeep.c@945cf7f506b2
children
comparison
equal deleted inserted replaced
518:4b7e0dba42f6 519:838eeafb0051
1 /****************************************************************************/
2 /* */
3 /* File Name: audio_keybeep.c */
4 /* */
5 /* Purpose: This file contains all the functions used to manage the */
6 /* keybeep. */
7 /* */
8 /* Version 0.1 */
9 /* */
10 /* Date Modification */
11 /* ------------------------------------ */
12 /* 18 May 2001 Create */
13 /* */
14 /* Author */
15 /* Francois Mazard - Stephanie Gerthoux */
16 /* */
17 /* (C) Copyright 2001 by Texas Instruments Incorporated, All Rights Reserved*/
18 /****************************************************************************/
19
20 #include "rv/rv_defined_swe.h"
21 #ifdef RVM_AUDIO_MAIN_SWE
22 #ifndef _WINDOWS
23 #include "config/swconfig.cfg"
24 #include "config/sys.cfg"
25 #include "config/chipset.cfg"
26 #endif
27
28 #include <math.h>
29
30 /* include the usefull L1 header */
31 #include "l1_confg.h"
32
33 #if (KEYBEEP)
34 #include "rv/rv_general.h"
35 #include "rvm/rvm_gen.h"
36 #include "audio/audio_features_i.h"
37 #include "audio/audio_ffs_i.h"
38 #include "audio/audio_api.h"
39 #include "audio/audio_structs_i.h"
40 #include "audio/audio_var_i.h"
41 #include "audio/audio_messages_i.h"
42 #include "rvf/rvf_target.h"
43 #include "audio/audio_const_i.h"
44 #include "audio/audio_error_hdlr_i.h"
45
46 /* include the usefull L1 header */
47 #define BOOL_FLAG
48 #define CHAR_FLAG
49 #include "l1_types.h"
50 #include "l1audio_cust.h"
51 #include "l1audio_msgty.h"
52 #include "l1audio_signa.h"
53
54
55 /********************************************************************************/
56 /* */
57 /* Function Name: audio_keybeep_convert_parameter */
58 /* */
59 /* Purpose: Convert the keybeep paramters from the entity to the l1 */
60 /* parameters */
61 /* */
62 /* Input Parameters: */
63 /* entity keybeep message */
64 /* */
65 /* Output Parameters: */
66 /* layer 1 keybeep message */
67 /* */
68 /* Note: */
69 /* None. */
70 /* */
71 /* Revision History: */
72 /* None. */
73 /* */
74 /********************************************************************************/
75
76
77 void audio_keybeep_convert_parameter( T_AUDIO_KEYBEEP_START *entity_parameter,
78 T_MMI_KEYBEEP_REQ *l1_parameter)
79 {
80 double frequency_index, frequency_beep, amplitude_beep, amplitude, amplitude_index;
81
82 /* Calculation of the frequency index */
83 /* note: we /* add +0.5 to compensate the truncation */
84 frequency_beep = (double)(entity_parameter->keybeep_parameter.frequency_beep[0]);
85 frequency_index = (256 * cos(6.283185*(frequency_beep/8000)));
86 /* Calculation of the amplitude index */
87 /* note: we /* add +0.5 to compensate the truncation */
88 amplitude_beep = (double)(entity_parameter->keybeep_parameter.amplitude_beep[0]);
89 amplitude = exp((amplitude_beep*0.115129)+(5.544625));
90 amplitude_index = amplitude * sin(6.283185*(frequency_beep/8000));
91
92 l1_parameter->d_k_x1_kt0 = (UINT16)((((UINT16)(frequency_index))<<8) | ((UINT16)(amplitude_index)));
93
94 /* Calculation of the frequency index */
95 /* note: we /* add +0.5 to compensate the truncation */
96 frequency_beep = (double)(entity_parameter->keybeep_parameter.frequency_beep[1]);
97 frequency_index = (256 * cos(6.283185*(frequency_beep/8000)));
98 /* Calculation of the amplitude index */
99 /* note: we /* add +0.5 to compensate the truncation */
100 amplitude_beep = (double)(entity_parameter->keybeep_parameter.amplitude_beep[1]);
101 amplitude = exp((amplitude_beep*0.115129)+(5.544625));
102 amplitude_index = amplitude * sin(6.283185*(frequency_beep/8000));
103
104 l1_parameter->d_k_x1_kt1 = (UINT16)((((UINT16)(frequency_index))<<8) | ((UINT16)(amplitude_index)));
105
106 l1_parameter->d_dur_kb = (UINT16)(entity_parameter->keybeep_parameter.duration/20);
107 }
108
109
110 /********************************************************************************/
111 /* */
112 /* Function Name: audio_keybeep_send_status */
113 /* */
114 /* Purpose: This function sends the keybeep status to the entity. */
115 /* */
116 /* Input Parameters: */
117 /* status, */
118 /* return path */
119 /* */
120 /* Output Parameters: */
121 /* None. */
122 /* */
123 /* Note: */
124 /* None. */
125 /* */
126 /* Revision History: */
127 /* None. */
128 /* */
129 /********************************************************************************/
130 void audio_keybeep_send_status (T_AUDIO_RET status, T_RV_RETURN return_path)
131 {
132 void *p_send_message = NULL;
133 T_RVF_MB_STATUS mb_status = RVF_RED;
134
135 while (mb_status == RVF_RED)
136 {
137 /* allocate the message buffer */
138 mb_status = rvf_get_buf (p_audio_gbl_var->mb_external,
139 sizeof (T_AUDIO_KEYBEEP_STATUS),
140 (T_RVF_BUFFER **) (&p_send_message));
141
142 /* If insufficient resources, then report a memory error and abort. */
143 /* and wait until more ressource is given */
144 if (mb_status == RVF_RED)
145 {
146 audio_keybeep_error_trace(AUDIO_ENTITY_NO_MEMORY);
147 rvf_delay(RVF_MS_TO_TICKS(1000));
148 }
149 }
150 /*fill the header of the message */
151 ((T_AUDIO_KEYBEEP_STATUS *)(p_send_message))->os_hdr.msg_id = AUDIO_KEYBEEP_STATUS_MSG;
152
153 /* fill the status parameters */
154 ((T_AUDIO_KEYBEEP_STATUS *)(p_send_message))->status = status;
155
156 if (return_path.callback_func == NULL)
157 {
158 /* send the message to the entity */
159 rvf_send_msg (return_path.addr_id,
160 p_send_message);
161 }
162 else
163 {
164 /* call the callback function */
165 (*return_path.callback_func)((void *)(p_send_message));
166 rvf_free_buf((T_RVF_BUFFER *)p_send_message);
167 }
168 }
169 /********************************************************************************/
170 /* */
171 /* Function Name: audio_keybeep_manager */
172 /* */
173 /* Purpose: This function is called to manage a key beep generation */
174 /* and DTMF generation. */
175 /* */
176 /* Input Parameters: */
177 /* Audio Key Beep Parameters, */
178 /* */
179 /* Output Parameters: */
180 /* None. */
181 /* */
182 /* Note: */
183 /* None. */
184 /* */
185 /* Revision History: */
186 /* None. */
187 /* */
188 /********************************************************************************/
189 void audio_keybeep_manager (T_RV_HDR *p_message)
190 {
191 /* Declare local variables. */
192 void *p_send_message;
193
194 /**************** audio_keybeep_manager function begins *********************/
195 switch(p_audio_gbl_var->keybeep.state)
196 {
197 case AUDIO_KEYBEEP_IDLE:
198 {
199 switch(p_message->msg_id)
200 {
201 case AUDIO_KEYBEEP_START_REQ:
202 {
203 /* save the addr id of the entity */
204 p_audio_gbl_var->keybeep.task_id = p_message->src_addr_id;
205
206 /* save the return path */
207 p_audio_gbl_var->keybeep.return_path.callback_func = ((T_AUDIO_KEYBEEP_START*)(p_message))->return_path.callback_func;
208 p_audio_gbl_var->keybeep.return_path.addr_id = ((T_AUDIO_KEYBEEP_START*)(p_message))->return_path.addr_id;
209
210
211 /* allocate the buffer for the message to the L1 */
212 p_send_message = audio_allocate_l1_message(sizeof(T_MMI_KEYBEEP_REQ));
213 if ( p_send_message != NULL)
214 {
215 /* Convert the entity parameters to the audio L1 parameters */
216 audio_keybeep_convert_parameter((T_AUDIO_KEYBEEP_START *)p_message,
217 (T_MMI_KEYBEEP_REQ *)p_send_message);
218
219 /* send the start command to the audio L1 */
220 audio_send_l1_message(MMI_KEYBEEP_START_REQ, p_send_message);
221 }
222
223 /* change to the state AUDIO_KEYBEEP_WAIT_START_CONFIRMATION */
224 p_audio_gbl_var->keybeep.state = AUDIO_KEYBEEP_WAIT_START_CON;
225 break;
226 }
227
228 case AUDIO_KEYBEEP_STOP_REQ:
229 {
230 /* event error - send an error message*/
231 audio_keybeep_send_status (AUDIO_ERROR, ((T_AUDIO_KEYBEEP_STOP *)(p_message))->return_path);
232
233 audio_keybeep_error_trace(AUDIO_ERROR_STOP_EVENT);
234 break;
235 }
236 }
237 break;
238 } /* case AUDIO_KEYBEEP_IDLE */
239
240 case AUDIO_KEYBEEP_WAIT_START_CON:
241 {
242 switch(p_message->msg_id)
243 {
244 case MMI_KEYBEEP_START_CON:
245 {
246 /* change to the state AUDIO_KEYBEEP_WAIT_STOP_COMMAND */
247 p_audio_gbl_var->keybeep.state = AUDIO_KEYBEEP_WAIT_STOP_COMMAND;
248 break;
249 }
250 case AUDIO_KEYBEEP_STOP_REQ:
251 /*.Before stopping this task, control that */
252 /* stop task id caller = Keybeep task id */
253 {
254 if ( p_audio_gbl_var->keybeep.task_id == p_message->src_addr_id)
255 {
256 /* change to the state AUDIO_KEYBEEP_WAIT_STOP_CONFIRMATION */
257 p_audio_gbl_var->keybeep.state = AUDIO_KEYBEEP_WAIT_START_CON_TO_STOP;
258 }
259 else
260 {
261 /* A stop request from an other task is sent during a start connection */
262 /* event error - send an error message */
263 audio_keybeep_send_status (AUDIO_ERROR, ((T_AUDIO_KEYBEEP_STOP *)(p_message))->return_path);
264
265 audio_keybeep_error_trace(AUDIO_ERROR_STOP_EVENT);
266 }
267 break;
268 }
269 case AUDIO_KEYBEEP_START_REQ:
270 {
271 /* event error - send an error message*/
272 audio_keybeep_send_status (AUDIO_ERROR, ((T_AUDIO_KEYBEEP_START *)(p_message))->return_path);
273
274 audio_keybeep_error_trace(AUDIO_ERROR_START_EVENT);
275 break;
276 }
277 }
278 break;
279 } /* case AUDIO_WAIT_START_CON */
280
281 case AUDIO_KEYBEEP_WAIT_START_CON_TO_STOP:
282 {
283 switch(p_message->msg_id)
284 {
285 case MMI_KEYBEEP_START_CON:
286 {
287 /* send the stop command to the audio L1 */
288 /* allocate the buffer for the message to the L1 */
289 p_send_message = audio_allocate_l1_message(0);
290 if ( p_send_message != NULL)
291 {
292 /* send the start command to the audio L1 */
293 audio_send_l1_message(MMI_KEYBEEP_STOP_REQ, p_send_message);
294 }
295
296 /* change to the state AUDIO_KEYBEEP_WAIT_STOP_CON */
297 p_audio_gbl_var->keybeep.state = AUDIO_KEYBEEP_WAIT_STOP_CON;
298 break;
299 }
300 case AUDIO_KEYBEEP_START_REQ:
301 {
302 /* event error - send an error message*/
303 audio_keybeep_send_status (AUDIO_ERROR, ((T_AUDIO_KEYBEEP_START *)(p_message))->return_path);
304
305 audio_keybeep_error_trace(AUDIO_ERROR_START_EVENT);
306 break;
307 }
308 case AUDIO_KEYBEEP_STOP_REQ:
309 {
310 /* event error - send an error message*/
311 audio_keybeep_send_status (AUDIO_ERROR, ((T_AUDIO_KEYBEEP_STOP *)(p_message))->return_path);
312
313 audio_keybeep_error_trace(AUDIO_ERROR_STOP_EVENT);
314 break;
315 }
316 }
317 break;
318 }
319
320 case AUDIO_KEYBEEP_WAIT_STOP_COMMAND:
321 {
322 switch(p_message->msg_id)
323 {
324 case MMI_KEYBEEP_STOP_CON:
325 {
326 audio_keybeep_send_status (AUDIO_OK, p_audio_gbl_var->keybeep.return_path);
327
328 /* change to the state AUDIO_KEYBEEP_IDLE */
329 p_audio_gbl_var->keybeep.state = AUDIO_KEYBEEP_IDLE;
330 break;
331 }
332
333 case AUDIO_KEYBEEP_STOP_REQ:
334 /* A stop request is sent during a stop connection */
335 /* Save the addr id of the entity */
336 p_audio_gbl_var->keybeep.task_id = p_message->src_addr_id;
337
338 /*.Control that (stop task id caller = Keybeep task id) and stop the task */
339 { if ( p_audio_gbl_var->keybeep.task_id == p_message->src_addr_id)
340 {
341
342 /* send the stop command to the audio L1 */
343 /* allocate the buffer for the message to the L1 */
344 p_send_message = audio_allocate_l1_message(0);
345 if (p_send_message != NULL)
346 {
347 /* send the start command to the audio L1 */
348 audio_send_l1_message(MMI_KEYBEEP_STOP_REQ, p_send_message);
349 }
350
351 /* change to the state AUDIO_KEYBEEP_WAIT_STOP_CONFIRMATION */
352 p_audio_gbl_var->keybeep.state = AUDIO_KEYBEEP_WAIT_STOP_CON;
353 }
354 else
355 {
356 /* A stop request from an other task is sent during a stop connection */
357 /* event error - send an error message */
358 audio_keybeep_send_status (AUDIO_ERROR, ((T_AUDIO_KEYBEEP_STOP *)(p_message))->return_path);
359
360 audio_keybeep_error_trace(AUDIO_ERROR_STOP_EVENT);
361 }
362 break;
363 }
364
365 case AUDIO_KEYBEEP_START_REQ:
366 {
367 /* event error - send an error message*/
368 audio_keybeep_send_status (AUDIO_ERROR, ((T_AUDIO_KEYBEEP_START *)(p_message))->return_path);
369
370 audio_keybeep_error_trace(AUDIO_ERROR_START_EVENT);
371 break;
372 }
373 }
374 break;
375 } /* case AUDIO_KEYBEEP_WAIT_STOP_COMMAND */
376
377 case AUDIO_KEYBEEP_WAIT_STOP_CON:
378 {
379 switch(p_message->msg_id)
380 {
381 case MMI_KEYBEEP_STOP_CON:
382 {
383 audio_keybeep_send_status (AUDIO_OK, p_audio_gbl_var->keybeep.return_path);
384
385 /* change to the state AUDIO_KEYBEEP_IDLE */
386 p_audio_gbl_var->keybeep.state = AUDIO_KEYBEEP_IDLE;
387 break;
388 }
389 case AUDIO_KEYBEEP_STOP_REQ:
390 {
391 /* event error - send an error message*/
392 audio_keybeep_send_status (AUDIO_ERROR, ((T_AUDIO_KEYBEEP_STOP *)(p_message))->return_path);
393
394 audio_keybeep_error_trace(AUDIO_ERROR_STOP_EVENT);
395 break;
396 }
397 case AUDIO_KEYBEEP_START_REQ:
398 {
399 /* event error - send an error message*/
400 audio_keybeep_send_status (AUDIO_ERROR, ((T_AUDIO_KEYBEEP_START *)(p_message))->return_path);
401
402 audio_keybeep_error_trace(AUDIO_ERROR_START_EVENT);
403 break;
404 }
405 }
406 break;
407 } /* case AUDIO_KEYBEEP_WAIT_STOP_CON */
408
409 } /* switch(p_audio_gbl_var->keybeep.state) */
410 } /*********************** End of audio_keybeep_manager function **********************/
411 #endif /* #if (KEYBEEP) */
412
413 #endif /* #ifdef RVM_AUDIO_MAIN_SWE */