2 * Copyright 2012 Samsung Electronics Co., Ltd
4 * Licensed under the Flora License, Version 1.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.tizenopensource.org/license
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
18 #include "voice-call-sound.h"
19 #include "vc-core-util.h"
20 #include "vc-core-engine-types.h"
21 #include "voice-call-core.h"
22 #include "voice-call-bt.h"
23 #include "voice-call-service.h"
25 #include <vconf-keys.h>
27 #include <mm_message.h>
28 #include <mm_player.h>
30 #include <mm_sound_private.h>
34 #include <mm_session.h>
35 #include <mm_session_private.h>
37 #include <devman_haptic.h>
39 #define VOICE_CALL_SND_INVALID_SND_HANDLE -1 /**<Invalid Sound lib Handle*/
40 #define VOICE_CALL_SND_INVALID_PLAYER_HANDLE 0 /**<Invalid player lib Handle*/
42 #define VOICE_CALL_SND_VIBON_TIME_PERIOD 1500 /**< Vibration On Timer Interval */
43 #define VOICE_CALL_SND_VIBOFF_TIME_PERIOD 500 /**< Vibration Off Timer Interval */
44 #define VOICE_CALL_SND_INCREMENT_TIMER_INTERVAL 2000 /**< Incremental Melody Timer Interval */
45 #define VOICE_CALL_SND_VIB_THEN_MELODY_TIMER_INTERVAL 6000 /**< 6 sec (3 * (VOICE_CALL_SND_VIBON_TIME_PERIOD + VOICE_CALL_SND_VIBOFF_TIME_PERIOD)) approximately*/
46 #define VOICE_CALL_SND_2ND_CALL_BEEP_INTERVAL 2500
48 #define VOICE_CALL_SND_DEFAULT_RINGTONE_PATH MEDIADIR"/01_Minimal_tone.mp3"
49 #define VOICE_CALL_SND_SECOND_RINGTONE_PATH MEDIADIR"/Call_WaitingTone.wav"
51 #define VOICE_CALL_SND_CONNECT_SIGNAL_PATH MEDIADIR"/03_Call_connect.wav"
52 #define VOICE_CALL_SND_DISCONNECT_SIGNAL_PATH MEDIADIR"/04_Call_disconnect.wav"
53 #define VOICE_CALL_SND_MINUTE_MINDER_SIGNAL_PATH MEDIADIR"/03_Call_connect.wav"
55 #define VOICE_CALL_SND_USER_BUSY_SIGNAL_PATH MEDIADIR"/Call_BusyTone.wav"
56 #define VOICE_CALL_SND_NW_CONGESTION_SIGNAL_PATH MEDIADIR"/Call_NwCongestionTone.wav"
57 #define VOICE_CALL_SND_ERROR_SIGNAL_PATH MEDIADIR"/Call_ErrorTone.wav"
59 #ifdef VOICE_CALL_RINGTONE_ELEVATOR
60 #define VOICE_CALL_SND_INITIAL_VOL_LEVEL 1
61 #define VOICE_CALL_SND_RING_ELEVATOR_TIME_VAL 2000 /*3 Seconds Approx. */
65 * Enumeration for volume level of 10 levels
67 typedef enum _voicecall_snd_mm_vol_level9_t {
68 VOICE_CALL_SND_MM_VOLUME_LEVEL_0_9 = 0, /**< volume level 1 of 10 */
69 VOICE_CALL_SND_MM_VOLUME_LEVEL_1_9 = 16, /**< volume level 2 of 10 */
70 VOICE_CALL_SND_MM_VOLUME_LEVEL_2_9 = 28, /**< volume level 3 of 10 */
71 VOICE_CALL_SND_MM_VOLUME_LEVEL_3_9 = 39, /**< volume level 4 of 10 */
72 VOICE_CALL_SND_MM_VOLUME_LEVEL_4_9 = 50, /**< volume level 5 of 10 */
73 VOICE_CALL_SND_MM_VOLUME_LEVEL_5_9 = 62, /**< volume level 6 of 10 */
74 VOICE_CALL_SND_MM_VOLUME_LEVEL_6_9 = 73, /**< volume level 7 of 10 */
75 VOICE_CALL_SND_MM_VOLUME_LEVEL_7_9 = 82, /**< volume level 8 of 10 */
76 VOICE_CALL_SND_MM_VOLUME_LEVEL_8_9 = 91, /**< volume level 9 of 10 */
77 VOICE_CALL_SND_MM_VOLUME_LEVEL_9_9 = 100, /**< volume level 10 of 10 */
78 } voicecall_snd_mm_vol_level9_t;
80 typedef struct __voicecall_snd_path_info_t {
81 int phone_path; /**< normal call state path */
82 int alert_phone_path; /**< alert sound to other party (record alert beep or answering machine guidance) */
84 } voicecall_snd_path_info_t;
86 /* Local Fucntion Declerations */
88 * This function prepares to start the melody to be played according to the given parameters
90 * @return Returns TRUE on success or FALSE on failure
91 * @param[in] papp_snd Handle to the Sound Manager
92 * @param[in] bis_increasing TRUE - Increasing Melody, FALSE -Normal Melody
93 * @param[in] call_handle Call Handle of the Incoming Call
95 static gboolean __voicecall_snd_start_melody(voicecall_snd_mgr_t *papp_snd, gboolean bis_increasing, int call_handle);
98 * This function create the mm player
100 * @return turns TRUE on success or FALSE on failure
101 * @param[in] papp_snd Handle to the Soudn Manager
102 * @param[in] pPlayer Handle to the mm player
103 * @param[in] play_type Play Type of the Sound
105 static gboolean __voicecall_snd_create_player(voicecall_snd_mgr_t *papp_snd, MMHandleType * pPlayer, voicecall_snd_play_type_t play_type);
108 * This function starts the vibration
110 * @return Returns nothing
111 * @param[in] papp_snd Handle to the Sound Manager
113 static void __voicecall_snd_start_vibration(voicecall_snd_mgr_t *papp_snd);
116 * This function stops the vibration
118 * @return Returns TRUE on success or FALSE on failure
119 * @param[in] papp_snd Handle to the Sound Manager
121 static void __voicecall_snd_stop_vibration(voicecall_snd_mgr_t *papp_snd);
124 * This function serves as the callback for vibration then melody timer
126 * @return Returns TRUE on success or FALSE on failure
127 * @param[in] data Local data set by the caller
129 static gboolean __voicecall_snd_vib_then_melody_cb(void *data);
132 * This function serves as the callbback for the MM Player
134 * @return Returns TRUE on success or FALSE on failure
135 * @param[in] message MM Message from the MM Player
136 * @param[in] data Data send by the MM Player according to the Message
137 * @param[in] user_data Local Data by the Caller
139 static int __voicecall_snd_mmplayer_cb(int message, void *data, void *user_data);
141 static void __voicecall_snd_mmplayer_signal_cb(gpointer puser_data);
144 * This function serves as the callback for the increasing melody periodic timer
146 * @return Returns TRUE if sound cane be played or FALSE otherwise
147 * @param[in] data Loca Data set by the caller
149 static gboolean __voicecall_snd_increasing_melody_cb(void *data);
152 * This function plays the ringtone melody according to the settings
155 * @param[in] papp_snd Handle to the Sound Manager
156 * @param[in] bis_increasing TRUE - increasing melody, FALSE - normal
158 static gboolean __voicecall_snd_play_melody(voicecall_snd_mgr_t *papp_snd, gboolean bis_increasing);
161 * This function retreives the tapi sound path to be used according to the current status
164 * @param[in] papp_snd Handle to Sound Manager
165 * @param[out] voice_snd_path Tapi Sound Path
167 static void __voicecall_snd_get_voice_path(voicecall_snd_mgr_t *papp_snd, int *voice_snd_path);
169 #ifdef VOICE_CALL_RINGTONE_ELEVATOR
171 static gboolean __voicecall_and_start_ring_elevator_cb(gpointer pdata);
172 static void __voicecall_snd_start_ring_elevator(voicecall_snd_mgr_t *papp_snd);
173 static void __voicecall_snd_cancel_ring_elevator(voicecall_snd_mgr_t *papp_snd);
176 /*Function Defintions*/
178 * This function initializes the sound functionalties required by the Application
180 * @return Returns TRUE on success or FALSE on failure
181 * @param[in] pcall_core Handle to voicecall core
182 * @param[out] papp_snd Handle to the Sound Manager
184 gboolean voicecall_snd_init(void *pcall_core, voicecall_snd_mgr_t **papp_snd)
186 voicecall_snd_mgr_t *psnd_mgr = NULL;
188 CALL_ENG_DEBUG(ENG_DEBUG, "Sound CM Test\n");
190 psnd_mgr = (voicecall_snd_mgr_t *)calloc(1, sizeof(voicecall_snd_mgr_t));
192 if (psnd_mgr == NULL) {
193 CALL_ENG_DEBUG(ENG_ERR, "Memory Allocation Failed\n");
196 CALL_ENG_DEBUG(ENG_DEBUG, "psnd_mgr alloctated memory:[%d]\n", sizeof(voicecall_snd_mgr_t));
198 /*Store voice call Handle */
199 psnd_mgr->pcall_core = pcall_core;
201 psnd_mgr->current_snd_path = VOICE_CALL_SND_PATH_RECEIVER;
202 psnd_mgr->old_snd_path = VOICE_CALL_SND_PATH_NONE;
205 psnd_mgr->bsound_cm_state = FALSE;
207 psnd_mgr->pmm_player = VOICE_CALL_SND_INVALID_PLAYER_HANDLE;
208 psnd_mgr->pmm_signal_player = VOICE_CALL_SND_INVALID_SND_HANDLE;
210 psnd_mgr->mmfsoundplay_handle = VOICE_CALL_SND_INVALID_SND_HANDLE;
211 psnd_mgr->mmfalternateplay_handle = VOICE_CALL_SND_INVALID_SND_HANDLE;
213 psnd_mgr->psignal_play_end_cb = NULL;
214 psnd_mgr->psignal_play_end_cb_data = NULL;
216 /*Return the created Sound Manager */
217 *papp_snd = psnd_mgr;
222 void __voicecall_snd_alternate_sound_cb(void *puser_data);
223 void __voicecall_snd_play_alternate_sound(voicecall_snd_mgr_t *papp_snd);
224 gboolean __voicecall_snd_stop_alternate_sound(voicecall_snd_mgr_t *papp_snd);
226 gboolean __voicecall_snd_alternate_sound_idle_cb(void *puser_data)
228 voicecall_snd_mgr_t *papp_snd = (voicecall_snd_mgr_t *)puser_data;
229 call_vc_core_state_t *pcall_core = (call_vc_core_state_t *)papp_snd->pcall_core;
231 CALL_ENG_DEBUG(ENG_DEBUG, "..\n");
233 if (TRUE == papp_snd->balternate_play) {
234 if ((FALSE == voicecall_core_is_connected_call_exist(pcall_core->pcall_engine))
235 && (TRUE == voicecall_core_is_incoming_call_exists(pcall_core->pcall_engine))) {
236 /* case : during 2nd incoming call, connected call is cleared. so, just 1 incoming call case... */
237 CALL_ENG_DEBUG(ENG_DEBUG, "2nd incoming -> just single incoming call.\n");
238 voicecall_snd_prepare_alert(papp_snd, papp_snd->incoming_call_handle);
239 voicecall_snd_change_mm_path(papp_snd, VOICE_CALL_MM_RING_TONE);
240 voicecall_snd_play_alert(papp_snd);
242 __voicecall_snd_play_alternate_sound(papp_snd);
249 gboolean __voicecall_snd_alternate_play_timeout_cb(gpointer pdata)
251 voicecall_snd_mgr_t *papp_snd = (voicecall_snd_mgr_t *)pdata;
253 CALL_ENG_DEBUG(ENG_DEBUG, "..\n");
254 if (papp_snd->balternate_play == TRUE) {
255 __voicecall_snd_play_alternate_sound(papp_snd);
261 void __voicecall_snd_play_alternate_sound(voicecall_snd_mgr_t *papp_snd)
263 CALL_ENG_DEBUG(ENG_DEBUG, "..\n");
264 call_vc_core_state_t *pcall_core = (call_vc_core_state_t *)papp_snd->pcall_core;
266 if (TRUE == voicecall_core_is_incoming_call_exists(pcall_core->pcall_engine)) {
267 CALL_ENG_DEBUG(ENG_DEBUG, "Incoming call is there!Play Alternate Sound \n");
271 char ring_tone[VOICE_CALL_SND_RINGTONE_PATH_LEN];
272 snprintf(ring_tone, sizeof(ring_tone), "file://%s", VOICE_CALL_SND_SECOND_RINGTONE_PATH);
274 voicecall_snd_change_mm_path(pcall_core->papp_snd, VOICE_CALL_MM_SECOND_CALL_TONE);
276 CALL_ENG_DEBUG(ENG_DEBUG, "Call mm_sound_play_sound to play alternate ringtonen\n");
277 mmf_error = mm_sound_play_sound(VOICE_CALL_SND_SECOND_RINGTONE_PATH, VOLUME_TYPE_CALL, __voicecall_snd_alternate_sound_cb, papp_snd, &papp_snd->mmfalternateplay_handle);
279 if (MM_ERROR_NONE == mmf_error) {
280 papp_snd->balternate_play = TRUE;
281 papp_snd->ringtone_sound_status = VOICE_CALL_SND_STATUS_PLAY;
282 CALL_ENG_DEBUG(ENG_DEBUG, "Alternate Sound Play Called,papp_snd->balternate_play=%d \n", papp_snd->balternate_play);
284 papp_snd->ringtone_sound_status = VOICE_CALL_SND_STATUS_STOP;
285 papp_snd->balternate_play = FALSE;
286 CALL_ENG_DEBUG(ENG_DEBUG, "mmf_error = [0x%x] \n", mmf_error);
288 CALL_ENG_DEBUG(ENG_DEBUG, "End of Alternate Sound!\n");
292 gboolean __voicecall_snd_stop_alternate_sound(voicecall_snd_mgr_t *papp_snd)
294 CALL_ENG_DEBUG(ENG_DEBUG, " papp_snd->balternate_play = %d\n", papp_snd->balternate_play);
295 if (TRUE == papp_snd->balternate_play) {
296 /*Only Stop if it is in Play State */
297 if (VOICE_CALL_SND_STATUS_PLAY == papp_snd->ringtone_sound_status) {
299 error = mm_sound_stop_sound(papp_snd->mmfalternateplay_handle);
300 papp_snd->mmfalternateplay_handle = -1;
301 papp_snd->ringtone_sound_status = VOICE_CALL_SND_STATUS_STOP;
302 CALL_ENG_DEBUG(ENG_ERR, "Alternate Ringtone Stopeed,Error Code: [0x%x] \n", error);
304 papp_snd->balternate_play = FALSE;
310 void __voicecall_snd_alternate_sound_cb(void *puser_data)
312 voicecall_snd_mgr_t *papp_snd = (voicecall_snd_mgr_t *)puser_data;
313 call_vc_core_state_t *pcall_core = (call_vc_core_state_t *)papp_snd->pcall_core;
315 CALL_ENG_DEBUG(ENG_DEBUG, "papp_snd->balternate_play= %d\n", papp_snd->balternate_play);
317 papp_snd->ringtone_sound_status = VOICE_CALL_SND_STATUS_STOPPED;
319 /*If connected call exists then change the audio path */
320 if ((TRUE == voicecall_core_is_connected_call_exist(pcall_core->pcall_engine)) || (TRUE == voicecall_core_is_outgoing_call_exists(pcall_core->pcall_engine))) {
321 voicecall_snd_change_path(papp_snd);
324 g_timeout_add(VOICE_CALL_SND_2ND_CALL_BEEP_INTERVAL, __voicecall_snd_alternate_sound_idle_cb, papp_snd);
328 void voicecall_snd_prepare_alert(voicecall_snd_mgr_t *papp_snd, int call_handle)
330 CALL_ENG_DEBUG(ENG_DEBUG, "..\n");
332 call_vc_core_state_t *pcall_core = (call_vc_core_state_t *)papp_snd->pcall_core;
335 papp_snd->incoming_call_handle = call_handle;
337 if (TRUE == voicecall_core_is_connected_call_exist(pcall_core->pcall_engine)) {
338 CALL_ENG_DEBUG(ENG_DEBUG, "Alternate Sound Needs to be played \n");
339 papp_snd->ringtone_sound_status = VOICE_CALL_AND_STATUS_ALTERNATE_PLAY;
344 Always stop the alert before starting another
345 to make sure the previous alert is proerly closed.
347 voicecall_snd_stop_alert(papp_snd);
349 /*Initizlize Variables */
350 papp_snd->pmm_player = VOICE_CALL_SND_INVALID_PLAYER_HANDLE;
351 papp_snd->settings_sound_status = FALSE;
352 papp_snd->settings_vib_status = FALSE;
354 err_code = vconf_get_bool(VCONFKEY_SETAPPL_SOUND_STATUS_BOOL, &papp_snd->settings_sound_status);
355 CALL_ENG_DEBUG(ENG_DEBUG, "cur_sound_status = %d, error_code = %d\n", papp_snd->settings_sound_status, err_code);
357 err_code = vconf_get_bool(VCONFKEY_SETAPPL_VIBRATION_STATUS_BOOL, &papp_snd->settings_vib_status);
358 CALL_ENG_DEBUG(ENG_DEBUG, "cur_vib_status = %d, error_code = %d\n", papp_snd->settings_vib_status, err_code);
360 if (papp_snd->settings_sound_status == FALSE)
361 papp_snd->bmute_play = TRUE;
363 __voicecall_snd_start_melody(papp_snd, FALSE, call_handle);
367 void voicecall_snd_play_alert(voicecall_snd_mgr_t *papp_snd)
369 call_vc_core_state_t *pcall_core = (call_vc_core_state_t *)papp_snd->pcall_core;
371 CALL_ENG_DEBUG(ENG_DEBUG, "papp_snd->ringtone_sound_status=%d \n ", papp_snd->ringtone_sound_status);
373 if (VOICE_CALL_AND_STATUS_ALTERNATE_PLAY == papp_snd->ringtone_sound_status) {
374 if (TRUE == voicecall_core_is_connected_call_exist(pcall_core->pcall_engine)) {
375 CALL_ENG_DEBUG(ENG_DEBUG, "Starting Alternate Sound \n");
376 papp_snd->balternate_play_count = 0;
377 __voicecall_snd_play_alternate_sound(papp_snd);
381 if (VOICE_CALL_SND_STATUS_READY != papp_snd->ringtone_sound_status) {
382 CALL_ENG_DEBUG(ENG_DEBUG, " Invalid ringtone_sound_status: %d \n ", papp_snd->ringtone_sound_status);
386 papp_snd->ringtone_sound_status = VOICE_CALL_SND_STATUS_PROCESSED;
388 CALL_ENG_DEBUG(ENG_DEBUG, " [##### papp_snd->settings_sound_status #####] : %d \n ", papp_snd->settings_sound_status);
389 CALL_ENG_DEBUG(ENG_DEBUG, " [##### papp_snd->settings_vib_status #####] : %d \n ", papp_snd->settings_vib_status);
391 if (papp_snd->settings_sound_status) {
392 __voicecall_snd_play_melody(papp_snd, FALSE);
393 } else if (papp_snd->bmute_play) {
394 /*Change the path to the earjack headset and play the ringtone */
395 voicecall_snd_change_mm_path(papp_snd, VOICE_CALL_MM_MUTE_PLAY);
396 __voicecall_snd_play_melody(papp_snd, FALSE);
398 if (papp_snd->settings_vib_status) {
399 __voicecall_snd_start_vibration(papp_snd);
403 #ifdef VOICE_CALL_RINGTONE_ELEVATOR
405 gboolean __voicecall_and_start_ring_elevator_cb(gpointer pdata)
407 voicecall_snd_mgr_t *papp_snd = (voicecall_snd_mgr_t *)pdata;
408 int volume_level = VOICE_CALL_VOL_LEVEL_1;
411 CALL_ENG_DEBUG(ENG_DEBUG, "..\n");
413 /*Get the settings current ringtone volume level and set to media player */
414 ret_value = vconf_get_int(VCONFKEY_SETAPPL_PROFILE_CURRENT_CALL_VOLUME_INT, &volume_level);
415 if (ret_value != 0) {
416 CALL_ENG_DEBUG(ENG_ERR, "settings read failed Error: %d\n", ret_value);
418 CALL_ENG_DEBUG(ENG_DEBUG, "Settings Volume Level = %d\n", volume_level);
420 if (papp_snd->pmm_player != VOICE_CALL_SND_INVALID_PLAYER_HANDLE) {
421 ret_value = mm_sound_volume_set_value(VOLUME_TYPE_RINGTONE, volume_level);
422 if (MM_ERROR_NONE != ret_value) {
423 CALL_ENG_DEBUG(ENG_ERR, "Set Volume Error: [0x%x]\n", ret_value);
426 CALL_ENG_DEBUG(ENG_ERR, "Invalid MM Plauer %d\n", papp_snd->pmm_player);
432 void __voicecall_snd_start_ring_elevator(voicecall_snd_mgr_t *papp_snd)
434 CALL_ENG_DEBUG(ENG_DEBUG, "..\n");
436 papp_snd->ring_elvator_timerid = g_timeout_add(VOICE_CALL_SND_RING_ELEVATOR_TIME_VAL, __voicecall_and_start_ring_elevator_cb, papp_snd);
439 void __voicecall_snd_cancel_ring_elevator(voicecall_snd_mgr_t *papp_snd)
441 CALL_ENG_DEBUG(ENG_DEBUG, "..\n");
442 if (papp_snd->ring_elvator_timerid > 0) {
443 g_source_remove(papp_snd->ring_elvator_timerid);
444 papp_snd->ring_elvator_timerid = 0;
449 gboolean voicecall_snd_mute_alert(voicecall_snd_mgr_t *papp_snd)
451 CALL_ENG_DEBUG(ENG_DEBUG, "..\n");
452 if (papp_snd->pmm_player != VOICE_CALL_SND_INVALID_PLAYER_HANDLE) {
455 ret_value = mm_player_set_mute(papp_snd->pmm_player, TRUE);
456 CALL_ENG_DEBUG(ENG_DEBUG, "MM Set Mute Error code: [0x%x] \n", ret_value);
459 if (TRUE == papp_snd->bvibration) {
460 CALL_ENG_DEBUG(ENG_DEBUG, "Vibration is playing, stopping vibration \n");
461 __voicecall_snd_stop_vibration(papp_snd);
463 #ifdef VOICE_CALL_RINGTONE_ELEVATOR
464 __voicecall_snd_cancel_ring_elevator(papp_snd);
467 /*Make Vibration than melody flag to FALSE, so melody will not be played when it is muted */
468 papp_snd->bvibration_then_melody = FALSE;
470 /*Make Increasing Melody flag to FALSE, so melody volume will not be increased when it is muted */
471 papp_snd->bincreasingmelody = FALSE;
477 * This function stops the sound alert
480 * @param[in] papp_snd Handle to Sound Manager
482 void voicecall_snd_stop_alert(voicecall_snd_mgr_t *papp_snd)
485 CALL_ENG_DEBUG(ENG_DEBUG, "..\n");
487 __voicecall_snd_stop_vibration(papp_snd);
489 if (TRUE == __voicecall_snd_stop_alternate_sound(papp_snd)) {
490 CALL_ENG_DEBUG(ENG_DEBUG, "Alternate sound stopped \n");
493 #ifdef VOICE_CALL_RINGTONE_ELEVATOR
494 /*Stop Ring Elevator */
495 __voicecall_snd_cancel_ring_elevator(papp_snd);
498 CALL_ENG_DEBUG(ENG_DEBUG, "pmm_player = %d \n", papp_snd->pmm_player);
499 if (papp_snd->pmm_player != VOICE_CALL_SND_INVALID_PLAYER_HANDLE) {
501 MMPlayerStateType mmplayer_state = MM_PLAYER_STATE_NONE;
503 /*Sound Stop requested by the Application */
504 papp_snd->ringtone_sound_status = VOICE_CALL_SND_STATUS_STOP;
506 mm_player_get_state(papp_snd->pmm_player, &mmplayer_state);
508 CALL_ENG_DEBUG(ENG_DEBUG, "Callling mmplayer_stop, current mm state = %d, Player = %d\n", mmplayer_state, papp_snd->pmm_player);
509 if (MM_PLAYER_STATE_PLAYING == mmplayer_state || MM_PLAYER_STATE_PAUSED == mmplayer_state) {
510 ret_value = mm_player_stop(papp_snd->pmm_player);
511 if (MM_ERROR_NONE != ret_value) {
512 CALL_ENG_DEBUG(ENG_ERR, "mmplayer_stop failed: [0x%x]\n", ret_value);
516 CALL_ENG_DEBUG(ENG_DEBUG, "Callling mmplayer_unrealize, Player = %d\n", papp_snd->pmm_player);
517 ret_value = mm_player_unrealize(papp_snd->pmm_player);
518 if (MM_ERROR_NONE != ret_value) {
519 CALL_ENG_DEBUG(ENG_ERR, "mmplayer_unrealize failed: [0x%x]\n", ret_value);
522 CALL_ENG_DEBUG(ENG_DEBUG, "Callling mmplayer_destroy, Player = %d\n", papp_snd->pmm_player);
523 ret_value = mm_player_destroy(papp_snd->pmm_player);
524 if (MM_ERROR_NONE != ret_value) {
525 CALL_ENG_DEBUG(ENG_ERR, "mmplayer_destroy failed: [0x%x]\n", ret_value);
527 papp_snd->pmm_player = VOICE_CALL_SND_INVALID_PLAYER_HANDLE;
529 papp_snd->ringtone_sound_status = VOICE_CALL_SND_STATUS_STOPPED;
532 /* Stop All periodic Timers */
533 papp_snd->bvibration_then_melody = FALSE;
534 papp_snd->bincreasingmelody = FALSE;
536 /* Make the Current Sound Playing Call HAndle Invalid */
537 papp_snd->current_playing_call_handle = -1;
539 papp_snd->bmute_play = FALSE;
542 gboolean voicecall_snd_set_play_end_callback(voicecall_snd_mgr_t *papp_snd, voicecall_snd_callback psignal_play_end_cb, gpointer psignal_play_end_cb_data)
544 CALL_ENG_DEBUG(ENG_DEBUG, "signal_type = %d\n", papp_snd->signal_type);
546 if (VOICE_CALL_SND_STATUS_NONE == papp_snd->signal_sound_status) {
547 CALL_ENG_DEBUG(ENG_DEBUG, "No Signal Being Played\n");
551 papp_snd->psignal_play_end_cb = psignal_play_end_cb;
552 papp_snd->psignal_play_end_cb_data = psignal_play_end_cb_data;
558 * This function plays call sound
560 * @return Returns TRUE on success or FALSE on failure
561 * @param[in] papp_snd Handle to Sound Manager
563 gboolean voicecall_snd_is_signal_playing(voicecall_snd_mgr_t *papp_snd)
565 CALL_ENG_DEBUG(ENG_DEBUG, "Signal Sound Status : [%d] \n", papp_snd->signal_sound_status);
566 if ((papp_snd->pmm_signal_player != VOICE_CALL_SND_INVALID_SND_HANDLE) && (VOICE_CALL_SND_STATUS_PLAY == papp_snd->signal_sound_status)) {
567 CALL_ENG_DEBUG(ENG_DEBUG, "Signal is playing \n");
571 CALL_ENG_DEBUG(ENG_DEBUG, "Signal is not playing \n");
575 gboolean voicecall_snd_play_signal(voicecall_snd_mgr_t *papp_snd, voicecall_snd_callback psignal_play_end_cb, gpointer psignal_play_end_cb_data)
579 CALL_ENG_DEBUG(ENG_DEBUG, "signal_type = %d\n", papp_snd->signal_type);
581 if (VOICE_CALL_SIGNAL_NONE == papp_snd->signal_type) {
582 CALL_ENG_DEBUG(ENG_DEBUG, "No Signal Type Assinged\n");
587 Always stop the signal before playing another one
588 This is to make sure that previous signal sound is stopeed completely
590 voicecall_snd_stop_signal(papp_snd);
592 /*Set status, the signal play is being prepared */
593 papp_snd->signal_sound_status = VOICE_CALL_SND_STATUS_READY;
594 CALL_ENG_DEBUG(ENG_DEBUG, "papp_snd->signal_sound_status = %d\n", papp_snd->signal_sound_status);
596 papp_snd->psignal_play_end_cb = psignal_play_end_cb;
597 papp_snd->psignal_play_end_cb_data = psignal_play_end_cb_data;
599 if (TRUE == voicecall_snd_is_effect_playing(papp_snd)) {
600 CALL_ENG_DEBUG(ENG_ERR, "Stopping effect tone to play signal \n ");
601 voicecall_snd_stop_effect_tone(papp_snd);
604 CALL_ENG_DEBUG(ENG_ERR, "Changing path to play signal\n ");
605 voicecall_snd_change_mm_path(papp_snd, VOICE_CALL_MM_SIGNAL_TONE);
606 CALL_ENG_DEBUG(ENG_ERR, "Changing path to play signal Over\n ");
608 CALL_ENG_DEBUG(ENG_DEBUG, "signal_tone = %s\n", papp_snd->signal_tone);
609 ret_value = mm_sound_play_sound(papp_snd->signal_tone, VOLUME_TYPE_CALL, __voicecall_snd_mmplayer_signal_cb, papp_snd, &papp_snd->pmm_signal_player);
610 if (MM_ERROR_NONE != ret_value) {
611 papp_snd->signal_sound_status = VOICE_CALL_SND_STATUS_NONE;
612 CALL_ENG_DEBUG(ENG_ERR, "mm_sound_play_sound failed,Error: [0x%x]\n", ret_value);
614 CALL_ENG_DEBUG(ENG_DEBUG, "papp_snd->pmm_signal_player[%d]\n", papp_snd->pmm_signal_player);
615 papp_snd->signal_sound_status = VOICE_CALL_SND_STATUS_PLAY;
617 CALL_ENG_DEBUG(ENG_DEBUG, "Signal Play Started, Sound Status is: %d\n", papp_snd->signal_sound_status);
623 * This function stops the sound alert
626 * @param[in] papp_snd Handle to Sound Manager
628 void voicecall_snd_stop_signal(voicecall_snd_mgr_t *papp_snd)
632 CALL_ENG_DEBUG(ENG_DEBUG, "Sound Status: %d, papp_snd->pmm_signal_player(%d)\n", papp_snd->signal_sound_status, papp_snd->pmm_signal_player);
633 if (papp_snd->pmm_signal_player != VOICE_CALL_SND_INVALID_SND_HANDLE) {
634 if (VOICE_CALL_SND_STATUS_PLAY == papp_snd->signal_sound_status) {
635 papp_snd->signal_sound_status = VOICE_CALL_SND_STATUS_STOPPED;
637 CALL_ENG_DEBUG(ENG_DEBUG, "Stopping Signal Sound \n");
638 ret_value = mm_sound_stop_sound(papp_snd->pmm_signal_player);
639 if (MM_ERROR_NONE != ret_value) {
640 CALL_ENG_DEBUG(ENG_ERR, "mm_sound_stop_sound failed: [0x%x]\n", ret_value);
643 CALL_ENG_DEBUG(ENG_DEBUG, "Sound Play Over / Already Stopped \n");
645 papp_snd->pmm_signal_player = VOICE_CALL_SND_INVALID_SND_HANDLE;
647 if (papp_snd->psignal_play_end_cb != NULL) {
648 papp_snd->psignal_play_end_cb(papp_snd->psignal_play_end_cb_data);
649 papp_snd->psignal_play_end_cb = NULL;
650 papp_snd->psignal_play_end_cb_data = NULL;
653 CALL_ENG_DEBUG(ENG_DEBUG, "Application Sound Status:%d \n", papp_snd->signal_sound_status);
657 * This function sets the end signal of the given end cause type
660 * @param[in] papp_snd Handle to Sound Manager
661 * @param[in] end_cause_type Type of the end cause
663 void voicecall_snd_set_signal_type(voicecall_snd_mgr_t *papp_snd, voicecall_snd_signal_type_t signal_type)
665 char signal_tone[VOICE_CALL_SND_RINGTONE_PATH_LEN];
667 CALL_ENG_DEBUG(ENG_DEBUG, "Signal Type: %d\n", signal_type);
669 memset(signal_tone, 0, sizeof(signal_tone));
671 papp_snd->signal_type = signal_type;
672 switch (papp_snd->signal_type) {
673 case VOICE_CALL_SIGNAL_USER_BUSY_TONE:
675 _vc_core_util_strcpy(signal_tone, VOICE_CALL_SND_RINGTONE_PATH_LEN, VOICE_CALL_SND_USER_BUSY_SIGNAL_PATH);
678 case VOICE_CALL_SIGNAL_WRONG_NUMBER_TONE:
680 _vc_core_util_strcpy(signal_tone, VOICE_CALL_SND_RINGTONE_PATH_LEN, VOICE_CALL_SND_ERROR_SIGNAL_PATH);
683 case VOICE_CALL_SIGNAL_CALL_FAIL_TONE:
684 case VOICE_CALL_SIGNAL_NW_CONGESTION_TONE:
686 _vc_core_util_strcpy(signal_tone, VOICE_CALL_SND_RINGTONE_PATH_LEN, VOICE_CALL_SND_NW_CONGESTION_SIGNAL_PATH);
690 CALL_ENG_DEBUG(ENG_ERR, "Invalid Signal Type \n");
694 _vc_core_util_strcpy(papp_snd->signal_tone, sizeof(papp_snd->signal_tone), signal_tone);
698 static void __voicecall_snd_get_voice_path(voicecall_snd_mgr_t *papp_snd, int *voice_snd_path)
700 voicecall_audio_path_t tmp_audio_path;
703 CALL_ENG_DEBUG(ENG_DEBUG, "current path = %d\n", voicecall_snd_get_path_status(papp_snd));
705 switch (voicecall_snd_get_path_status(papp_snd)) {
706 case VOICE_CALL_SND_PATH_BT:
708 tmp_audio_path = VC_AUDIO_PATH_BLUETOOTH;
711 case VOICE_CALL_SND_PATH_SPEAKER:
713 tmp_audio_path = VC_AUDIO_PATH_SPK_PHONE;
716 case VOICE_CALL_SND_PATH_EARJACK:
718 tmp_audio_path = VC_AUDIO_PATH_HEADSET;
721 case VOICE_CALL_SND_PATH_RECEIVER:
724 tmp_audio_path = VC_AUDIO_PATH_HANDSET;
728 CALL_ENG_DEBUG(ENG_DEBUG, "Headset Status = %d\n", papp_snd->bcall_audio_status[VOICE_CALL_AUDIO_HEADSET]);
729 CALL_ENG_DEBUG(ENG_DEBUG, "Loud Speaker Status = %d\n", papp_snd->bcall_audio_status[VOICE_CALL_AUDIO_SPEAKER]);
731 /*Priority is given to Headset, incase both loudspeaker and headset is enabled */
732 if (TRUE == papp_snd->bcall_audio_status[VOICE_CALL_AUDIO_HEADSET]) {
733 tmp_audio_path = VC_AUDIO_PATH_BLUETOOTH;
734 } else if (TRUE == papp_snd->bcall_audio_status[VOICE_CALL_AUDIO_SPEAKER]) {
735 tmp_audio_path = VC_AUDIO_PATH_SPK_PHONE;
736 } else if (TRUE == papp_snd->bcall_audio_status[VOICE_CALL_AUDIO_EARJACK]) {
737 tmp_audio_path = VC_AUDIO_PATH_HEADSET;
739 tmp_audio_path = VC_AUDIO_PATH_HANDSET;
742 *voice_snd_path = tmp_audio_path;
744 CALL_ENG_DEBUG(ENG_DEBUG, "voice_snd_path = %d\n", *voice_snd_path);
748 void voicecall_snd_change_mm_path(voicecall_snd_mgr_t *papp_snd, voicecall_snd_mm_path_type_t mm_path_type)
750 call_vc_core_state_t *pcall_core = (call_vc_core_state_t *)papp_snd->pcall_core;
751 voicecall_engine_t *pcall_engine = pcall_core->pcall_engine;
756 int option_field = MM_SOUND_PATH_OPTION_AUTO_HEADSET_CONTROL;
758 CALL_ENG_DEBUG(ENG_DEBUG, "mm_path_type = %d\n", mm_path_type);
759 CALL_ENG_DEBUG(ENG_DEBUG, "papp_snd->current_path_type = %d\n", papp_snd->current_path_type);
762 switch (voicecall_snd_get_path_status(papp_snd)) {
763 case VOICE_CALL_SND_PATH_BT:
765 out_path = MM_SOUND_PATH_BTHEADSET;
766 in_path = MM_SOUND_PATH_BTMIC;
769 case VOICE_CALL_SND_PATH_SPEAKER:
771 out_path = MM_SOUND_PATH_SPK;
772 in_path = MM_SOUND_PATH_MIC;
773 option_field = MM_SOUND_PATH_OPTION_NONE;
776 case VOICE_CALL_SND_PATH_EARJACK:
777 case VOICE_CALL_SND_PATH_RECEIVER:
780 out_path = MM_SOUND_PATH_RECV;
781 in_path = MM_SOUND_PATH_MIC;
788 if (TRUE == papp_snd->bcall_audio_status[VOICE_CALL_AUDIO_HEADSET]) {
789 out_path = MM_SOUND_PATH_BTHEADSET;
790 } else if (TRUE == papp_snd->bcall_audio_status[VOICE_CALL_AUDIO_SPEAKER]) {
791 out_path = MM_SOUND_PATH_SPK;
792 option_field = MM_SOUND_PATH_OPTION_NONE;
793 } else { /*Normal Phone Reciever */
795 out_path = MM_SOUND_PATH_RECV;
798 if (TRUE == papp_snd->bcall_audio_status[VOICE_CALL_AUDIO_HEADSET]) {
799 in_path = MM_SOUND_PATH_BTMIC;
801 CALL_ENG_DEBUG(ENG_DEBUG, "Don't off the MIC. Mute only modem\n");
802 in_path = MM_SOUND_PATH_MIC;
806 CALL_ENG_DEBUG(ENG_DEBUG, "Out Path = %d, In Path = %d \n", out_path, in_path);
808 /* This patch is required : if voice path is not reset,
809 * the volume played for ringtone and signal tone will not be audible enough to hear
811 if ((VOICE_CALL_MM_VOICE == papp_snd->current_path_type) && ((VOICE_CALL_MM_RING_TONE == mm_path_type) || (VOICE_CALL_MM_SIGNAL_TONE == mm_path_type))) {
812 CALL_ENG_DEBUG(ENG_DEBUG, "Resetting Voice Path before changing to some other path \n");
815 /*Define Gain Type */
816 switch (mm_path_type) {
817 case VOICE_CALL_MM_ALERT_TONE:
819 gain_type = MM_SOUND_GAIN_CALLTONE;
820 in_path = MM_SOUND_PATH_NONE;
823 case VOICE_CALL_MM_SECOND_CALL_TONE:
825 /* MMFW sound request. always set it. */
826 gain_type = MM_SOUND_GAIN_KEYTONE; /* In case of earjack inserting, during second call */
827 in_path = MM_SOUND_PATH_NONE;
830 case VOICE_CALL_MM_RING_TONE:
832 int io_state = VC_INOUT_STATE_NONE;
834 gain_type = MM_SOUND_GAIN_RINGTONE;
835 in_path = MM_SOUND_PATH_NONE;
836 option_field = MM_SOUND_PATH_OPTION_SPEAKER_WITH_HEADSET;
838 voicecall_core_get_engine_state(pcall_engine, &io_state);
839 if ((voicecall_core_is_incoming_call_exists(pcall_engine)) && (io_state != VC_INOUT_STATE_INCOME_END)) {
840 out_path = MM_SOUND_PATH_SPK;
844 case VOICE_CALL_MM_MUTE_PLAY:
846 gain_type = MM_SOUND_GAIN_RINGTONE;
847 in_path = MM_SOUND_PATH_NONE;
848 out_path = MM_SOUND_PATH_HEADSET;
851 case VOICE_CALL_MM_RESET:
853 gain_type = MM_SOUND_GAIN_VOICECALL;
854 in_path = MM_SOUND_PATH_NONE;
855 out_path = MM_SOUND_PATH_NONE;
858 case VOICE_CALL_MM_SIGNAL_TONE:
860 gain_type = MM_SOUND_GAIN_CALLTONE;
861 in_path = MM_SOUND_PATH_NONE;
864 case VOICE_CALL_MM_RECORD:
866 gain_type = MM_SOUND_GAIN_VOICECALL;
869 case VOICE_CALL_MM_VOICE:
871 gain_type = MM_SOUND_GAIN_VOICECALL;
875 CALL_ENG_DEBUG(ENG_DEBUG, "Invalid MM Path Type: %d\n", mm_path_type);
878 if (papp_snd->bsound_cm_state == TRUE) {
879 CALL_ENG_DEBUG(ENG_DEBUG, "mm_sound_set_path- Gain:[%d],OutPath:[%d],InPath:[%d],option:[%d] \n", gain_type, out_path, in_path, option_field);
880 CALL_ENG_KPI("mm_sound_set_path start");
881 mm_error = mm_sound_set_path(gain_type, out_path, in_path, option_field);
882 CALL_ENG_KPI("mm_sound_set_path done");
883 if (mm_error != MM_ERROR_NONE) {
884 CALL_ENG_DEBUG(ENG_ERR, "MM Path Change Failed,mm_error = [0x%x]\n", mm_error);
886 papp_snd->current_path_type = mm_path_type;
888 CALL_ENG_DEBUG(ENG_ERR, "** we can't change mm path. check it. **** \n");
894 * This function changes the sound path according to the current status
897 * @param[in] papp_snd Handle to Sound Manager
899 void voicecall_snd_change_path(voicecall_snd_mgr_t *papp_snd)
901 CALL_ENG_DEBUG(ENG_DEBUG, "..\n");
902 CALL_ENG_KPI("voicecall_snd_change_path start");
903 call_vc_core_state_t *pcall_core = (call_vc_core_state_t *)papp_snd->pcall_core;
906 if (voicecall_snd_get_path_status(papp_snd) == VOICE_CALL_SND_PATH_BT) {
907 int bt_sco_status = 0;
909 bt_sco_status = _vc_bt_get_bt_sco_status();
910 if (FALSE == bt_sco_status) {
911 gboolean bevent_wait = FALSE;
913 CALL_ENG_DEBUG(ENG_ERR, "BT Sco is OFF, request BT for path change\n");
914 bevent_wait = voicecall_core_get_status(pcall_core, CALL_VC_CORE_FLAG_BT_EVENT_WAITING);
915 if (FALSE == bevent_wait) {
916 /*Request BT for change path to headset */
917 _vc_bt_request_switch_headset_path(pcall_core, TRUE);
919 CALL_ENG_DEBUG(ENG_ERR, "bevent_wait = %d, waiting for BT Event \n", bevent_wait);
922 CALL_ENG_DEBUG(ENG_DEBUG, "BT SCO is open, Change the path to sync with BT Path\n");
923 voicecall_snd_change_path_real(papp_snd);
926 CALL_ENG_DEBUG(ENG_DEBUG, "new PATH is not BT.");
927 gboolean bevent_wait = FALSE;
929 bevent_wait = voicecall_core_get_status(pcall_core, CALL_VC_CORE_FLAG_BT_EVENT_WAITING);
930 if (FALSE == bevent_wait) {
931 /*Request BT for change path to headset */
932 voicecall_snd_change_path_real(papp_snd);
934 CALL_ENG_DEBUG(ENG_ERR, "bevent_wait = %d, waiting for BT Event \n", bevent_wait);
938 if ((TRUE == _vc_bt_is_bt_connected(pcall_core))
939 && (TRUE == papp_snd->bcall_audio_status[VOICE_CALL_AUDIO_HEADSET])) {
941 int bt_sco_status = 0;
943 bt_sco_status = _vc_bt_get_bt_sco_status();
944 if (FALSE == bt_sco_status) {
945 gboolean bevent_wait = FALSE;
947 CALL_ENG_DEBUG(ENG_ERR, "BT Sco is OFF, request BT for path change\n");
948 bevent_wait = voicecall_core_get_status(pcall_core, CALL_VC_CORE_FLAG_BT_EVENT_WAITING);
949 if (FALSE == bevent_wait) {
950 /*Request BT for change path to headset */
951 _vc_bt_request_switch_headset_path(pcall_core, TRUE);
953 CALL_ENG_DEBUG(ENG_ERR, "bevent_wait = %d, waiting for BT Event \n", bevent_wait);
956 CALL_ENG_DEBUG(ENG_DEBUG, "BT SCO is open, Change the path to sync with BT Path\n");
957 voicecall_snd_change_path_real(papp_snd);
959 } else if ((TRUE == _vc_bt_is_bt_connected(pcall_core)) && (TRUE == voicecall_core_get_status(pcall_core, CALL_VC_CORE_FLAG_ACCEPT_BY_BT))) {
960 /*Request BT for change path to headset, actual voice path will be changed in the response from BT */
961 CALL_ENG_DEBUG(ENG_ERR, "Headset Connected Call is accepted by BT, requesting BT to change path\n");
962 _vc_bt_request_switch_headset_path(pcall_core, TRUE);
964 CALL_ENG_DEBUG(ENG_DEBUG, "No Headset connected/Headset connected call accepted by Phone, Normal Path Change..\n");
965 voicecall_snd_change_path_real(papp_snd);
968 CALL_ENG_KPI("voicecall_snd_change_path done");
972 void voicecall_snd_change_path_real(voicecall_snd_mgr_t *papp_snd)
974 CALL_ENG_DEBUG(ENG_DEBUG, "..\n");
976 /* Change the mm sound path */
977 voicecall_snd_change_mm_path(papp_snd, VOICE_CALL_MM_VOICE);
979 voicecall_snd_change_modem_path(papp_snd);
982 void voicecall_snd_change_modem_path(voicecall_snd_mgr_t *papp_snd)
984 CALL_ENG_DEBUG(ENG_DEBUG, "..\n");
985 call_vc_core_state_t *pcall_core = (call_vc_core_state_t *)papp_snd->pcall_core;
987 int audio_path = VC_AUDIO_PATH_HANDSET;
989 /* Change the tapi sound path */
990 __voicecall_snd_get_voice_path(papp_snd, &audio_path);
992 if (FALSE == voicecall_core_change_audio_path(pcall_core->pcall_engine, audio_path)) {
993 CALL_ENG_DEBUG(ENG_ERR, "TAPI Audio Change Path ERROR \n");
998 * This function sets the status of the given call audio type
1001 * @param[in] papp_snd Handle to Sound Manager
1002 * @param[in] snd_audio_type Type of the Device to be changed
1003 * @param[in] status Status, TRUE - Enable, FALSE -Disable
1005 void voicecall_snd_set_status(voicecall_snd_mgr_t *papp_snd, voicecall_snd_audio_type_t snd_audio_type, gboolean status)
1007 CALL_ENG_DEBUG(ENG_DEBUG, "snd_audio_type:[%d], status:[%d]\n", snd_audio_type, status);
1009 /*if BT headset is connected , switch off loud speaker - it will be reflectd in the next sound path change */
1010 if (((VOICE_CALL_AUDIO_HEADSET == snd_audio_type) || (VOICE_CALL_AUDIO_EARJACK == snd_audio_type)) && (TRUE == status)) {
1011 CALL_ENG_DEBUG(ENG_DEBUG, "loud speaker status is to be FALSE\n");
1012 papp_snd->bcall_audio_status[VOICE_CALL_AUDIO_SPEAKER] = FALSE;
1014 papp_snd->bcall_audio_status[snd_audio_type] = status;
1018 * This function returns the current status of the given call audio type
1020 * @return Returns TRUE if given call audio type is enables or FALSE otherwise
1021 * @param[in] papp_snd Handle to Sound Manager
1022 * @param[in] snd_audio_type Type of the Device to be changed
1024 gboolean voicecall_snd_get_status(voicecall_snd_mgr_t *papp_snd, voicecall_snd_audio_type_t snd_audio_type)
1026 CALL_ENG_DEBUG(ENG_DEBUG, "Status[%d] = %d \n", snd_audio_type, papp_snd->bcall_audio_status[snd_audio_type]);
1027 return papp_snd->bcall_audio_status[snd_audio_type];
1032 * This function sets the status of the given call audio type
1035 * @param[in] papp_snd Handle to Sound Manager
1036 * @param[in] snd_audio_type Type of the Device to be changed
1037 * @param[in] status Status, TRUE - Enable, FALSE -Disable
1039 void voicecall_snd_set_path_status(voicecall_snd_mgr_t *papp_snd, voicecall_snd_path_t path)
1041 CALL_ENG_DEBUG(ENG_DEBUG, "current path:[%d], new path:[%d]\n", papp_snd->current_snd_path, path);
1043 papp_snd->old_snd_path = papp_snd->current_snd_path;
1044 papp_snd->current_snd_path = path;
1047 voicecall_snd_path_t voicecall_snd_get_path_status(voicecall_snd_mgr_t *papp_snd)
1049 CALL_ENG_DEBUG(ENG_DEBUG, "old path:[%d], current path:[%d]\n", papp_snd->old_snd_path, papp_snd->current_snd_path);
1051 return papp_snd->current_snd_path;
1056 * This function sets the volume level for the given volume alert type
1059 * @param[in] papp_snd Handle to Sound Manager
1060 * @param[in] vol_alert_type volume alert type #voicecall_snd_volume_alert_type_t
1061 * @param[in] volume_level volume level to be set
1063 void voicecall_snd_set_volume(voicecall_snd_mgr_t *papp_snd, voicecall_snd_volume_alert_type_t vol_alert_type, int volume_level)
1065 CALL_ENG_DEBUG(ENG_DEBUG, "volume_level = %d \n", volume_level);
1066 call_vc_core_state_t *pcall_core = (call_vc_core_state_t *)papp_snd->pcall_core;
1068 switch (vol_alert_type) {
1069 case VOICE_CALL_VOL_TYPE_RINGTONE:
1074 if (VOICE_CALL_SND_INVALID_PLAYER_HANDLE == papp_snd->pmm_player) {
1075 CALL_ENG_DEBUG(ENG_ERR, "Invalid MM Player Handle \n");
1079 /* Make Increasing Melody flag to FALSE, so melody volume will not be increased when volume it adjusted by user during increasing melody */
1080 papp_snd->bincreasingmelody = FALSE;
1082 volume = volume_level;
1084 ret_value = mm_sound_volume_set_value(VOLUME_TYPE_RINGTONE, volume);
1085 if (MM_ERROR_NONE != ret_value) {
1086 CALL_ENG_DEBUG(ENG_ERR, "mmplayer_set_volume failed Error: [0x%x]\n", ret_value);
1088 #ifdef VOICE_CALL_RINGTONE_ELEVATOR
1089 __voicecall_snd_cancel_ring_elevator(papp_snd);
1093 case VOICE_CALL_VOL_TYPE_VOICE:
1095 int incall_vol_level = 0;
1098 if (VOICE_CALL_VOL_LEVEL_1 >= volume_level) {
1099 incall_vol_level = VOICE_CALL_VOL_LEVEL_1;
1100 } else if (VOICE_CALL_VOL_LEVEL_6 < volume_level) {
1101 incall_vol_level = VOICE_CALL_VOL_LEVEL_6;
1103 incall_vol_level = volume_level;
1106 __voicecall_snd_get_voice_path(papp_snd, &audio_path);
1108 _vc_core_util_set_call_volume(volume_level);
1110 /* MODEM want to get volume level as 0~5, not a 1~6. So pass -1 value */
1111 if (FALSE == voicecall_core_set_audio_volume(pcall_core->pcall_engine, audio_path, (incall_vol_level-1))) {
1112 CALL_ENG_DEBUG(ENG_DEBUG, "voicecall_doc_set_audio_volume failed\n");
1116 case VOICE_CALL_VOL_TYPE_HEADSET:
1118 int bt_vol_level = 0;
1119 if (TRUE == voicecall_core_get_status(pcall_core, CALL_VC_CORE_FLAG_VOL_CHNGD_BYBT)) {
1120 CALL_ENG_DEBUG(ENG_DEBUG, "BT Requested Volume flag is enabled, not sending response \n");
1121 voicecall_core_set_status(pcall_core, CALL_VC_CORE_FLAG_VOL_CHNGD_BYBT, FALSE);
1123 bt_vol_level = volume_level;
1124 CALL_ENG_DEBUG(ENG_DEBUG, "bt_vol_level = %d\n", bt_vol_level);
1126 _vc_bt_send_response_to_bt(pcall_core, BT_AG_RES_SPK_GAIN, bt_vol_level, NULL);
1132 CALL_ENG_DEBUG(ENG_DEBUG, "No Actions Defined for the volume alert type: %d \n", vol_alert_type);
1138 * This function retreives the volume according to the given volume alert type
1140 * @return current volume level
1141 * @param[in] papp_snd Handle to Sound Manager
1142 * @param[in] vol_alert_type volume alert type #voicecall_snd_volume_alert_type_t
1144 int voicecall_snd_get_volume(voicecall_snd_mgr_t *papp_snd, voicecall_snd_volume_alert_type_t vol_alert_type)
1146 CALL_ENG_DEBUG(ENG_DEBUG, "\n");
1147 call_vc_core_state_t *pcall_core = (call_vc_core_state_t *)papp_snd->pcall_core;
1149 switch (vol_alert_type) {
1150 case VOICE_CALL_VOL_TYPE_RINGTONE:
1153 unsigned int volume = 0;
1155 ret_val = mm_sound_volume_get_value(VOLUME_TYPE_RINGTONE, &volume);
1156 if (MM_ERROR_NONE != ret_val) {
1157 CALL_ENG_DEBUG(ENG_DEBUG, "ret_val = [0x%x]\n", ret_val);
1158 return VC_INVALID_VOLUME;
1160 CALL_ENG_DEBUG(ENG_DEBUG, "MM Volume Level : %d\n", volume);
1166 case VOICE_CALL_VOL_TYPE_VOICE:
1168 return _vc_core_util_get_call_volume();
1171 case VOICE_CALL_VOL_TYPE_HEADSET:
1173 _vc_bt_send_response_to_bt(pcall_core, BT_AG_RES_HEADSET_VOL, 0, NULL);
1174 return VC_INVALID_VOLUME; /*Return Invalid Volume level as default */
1178 return VC_INVALID_VOLUME; /*Return Invalid Volume level as default */
1181 return VC_INVALID_VOLUME;
1184 gboolean voicecall_snd_get_alternate_play(voicecall_snd_mgr_t *papp_snd)
1186 return papp_snd->balternate_play;
1189 static gboolean __voicecall_snd_start_melody(voicecall_snd_mgr_t *papp_snd, gboolean bis_increasing, int call_handle)
1191 char *setting_file_path = NULL;
1192 char ringtone_path[VOICE_CALL_SND_RINGTONE_PATH_LEN] = { 0, };
1193 call_vc_call_objectinfo_t callobject_info;
1194 voicecall_contact_info_t ct_info;
1196 call_vc_core_state_t *pcall_core = (call_vc_core_state_t *)papp_snd->pcall_core;
1198 CALL_ENG_DEBUG(ENG_DEBUG, "call_handle = %d\n", call_handle);
1200 CALL_ENG_DEBUG(ENG_DEBUG, "Contact ring_tone_path = [%s]\n", papp_snd->ring_tone);
1202 if (strlen(papp_snd->ring_tone) <= 0) {
1203 setting_file_path = vconf_get_str(VCONFKEY_SETAPPL_CALL_RINGTONE_PATH_STR);
1204 if ((setting_file_path == NULL) || (strlen(setting_file_path) <= 0) ||
1205 (FALSE == g_file_test(setting_file_path, G_FILE_TEST_EXISTS)))
1207 CALL_ENG_DEBUG(ENG_ERR, "setting ring tone path is invalid : [%s]\n", setting_file_path);
1208 /*snprintf(ringtone_path, sizeof(ringtone_path), "file://%s", VOICE_CALL_SND_DEFAULT_RINGTONE_PATH);*/
1211 snprintf(ringtone_path, sizeof(ringtone_path), "file://%s", setting_file_path);
1214 CALL_ENG_DEBUG(ENG_DEBUG, "Ringtone From Settings : %s\n", ringtone_path);
1215 _vc_core_util_strcpy(papp_snd->ring_tone, sizeof(papp_snd->ring_tone), ringtone_path);
1218 /* Create MM Player */
1219 papp_snd->pmm_player = VOICE_CALL_SND_INVALID_PLAYER_HANDLE;
1220 __voicecall_snd_create_player(papp_snd, &papp_snd->pmm_player, VOICE_CALL_PLAY_TYPE_RINGTONE);
1222 papp_snd->ringtone_sound_status = VOICE_CALL_SND_STATUS_READY;
1227 static gboolean __voicecall_snd_create_player(voicecall_snd_mgr_t *papp_snd, MMHandleType * pPlayer, voicecall_snd_play_type_t play_type)
1230 MMMessageCallback callback = NULL;
1231 char *mmf_error = NULL;
1233 CALL_ENG_DEBUG(ENG_DEBUG, "Start..\n");
1235 if (*pPlayer != VOICE_CALL_SND_INVALID_SND_HANDLE) {
1236 CALL_ENG_DEBUG(ENG_DEBUG, "Player = %d \n", *pPlayer);
1237 mm_player_destroy(*pPlayer);
1238 *pPlayer = VOICE_CALL_SND_INVALID_SND_HANDLE;
1241 ret_value = mm_player_create(pPlayer);
1242 if (MM_ERROR_NONE != ret_value || *pPlayer == VOICE_CALL_SND_INVALID_SND_HANDLE) {
1243 CALL_ENG_DEBUG(ENG_ERR, "mmplayer_create failed , Error:[0x%x]\n", ret_value);
1246 CALL_ENG_DEBUG(ENG_DEBUG, "*pPlayer: %d\n", *pPlayer);
1248 switch (play_type) {
1249 /*Set the MM Player Attributes according to the Display Priority Type */
1250 case VOICE_CALL_PLAY_TYPE_RINGTONE:
1252 mm_player_set_attribute(*pPlayer, &mmf_error,
1253 "sound_volume_type", MM_SOUND_VOLUME_TYPE_RINGTONE,
1254 "profile_uri", papp_snd->ring_tone, VOICE_CALL_SND_RINGTONE_PATH_LEN,
1255 "profile_play_count", -1, "sound_route", MM_AUDIOROUTE_USE_EXTERNAL_SETTING, "sound_spk_out_only", TRUE, "sound_stop_when_unplugged", FALSE, NULL);
1256 callback = __voicecall_snd_mmplayer_cb;
1264 mm_player_set_message_callback(*pPlayer, callback, papp_snd);
1266 ret_value = mm_player_realize(*pPlayer);
1267 if (MM_ERROR_NONE != ret_value) {
1268 CALL_ENG_DEBUG(ENG_ERR, "mmplayer_realize failed , Error:[0x%x]\n", ret_value);
1272 CALL_ENG_DEBUG(ENG_DEBUG, "Finish..\n");
1276 static gboolean __voicecall_snd_play_melody(voicecall_snd_mgr_t *papp_snd, gboolean bis_increasing)
1278 CALL_ENG_DEBUG(ENG_DEBUG, "..\n");
1280 if (strlen(papp_snd->ring_tone) > 0) {
1281 int mm_error = MM_ERROR_NONE;
1283 mm_error = mm_player_start(papp_snd->pmm_player);
1284 if (MM_ERROR_NONE != mm_error) {
1285 CALL_ENG_DEBUG(ENG_ERR, "mm_player_start failed,Error: [0x%x]\n", mm_error);
1287 if (TRUE == bis_increasing) {
1288 papp_snd->bincreasingmelody = TRUE;
1289 g_timeout_add(VOICE_CALL_SND_INCREMENT_TIMER_INTERVAL, __voicecall_snd_increasing_melody_cb, (gpointer) papp_snd);
1291 #ifdef VOICE_CALL_RINGTONE_ELEVATOR
1292 CALL_ENG_DEBUG(ENG_DEBUG, "Starting Ringtone Elevator\n");
1293 /*Start only when the volume is not incremental volume */
1294 __voicecall_snd_start_ring_elevator(papp_snd);
1298 papp_snd->ringtone_sound_status = VOICE_CALL_SND_STATUS_PLAY;
1302 CALL_ENG_DEBUG(ENG_ERR, "Ringtone is empty(Problem) \n");
1308 static int __voicecall_snd_mmplayer_cb(int message, void *data, void *user_data)
1310 voicecall_snd_mgr_t *papp_snd = (voicecall_snd_mgr_t *)user_data;
1311 if (VOICE_CALL_SND_STATUS_PLAY != papp_snd->ringtone_sound_status) {
1312 CALL_ENG_DEBUG(ENG_DEBUG, "Sound Play stopped by application, callback not handled \n");
1317 case MM_MESSAGE_END_OF_STREAM:
1319 CALL_ENG_DEBUG(ENG_DEBUG, "Ringtone loop count is supported by MMF , need not restart the ringtone \n");
1329 gboolean __voicecall_snd_mmplayer_signal_end_callback_idle_cb(gpointer pdata)
1331 voicecall_snd_mgr_t *papp_snd = (voicecall_snd_mgr_t *)pdata;
1333 CALL_ENG_DEBUG(ENG_DEBUG, " \n");
1335 /*Callback needs to be called, only when the tone is played completely and it is ended
1336 if the signal is explictly stopped, don't call the user callback */
1337 if (papp_snd->psignal_play_end_cb != NULL) {
1338 CALL_ENG_DEBUG(ENG_DEBUG, "Calling user callback \n");
1339 papp_snd->psignal_play_end_cb(papp_snd->psignal_play_end_cb_data);
1340 papp_snd->psignal_play_end_cb = NULL;
1341 papp_snd->psignal_play_end_cb_data = NULL;
1347 static void __voicecall_snd_mmplayer_signal_cb(gpointer puser_data)
1349 voicecall_snd_mgr_t *papp_snd = (voicecall_snd_mgr_t *)puser_data;
1351 CALL_ENG_DEBUG(ENG_DEBUG, "Sound Play Over \n");
1353 if (papp_snd->signal_sound_status != VOICE_CALL_SND_STATUS_PLAY) {
1354 CALL_ENG_DEBUG(ENG_DEBUG, "Sound Play already stopped by application \n");
1358 papp_snd->signal_sound_status = VOICE_CALL_SND_STATUS_STOPPED;
1360 __voicecall_snd_mmplayer_signal_end_callback_idle_cb(papp_snd);
1363 static gboolean __voicecall_snd_increasing_melody_cb(void *data)
1365 voicecall_snd_mgr_t *papp_snd = (voicecall_snd_mgr_t *)data;
1367 int set_volume_level = VOICE_CALL_VOL_LEVEL_1;
1369 if (FALSE == papp_snd->bincreasingmelody) {
1370 CALL_ENG_DEBUG(ENG_DEBUG, "Already Deactivated\n");
1374 if (FALSE == vconf_get_int(VCONFKEY_SETAPPL_PROFILE_CURRENT_CALL_VOLUME_INT, &set_volume_level)) {
1375 CALL_ENG_DEBUG(ENG_ERR, "settings read failed Error: %d\n", ret_value);
1378 if ((set_volume_level != 0) && (papp_snd->increment_melody_value <= set_volume_level)) {
1381 papp_snd->increment_melody_value++;
1383 volume_val = papp_snd->increment_melody_value;
1384 ret_value = mm_sound_volume_set_value(VOLUME_TYPE_RINGTONE, volume_val);
1386 if (MM_ERROR_NONE != ret_value) {
1387 CALL_ENG_DEBUG(ENG_ERR, "Set Volume Error: [0x%x]\n", ret_value);
1390 CALL_ENG_DEBUG(ENG_DEBUG, "Increasing Melody Continuing, Current Increased Melody : %d\n", papp_snd->increment_melody_value);
1391 if (papp_snd->increment_melody_value >= set_volume_level) {
1392 CALL_ENG_DEBUG(ENG_DEBUG, "Increasing Melody Ended\n");
1399 CALL_ENG_DEBUG(ENG_DEBUG, "Increasing Melody Ended\n");
1403 static void __voicecall_snd_start_vibration(voicecall_snd_mgr_t *papp_snd)
1405 /*First Stop the previous Vibration and then start it again */
1407 CALL_ENG_DEBUG(ENG_DEBUG, "..\n");
1410 int haptic_vib_type = -1;
1412 papp_snd->bvibration = FALSE;
1414 papp_snd->vibration_handle = device_haptic_open(DEV_IDX_0, 0);
1416 CALL_ENG_DEBUG(ENG_DEBUG, "srart vibration device_handle=%d \n", papp_snd->vibration_handle);
1418 if (papp_snd->vibration_handle < 0) {
1419 CALL_ENG_DEBUG(ENG_DEBUG, "device_haptic_open error \n");
1423 if (vconf_get_int(VCONFKEY_SETAPPL_CALL_VIBRATION_PATTERN_INT, &vib_type)) {
1424 CALL_ENG_DEBUG(ENG_ERR, "VCONFKEY_SETAPPL_CALL_VIBRATION_PATTERN_INT vconf_get_bool failed.\n");
1426 if (vconf_get_int(VCONFKEY_SETAPPL_NOTI_VIBRATION_LEVEL_INT, &vib_level)) {
1427 CALL_ENG_DEBUG(ENG_ERR, "VCONFKEY_SETAPPL_NOTI_VIBRATION_LEVEL_INT vconf_get_bool failed.\n");
1434 case SETTING_CALL_ALERT_VIB_TYPE1:
1435 haptic_vib_type = EFFCTVIBE_INCOMING_CALL01;
1437 case SETTING_CALL_ALERT_VIB_TYPE2:
1438 haptic_vib_type = EFFCTVIBE_INCOMING_CALL02;
1440 case SETTING_CALL_ALERT_VIB_TYPE3:
1441 haptic_vib_type = EFFCTVIBE_INCOMING_CALL03;
1444 haptic_vib_type = EFFCTVIBE_INCOMING_CALL01;
1447 if (device_haptic_play_pattern(papp_snd->vibration_handle, haptic_vib_type, 255, vib_level)) {
1448 CALL_ENG_DEBUG(ENG_DEBUG, "device_haptic_play_pattern error \n");
1451 if (device_haptic_play_monotone(papp_snd->vibration_handle, 60000)) {
1452 CALL_ENG_DEBUG(ENG_DEBUG, "device_haptic_play_monotone error \n");
1456 papp_snd->bvibration = TRUE;
1460 static gboolean __voicecall_snd_vib_then_melody_cb(void *data)
1462 voicecall_snd_mgr_t *papp_snd = (voicecall_snd_mgr_t *)data;
1463 call_vc_core_state_t *pcall_core = (call_vc_core_state_t *)papp_snd->pcall_core;
1465 __voicecall_snd_stop_vibration(papp_snd);
1467 if (FALSE == papp_snd->bvibration_then_melody) {
1471 if (FALSE == voicecall_core_is_connected_call_exist(pcall_core->pcall_engine)) {
1474 int set_volume_level = 0;
1477 vconf_get_int(VCONFKEY_SETAPPL_PROFILE_CURRENT_CALL_VOLUME_INT, &set_volume_level);
1479 volume_val = set_volume_level;
1481 ret_value = mm_sound_volume_set_value(VOLUME_TYPE_RINGTONE, volume_val);
1483 CALL_ENG_DEBUG(ENG_ERR, "__voicecall_snd_vib_then_melody_cb() : volume = %d\n", volume_val);
1485 __voicecall_snd_play_melody(papp_snd, FALSE);
1491 static void __voicecall_snd_stop_vibration(voicecall_snd_mgr_t *papp_snd)
1493 CALL_ENG_DEBUG(ENG_DEBUG, "..\n");
1495 if (TRUE == papp_snd->bvibration) {
1496 CALL_ENG_DEBUG(ENG_DEBUG, "Stopping Vibration , handle=%d \n", papp_snd->vibration_handle);
1498 if (device_haptic_stop_play(papp_snd->vibration_handle)) {
1499 CALL_ENG_DEBUG(ENG_DEBUG, "device_haptic_play_stop error \n");
1503 if (device_haptic_close(papp_snd->vibration_handle)) {
1504 CALL_ENG_DEBUG(ENG_DEBUG, "device_haptic_close error \n");
1508 papp_snd->vibration_handle = -1;
1510 papp_snd->bvibration = FALSE;
1512 CALL_ENG_DEBUG(ENG_DEBUG, "bvibration is not enabled.\n");
1518 * This function is callback of mm_sound_route_add_callback
1520 * @param[in] data call user data
1521 * policy system audio route policy which has applied.
1523 void voicecall_snd_route_change_cb(void *data, system_audio_route_t policy)
1526 CALL_ENG_DEBUG(ENG_ERR, "System audio route policy has changed");
1527 if (policy != SYSTEM_AUDIO_ROUTE_POLICY_IGNORE_A2DP) {
1528 error_code = mm_sound_route_set_system_policy(SYSTEM_AUDIO_ROUTE_POLICY_IGNORE_A2DP);
1530 CALL_ENG_DEBUG(ENG_ERR, "mm_sound_route_set_system_policy failed. error_code:[0x%x]\n", error_code);
1536 * This function unregisters the application with the sound conflict manager
1539 * @param[in] papp_snd Handle to Sound Manager
1541 void voicecall_snd_register_cm(voicecall_snd_mgr_t *papp_snd)
1545 CALL_ENG_DEBUG(ENG_DEBUG, "current bsound_cm_state:[%d]. \n", papp_snd->bsound_cm_state);
1547 if (FALSE == papp_snd->bsound_cm_state) {
1548 CALL_ENG_KPI("mm_session_init start");
1549 error_code = mm_session_init(MM_SESSION_TYPE_CALL);
1550 CALL_ENG_KPI("mm_session_init done");
1552 CALL_ENG_DEBUG(ENG_ERR, "mm_session_init failed. error_code:[0x%x]\n", error_code);
1555 error_code = mm_sound_route_get_system_policy(&papp_snd->backup_route_policy);
1557 CALL_ENG_DEBUG(ENG_ERR, "mm_sound_route_get_system_policy failed. error_code:[0x%x]\n", error_code);
1560 error_code = mm_sound_route_set_system_policy(SYSTEM_AUDIO_ROUTE_POLICY_IGNORE_A2DP);
1562 CALL_ENG_DEBUG(ENG_ERR, "mm_sound_route_set_system_policy failed. error_code:[0x%x]\n", error_code);
1565 error_code = mm_sound_route_add_change_callback(voicecall_snd_route_change_cb, NULL);
1567 CALL_ENG_DEBUG(ENG_ERR, "mm_sound_route_add_change_callback failed. error_code:[0x%x]\n", error_code);
1571 papp_snd->bsound_cm_state = TRUE;
1577 * This function unregisters the application from the sound conflict manager
1580 * @param[in] papp_snd Handle to Sound Manager
1582 void voicecall_snd_unregister_cm(voicecall_snd_mgr_t *papp_snd)
1586 CALL_ENG_DEBUG(ENG_DEBUG, "current bsound_cm_state:[%d]. \n", papp_snd->bsound_cm_state);
1588 if (TRUE == papp_snd->bsound_cm_state) {
1589 /*Reset the Path when the app is closed - safety code */
1590 voicecall_snd_change_mm_path(papp_snd, VOICE_CALL_MM_RESET);
1591 CALL_ENG_DEBUG(ENG_DEBUG, "Sound Path reset to Default\n");
1593 papp_snd->bsound_cm_state = FALSE;
1595 CALL_ENG_DEBUG(ENG_DEBUG, "Unregistering Sound CM\n");
1596 error_code = mm_session_finish();
1598 CALL_ENG_DEBUG(ENG_ERR, "mm_session_finish failed. error_code:[0x%x]\n", error_code);
1600 error_code = mm_sound_route_remove_change_callback();
1602 CALL_ENG_DEBUG(ENG_ERR, "mm_sound_route_remove_change_callback failed. error_code:[0x%x]\n", error_code);
1604 error_code = mm_sound_route_set_system_policy(papp_snd->backup_route_policy);
1606 CALL_ENG_DEBUG(ENG_ERR, "mm_sound_route_set_system_policy failed. error_code:[0x%x]\n", error_code);
1609 /*Set to Defaults */
1610 voicecall_snd_set_to_defaults(papp_snd);
1614 gboolean __voicecall_snd_effect_idle_cb(gpointer puser_data)
1616 voicecall_snd_mgr_t *papp_snd = (voicecall_snd_mgr_t *)puser_data;
1617 call_vc_core_state_t *pcall_core = (call_vc_core_state_t *)papp_snd->pcall_core;
1619 papp_snd->effect_tone_status = VOICE_CALL_SND_STATUS_NONE;
1620 CALL_ENG_DEBUG(ENG_DEBUG, "papp_snd->effect_tone_status = %d\n", papp_snd->effect_tone_status);
1622 /*If connected call exists then change the audio path */
1623 if ((TRUE == voicecall_core_is_connected_call_exist(pcall_core->pcall_engine)) || (TRUE == voicecall_core_is_outgoing_call_exists(pcall_core->pcall_engine))) {
1624 CALL_ENG_DEBUG(ENG_DEBUG, "Connected call exists, changing path at the end of effect tone \n");
1626 CALL_ENG_DEBUG(ENG_ERR, "papp_snd->signal_sound_status = %d \n", papp_snd->signal_sound_status);
1627 /*Check the signal play status, if signal is being prepared / played, don't change the path */
1628 if (VOICE_CALL_SND_STATUS_NONE == papp_snd->signal_sound_status) {
1629 voicecall_snd_change_path(papp_snd);
1631 CALL_ENG_DEBUG(ENG_ERR, "Signal is playing, skipping path change, it will be done at the end of signal \n");
1634 CALL_ENG_DEBUG(ENG_DEBUG, "non connected call\n");
1636 CALL_ENG_DEBUG(ENG_DEBUG, "Over\n");
1640 static void __voicecall_snd_effect_cb(gpointer puser_data)
1642 voicecall_snd_mgr_t *papp_snd = (voicecall_snd_mgr_t *)puser_data;
1644 CALL_ENG_DEBUG(ENG_DEBUG, "effect_tone_status = %d, Calling Idle\n", papp_snd->effect_tone_status);
1645 papp_snd->effect_tone_status = VOICE_CALL_SND_STATUS_STOPPED;
1647 __voicecall_snd_effect_idle_cb(papp_snd);
1648 CALL_ENG_DEBUG(ENG_DEBUG, "End : papp_snd->effect_tone_status = %d\n", papp_snd->effect_tone_status);
1651 gboolean voicecall_snd_play_effect_tone(voicecall_snd_mgr_t *papp_snd, int effect_type)
1653 int error_code = -1;
1654 gboolean bzuhause = FALSE;
1655 gboolean bstatus = FALSE;
1656 call_vc_core_state_t *pcall_core = (call_vc_core_state_t *)papp_snd->pcall_core;
1658 CALL_ENG_DEBUG(ENG_DEBUG, "effect type:[%d] \n", effect_type);
1660 switch (effect_type) {
1661 case VOICE_CALL_SND_EFFECT_CALL_CONNECT:
1663 CALL_ENG_KPI("voicecall_core_get_zuhause start");
1664 voicecall_core_get_zuhause(pcall_core->pcall_engine, &bzuhause);
1665 CALL_ENG_KPI("voicecall_core_get_zuhause done");
1667 if (bzuhause == TRUE) {
1668 CALL_ENG_DEBUG(ENG_DEBUG, "It's zuhause area! don't play connect tone!\n");
1672 CALL_ENG_KPI("get VCONFKEY_CISSAPPL_CALL_CONNECT_TONE_BOOL start");
1673 if (vconf_get_bool(VCONFKEY_CISSAPPL_CALL_CONNECT_TONE_BOOL, &bstatus)) {
1674 CALL_ENG_DEBUG(ENG_ERR, "vconf_get_bool failed.\n");
1676 CALL_ENG_KPI("get VCONFKEY_CISSAPPL_CALL_CONNECT_TONE_BOOL done");
1679 CALL_ENG_DEBUG(ENG_DEBUG, "Connect Tone Settings not enabled \n");
1683 /*First Reset the audio Path to PDA */
1684 voicecall_snd_change_mm_path(papp_snd, VOICE_CALL_MM_ALERT_TONE);
1686 error_code = mm_sound_play_sound(VOICE_CALL_SND_CONNECT_SIGNAL_PATH, VOLUME_TYPE_CALL, __voicecall_snd_effect_cb, papp_snd, &papp_snd->mmfsoundplay_handle);
1689 case VOICE_CALL_SND_EFFECT_CALL_DISCONNECT:
1692 if (vconf_get_bool(VCONFKEY_CISSAPPL_CALL_END_TONE_BOOL, &bstatus)) {
1693 CALL_ENG_DEBUG(ENG_ERR, "vconf_get_bool failed.\n");
1697 CALL_ENG_DEBUG(ENG_DEBUG, "Disconnect Tone Settings not enabled \n");
1701 voicecall_snd_change_mm_path(papp_snd, VOICE_CALL_MM_ALERT_TONE);
1703 error_code = mm_sound_play_sound(VOICE_CALL_SND_DISCONNECT_SIGNAL_PATH, VOLUME_TYPE_CALL, __voicecall_snd_effect_cb, papp_snd, &papp_snd->mmfsoundplay_handle);
1708 case VOICE_CALL_SND_EFFECT_CALL_MINUTE_MINDER:
1710 voicecall_snd_change_mm_path(papp_snd, VOICE_CALL_MM_ALERT_TONE);
1711 error_code = mm_sound_play_sound(VOICE_CALL_SND_MINUTE_MINDER_SIGNAL_PATH, VOLUME_TYPE_CALL, __voicecall_snd_effect_cb, papp_snd, &papp_snd->mmfsoundplay_handle);
1716 CALL_ENG_DEBUG(ENG_DEBUG, "Invalid Effect Type: %d \n", effect_type);
1720 if (MM_ERROR_NONE == error_code) {
1721 papp_snd->effect_tone_status = VOICE_CALL_SND_STATUS_PLAY;
1724 CALL_ENG_DEBUG(ENG_DEBUG, "error code = [0x%x] \n", error_code);
1725 return (MM_ERROR_NONE == error_code) ? TRUE : FALSE;
1728 gboolean voicecall_snd_is_effect_playing(voicecall_snd_mgr_t *papp_snd)
1730 CALL_ENG_DEBUG(ENG_ERR, "Effect tone status: %d\n", papp_snd->effect_tone_status);
1731 if (VOICE_CALL_SND_STATUS_PLAY == papp_snd->effect_tone_status) {
1738 void voicecall_snd_stop_effect_tone(voicecall_snd_mgr_t *papp_snd)
1740 CALL_ENG_DEBUG(ENG_ERR, "Effect tone status: %d\n", papp_snd->effect_tone_status);
1742 if (VOICE_CALL_SND_STATUS_PLAY == papp_snd->effect_tone_status) {
1743 if (MM_ERROR_NONE != mm_sound_stop_sound(papp_snd->mmfsoundplay_handle)) {
1744 CALL_ENG_DEBUG(ENG_ERR, "MM Stop Sound Failed \n");
1747 papp_snd->effect_tone_status = VOICE_CALL_SND_STATUS_NONE;
1748 papp_snd->mmfsoundplay_handle = VOICE_CALL_SND_INVALID_SND_HANDLE;
1750 CALL_ENG_DEBUG(ENG_ERR, "Effect tone status: %d\n", papp_snd->effect_tone_status);
1753 void voicecall_snd_set_to_defaults(voicecall_snd_mgr_t *papp_snd)
1755 call_vc_core_state_t *pcall_core = NULL;
1757 CALL_ENG_DEBUG(ENG_DEBUG, "papp_snd = %p \n", papp_snd);
1759 /*Backup core handle */
1760 pcall_core = (call_vc_core_state_t *)papp_snd->pcall_core;
1762 /*Reset Sound Magr Data */
1763 memset(papp_snd, 0, sizeof(voicecall_snd_mgr_t));
1765 /*Re Assign core handle */
1766 papp_snd->pcall_core = pcall_core;
1768 /*Set to Defaults */
1769 papp_snd->pmm_player = VOICE_CALL_SND_INVALID_PLAYER_HANDLE;
1770 papp_snd->pmm_signal_player = VOICE_CALL_SND_INVALID_SND_HANDLE;
1772 papp_snd->mmfsoundplay_handle = VOICE_CALL_SND_INVALID_SND_HANDLE;
1773 papp_snd->mmfalternateplay_handle = VOICE_CALL_SND_INVALID_SND_HANDLE;