FreeCalypso > hg > tcs211-l1-reconst
comparison g23m/condat/ms/src/mfw/mfw_aud.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 | PROJECT: MMI-Framework (8417) $Workfile:: mfw_aud.c $| | |
4 | $Author:: NDH $Revision:: 1 $| | |
5 | CREATED: 04.02.03 $Modtime:: 10.04.00 14:58 $| | |
6 | STATE : code | | |
7 +--------------------------------------------------------------------+ | |
8 | |
9 MODULE : MFW_AUD | |
10 | |
11 PURPOSE : This module contains Audio Riveria Interface functions. | |
12 | |
13 HISTORY: | |
14 | |
15 Mar 03, 2005 REF: CRR MMI-ENH-28950 xnkulkar | |
16 Description: RE: Vocoder interface change | |
17 Solution: Function call 'enable_tch_vocoder()' is replaced with new functions 'hl_drv_enable_vocoder()' | |
18 and 'hl_drv_disable_vocoder()' | |
19 | |
20 Aug 25, 2004 REF: CRR 20655 xnkulkar | |
21 Description: Voice Memo functionality not working | |
22 Solution: The voice recording functionality was failing because | |
23 " mmi" folder is not present. As a solution, we create the | |
24 "mmi" folder and then proceed with recording. | |
25 */ | |
26 | |
27 | |
28 /* | |
29 ** Include Files | |
30 */ | |
31 | |
32 #define ENTITY_MFW | |
33 | |
34 /* BEGIN ADD: Req ID: : Sumit : 14-Mar-05 */ | |
35 #ifndef NEPTUNE_BOARD | |
36 /* END ADD: Req ID: : Sumit : 14-Mar-05 */ | |
37 | |
38 /* includes */ | |
39 #include <string.h> | |
40 | |
41 #include "typedefs.h" | |
42 #include "vsi.h" | |
43 #include "pei.h" | |
44 #include "custom.h" | |
45 #include "gsm.h" | |
46 | |
47 #include "mfw_ffs.h" | |
48 #include "mfw_aud.h" | |
49 | |
50 #include "Audio/audio_api.h" | |
51 | |
52 // Mar 03, 2005 REF: CRR MMI-ENH-28950 xnkulkar | |
53 #include "hl_audio_drv.h" | |
54 | |
55 /* | |
56 ** Local Variable Definitions | |
57 */ | |
58 | |
59 static T_RV_RETURN_PATH voice_memo_return_path; | |
60 | |
61 | |
62 /* | |
63 ** Local Macro Definitions | |
64 */ | |
65 | |
66 #define VM_FILE_NAME "vmfile" // FFS File Name | |
67 #define VM_FOLDER "/mmi/vm" | |
68 | |
69 #define VM_MICROPHONE_GAIN (0x0100) // Default Gain of 1 | |
70 #define VM_NETWORK_GAIN (0x0100) // Default Gain of 1 | |
71 | |
72 #define VM_TONE_DURATION (50) | |
73 #define VM_TONE_INTERVAL (50) | |
74 #define VM_TONE_AMPLITUDE (-24) // Default Amplitude of -24dB | |
75 | |
76 | |
77 /* | |
78 ** Local Function Prototypes | |
79 */ | |
80 | |
81 static void mfw_aud_vm_create_file(const char *folder, const char *fname, UBYTE index); | |
82 static void configure_callback_fn(void (*callback_fn)(void *)); | |
83 static void configure_vm_filename(char *vm_filename, const char *folder, const char *fname, UBYTE index); | |
84 | |
85 | |
86 /* | |
87 ** Public function Definitions | |
88 */ | |
89 | |
90 | |
91 | |
92 /* | |
93 +--------------------------------------------------------------------+ | |
94 | PROJECT: MMI-Framework (8417) MODULE: MFW_AUD | | |
95 | STATE : code ROUTINE: mfw_aud_vm_delete_file | | |
96 +--------------------------------------------------------------------+ | |
97 | |
98 | |
99 PURPOSE : Delete the file which held the Voice Memo | |
100 | |
101 */ | |
102 SHORT mfw_aud_vm_delete_file(void) | |
103 { | |
104 char tmpFile[AUDIO_PATH_NAME_MAX_SIZE]; | |
105 | |
106 configure_vm_filename(tmpFile, VM_FOLDER, VM_FILE_NAME, 0); | |
107 | |
108 ffs_remove(tmpFile); | |
109 | |
110 return MFW_AUD_VM_OK; | |
111 } | |
112 | |
113 | |
114 /* | |
115 +--------------------------------------------------------------------+ | |
116 | PROJECT: MMI-Framework (8417) MODULE: MFW_AUD | | |
117 | STATE : code ROUTINE: mfw_aud_vm_start_playback | | |
118 +--------------------------------------------------------------------+ | |
119 | |
120 | |
121 PURPOSE : Start playback of a previously recorded Voice Memo | |
122 | |
123 */ | |
124 SHORT mfw_aud_vm_start_playback(void (*callback_fn)(void *)) | |
125 { | |
126 T_AUDIO_RET audio_riv_retVal; | |
127 T_AUDIO_VM_PLAY_PARAMETER mfw_vm_play_param; | |
128 | |
129 if (FFS_flashData.voice_memo_position EQ 0) | |
130 { | |
131 return MFW_AUD_VM_MEM_EMPTY; | |
132 } | |
133 else | |
134 { | |
135 | |
136 configure_callback_fn(callback_fn); | |
137 | |
138 //Set up the Voice Memo filename in FFS | |
139 configure_vm_filename(mfw_vm_play_param.memo_name, VM_FOLDER, VM_FILE_NAME, 0); | |
140 | |
141 // Call Riviera function to start playback. | |
142 #ifndef WIN32 // only if not in Windows | |
143 audio_riv_retVal = audio_vm_play_start(&mfw_vm_play_param, | |
144 voice_memo_return_path); | |
145 | |
146 // If the Riviera call failed | |
147 if (audio_riv_retVal != RV_OK) | |
148 return MFW_AUD_VM_RIVIERA_FAILED; | |
149 #endif | |
150 } | |
151 | |
152 return MFW_AUD_VM_OK; | |
153 } | |
154 | |
155 | |
156 /* | |
157 +--------------------------------------------------------------------+ | |
158 | PROJECT: MMI-Framework (8417) MODULE: MFW_AUD | | |
159 | STATE : code ROUTINE: mfw_aud_vm_stop_playback | | |
160 +--------------------------------------------------------------------+ | |
161 | |
162 | |
163 PURPOSE : Stop playback of a previously recorded Voice Memo | |
164 | |
165 */ | |
166 SHORT mfw_aud_vm_stop_playback(void (*callback_fn)(void *)) | |
167 { | |
168 T_AUDIO_RET audio_riv_retVal; | |
169 | |
170 configure_callback_fn(callback_fn); | |
171 | |
172 #ifndef WIN32 // only if not in Windows | |
173 audio_riv_retVal = audio_vm_play_stop(voice_memo_return_path); | |
174 | |
175 // If the Riviera call failed | |
176 if (audio_riv_retVal != RV_OK) | |
177 return MFW_AUD_VM_RIVIERA_FAILED; | |
178 | |
179 #endif | |
180 | |
181 return MFW_AUD_VM_OK; | |
182 } | |
183 | |
184 | |
185 /* | |
186 +--------------------------------------------------------------------+ | |
187 | PROJECT: MMI-Framework (8417) MODULE: MFW_AUD | | |
188 | STATE : code ROUTINE: mfw_aud_vm_start_record | | |
189 +--------------------------------------------------------------------+ | |
190 | |
191 | |
192 PURPOSE : Configure Riviera and start recording a Voice Memo | |
193 | |
194 */ | |
195 SHORT mfw_aud_vm_start_record(UBYTE max_duration, void (*callback_fn)(void *)) | |
196 { | |
197 T_AUDIO_RET audio_riv_retVal; | |
198 T_AUDIO_VM_RECORD_PARAMETER mfw_vm_record_param; | |
199 T_AUDIO_TONES_PARAMETER mfw_vm_tones_param; | |
200 char * mmiDir = "/mmi"; // Aug 25, 2004 REF: CRR 20655 xnkulkar | |
201 | |
202 configure_callback_fn(callback_fn); | |
203 | |
204 //Set up, and create, the Voice Memo filename in FFS | |
205 configure_vm_filename(mfw_vm_record_param.memo_name, VM_FOLDER, VM_FILE_NAME, 0); | |
206 //Aug 25, 2004 REF: CRR 20655 xnkulkar | |
207 // We now create the "mmi" folder and then proceed with recording. | |
208 flash_makedir(mmiDir); | |
209 mfw_aud_vm_create_file(VM_FOLDER, VM_FILE_NAME, 0); | |
210 | |
211 // Setup the Voice Memo Tones | |
212 mfw_vm_record_param.memo_duration = (UINT32)max_duration; | |
213 mfw_vm_record_param.compression_mode = FALSE; // No Compression | |
214 mfw_vm_record_param.microphone_gain = VM_MICROPHONE_GAIN; | |
215 mfw_vm_record_param.network_gain = VM_NETWORK_GAIN; | |
216 | |
217 mfw_vm_tones_param.tones[0].start_tone = 0; | |
218 mfw_vm_tones_param.tones[0].stop_tone = VM_TONE_DURATION; | |
219 mfw_vm_tones_param.tones[0].frequency_tone = 520; // Tone 1 Frequecny in Hz | |
220 mfw_vm_tones_param.tones[0].amplitude_tone = VM_TONE_AMPLITUDE; | |
221 | |
222 mfw_vm_tones_param.tones[1].start_tone = mfw_vm_tones_param.tones[0].stop_tone + VM_TONE_INTERVAL; | |
223 mfw_vm_tones_param.tones[1].stop_tone = mfw_vm_tones_param.tones[1].start_tone + VM_TONE_DURATION; | |
224 mfw_vm_tones_param.tones[1].frequency_tone = 643; // Tone 2 Frequecny in Hz | |
225 mfw_vm_tones_param.tones[1].amplitude_tone = VM_TONE_AMPLITUDE; | |
226 | |
227 mfw_vm_tones_param.tones[2].start_tone = mfw_vm_tones_param.tones[1].stop_tone + VM_TONE_INTERVAL; | |
228 mfw_vm_tones_param.tones[2].stop_tone = mfw_vm_tones_param.tones[2].start_tone + VM_TONE_DURATION; | |
229 mfw_vm_tones_param.tones[2].frequency_tone = 775; // Tone 3 Frequecny in Hz | |
230 mfw_vm_tones_param.tones[2].amplitude_tone = VM_TONE_AMPLITUDE; | |
231 | |
232 mfw_vm_tones_param.frame_duration = mfw_vm_tones_param.tones[2].stop_tone * 2; | |
233 mfw_vm_tones_param.sequence_duration = mfw_vm_tones_param.frame_duration * 2; | |
234 mfw_vm_tones_param.period_duration = mfw_vm_tones_param.sequence_duration; | |
235 mfw_vm_tones_param.repetition = TONE_INFINITE; | |
236 | |
237 // Call Riviera function to start recording. | |
238 #ifndef WIN32 // only if not in Windows | |
239 audio_riv_retVal = audio_vm_record_start(&mfw_vm_record_param, | |
240 &mfw_vm_tones_param, | |
241 voice_memo_return_path); | |
242 | |
243 // If the Riviera call failed | |
244 if (audio_riv_retVal != RV_OK) | |
245 return MFW_AUD_VM_RIVIERA_FAILED; | |
246 #endif | |
247 | |
248 return MFW_AUD_VM_OK; | |
249 } | |
250 | |
251 | |
252 /* | |
253 +--------------------------------------------------------------------+ | |
254 | PROJECT: MMI-Framework (8417) MODULE: MFW_AUD | | |
255 | STATE : code ROUTINE: mfw_aud_vm_stop_record | | |
256 +--------------------------------------------------------------------+ | |
257 | |
258 | |
259 PURPOSE : Stop recording a Voice Memo | |
260 | |
261 */ | |
262 SHORT mfw_aud_vm_stop_record(void (*callback_fn)(void *)) | |
263 { | |
264 T_AUDIO_RET audio_riv_retVal; | |
265 | |
266 configure_callback_fn(callback_fn); | |
267 | |
268 #ifndef WIN32 // only if not in Windows | |
269 audio_riv_retVal = audio_vm_record_stop(voice_memo_return_path); | |
270 | |
271 // If the Riviera call failed | |
272 if (audio_riv_retVal != RV_OK) | |
273 return MFW_AUD_VM_RIVIERA_FAILED; | |
274 #endif | |
275 | |
276 return MFW_AUD_VM_OK; | |
277 } | |
278 | |
279 | |
280 /* | |
281 +--------------------------------------------------------------------+ | |
282 | PROJECT: MMI-Framework (8417) MODULE: MFW_AUD | | |
283 | STATE : code ROUTINE: mfw_aud_vm_get_duration | | |
284 +--------------------------------------------------------------------+ | |
285 | |
286 | |
287 PURPOSE : Get the duration of the previously recorded Voice Memo | |
288 | |
289 */ | |
290 UBYTE mfw_aud_vm_get_duration(void) | |
291 { | |
292 return FFS_flashData.voice_memo_position; | |
293 } | |
294 | |
295 | |
296 /* | |
297 +--------------------------------------------------------------------+ | |
298 | PROJECT: MMI-Framework (8417) MODULE: MFW_AUD | | |
299 | STATE : code ROUTINE: mfw_aud_vm_get_duration | | |
300 +--------------------------------------------------------------------+ | |
301 | |
302 | |
303 PURPOSE : Set the duration of the previously recorded Voice Memo | |
304 | |
305 */ | |
306 void mfw_aud_vm_set_duration(UBYTE duration) | |
307 { | |
308 FFS_flashData.voice_memo_position = duration; | |
309 | |
310 flash_write(); | |
311 return; | |
312 } | |
313 | |
314 | |
315 /* | |
316 ** Local Function Definitions | |
317 */ | |
318 | |
319 /* | |
320 +--------------------------------------------------------------------+ | |
321 | PROJECT: MMI-Framework (8417) MODULE: MFW_AUD | | |
322 | STATE : code ROUTINE: mfw_aud_vm_create_file | | |
323 +--------------------------------------------------------------------+ | |
324 | |
325 | |
326 PURPOSE : Create the FFS file required for the Riviera Voice Memo | |
327 | |
328 */ | |
329 static void mfw_aud_vm_create_file(const char *folder, const char *fname, UBYTE index) | |
330 { | |
331 UBYTE dummy = 0x00; | |
332 | |
333 flash_data_write(folder, fname, &dummy, sizeof(dummy)); | |
334 return; | |
335 } | |
336 | |
337 | |
338 /* | |
339 +--------------------------------------------------------------------+ | |
340 | PROJECT: MMI-Framework (8417) MODULE: MFW_AUD | | |
341 | STATE : code ROUTINE: configure_callback_fn | | |
342 +--------------------------------------------------------------------+ | |
343 | |
344 | |
345 PURPOSE : Configure the Riviera Return PAth | |
346 | |
347 */ | |
348 static void configure_callback_fn(void (*callback_fn)(void *)) | |
349 { | |
350 voice_memo_return_path.addr_id = 0; | |
351 voice_memo_return_path.callback_func = callback_fn; | |
352 | |
353 return; | |
354 } | |
355 | |
356 | |
357 | |
358 /* | |
359 +--------------------------------------------------------------------+ | |
360 | PROJECT: MMI-Framework (8417) MODULE: MFW_AUD | | |
361 | STATE : code ROUTINE: configure_vm_filename | | |
362 +--------------------------------------------------------------------+ | |
363 | |
364 | |
365 PURPOSE : Create the Voice memo filename from the incoming parameters | |
366 | |
367 */ | |
368 static void configure_vm_filename(char *vm_filename, const char *folder, const char *fname, UBYTE index) | |
369 { | |
370 memset(vm_filename, 0x00, AUDIO_PATH_NAME_MAX_SIZE); | |
371 strcpy(vm_filename, folder); | |
372 strcat(vm_filename, "/"); | |
373 strcat(vm_filename, fname); | |
374 } | |
375 | |
376 // Mar 03, 2005 REF: CRR MMI-ENH-28950 xnkulkar | |
377 // Commented as we are no more using 'enable_tch_vocoder()' from MFW | |
378 /* | |
379 #ifndef _SIMULATION_ | |
380 void enable_tch_vocoder(BOOL enabled); | |
381 #endif | |
382 */ | |
383 | |
384 /********************************************************************** | |
385 ** | |
386 ** MFW Riviera Vocoder Interface functions | |
387 ** | |
388 **********************************************************************/ | |
389 | |
390 void mfw_aud_l1_enable_vocoder ( void ) | |
391 { | |
392 #ifndef _SIMULATION_ | |
393 // Mar 03, 2005 REF: CRR MMI-ENH-28950 xnkulkar | |
394 // Call 'hl_drv_enable_vocoder()' instead of 'enable_tch_vocoder(TRUE)' | |
395 // enable_tch_vocoder(TRUE); | |
396 T_HL_VOICE_DRV_RSLT vocoderState; | |
397 vocoderState = hl_drv_enable_vocoder(); | |
398 if ( vocoderState == HL_VOICE_DRV_FAIL ) | |
399 { | |
400 TRACE_EVENT("vocoder driver : FAILED "); | |
401 return; | |
402 } | |
403 #endif | |
404 return; | |
405 } | |
406 | |
407 void mfw_aud_l1_disable_vocoder ( void ) | |
408 { | |
409 #ifndef _SIMULATION_ | |
410 // Mar 03, 2005 REF: CRR MMI-ENH-28950 xnkulkar | |
411 // Call 'hl_drv_disable_vocoder()' instead of 'enable_tch_vocoder(FALSE)' | |
412 // enable_tch_vocoder(FALSE); | |
413 hl_drv_disable_vocoder(); | |
414 #endif | |
415 return; | |
416 } | |
417 | |
418 /****************************************************************/ | |
419 /* NEPTUNE DEFINITIONS START HERE */ | |
420 /* BEGIN ADD: Req ID: : Sumit : 14-Mar-05 */ | |
421 #else /* NEPTUNE_BOARD */ | |
422 #include "typedefs.h" | |
423 #include "mfw_aud.h" | |
424 | |
425 SHORT mfw_aud_vm_delete_file(void) | |
426 { | |
427 return MFW_AUD_VM_OK; | |
428 } | |
429 | |
430 SHORT mfw_aud_vm_start_playback(void (*callback_fn)(void *)) | |
431 { | |
432 return MFW_AUD_VM_OK; | |
433 } | |
434 | |
435 SHORT mfw_aud_vm_stop_playback(void (*callback_fn)(void *)) | |
436 { | |
437 return MFW_AUD_VM_OK; | |
438 } | |
439 | |
440 SHORT mfw_aud_vm_start_record(UBYTE max_duration, void (*callback_fn)(void *)) | |
441 { | |
442 return MFW_AUD_VM_OK; | |
443 } | |
444 | |
445 SHORT mfw_aud_vm_stop_record(void (*callback_fn)(void *)) | |
446 { | |
447 return MFW_AUD_VM_OK; | |
448 } | |
449 | |
450 UBYTE mfw_aud_vm_get_duration(void) | |
451 { | |
452 return 0; | |
453 } | |
454 | |
455 void mfw_aud_vm_set_duration(UBYTE duration) | |
456 { | |
457 return; | |
458 } | |
459 | |
460 /* | |
461 ** Layer1 Audio interface functions | |
462 */ | |
463 void mfw_aud_l1_enable_vocoder ( void ) | |
464 { | |
465 } | |
466 | |
467 void mfw_aud_l1_disable_vocoder ( void ) | |
468 { | |
469 } | |
470 | |
471 #endif /* NEPTUNE_BOARD*/ | |
472 /* END ADD: Req ID: : Sumit : 14-Mar-05 */ | |
473 |