Fixed the build error using gcc 13
[platform/core/messaging/msg-service.git] / manager / src / msg-manager-sound.cpp
1 /*
2  * Copyright (c) 2016 Samsung Electronics Co., Ltd. All rights reserved
3  *
4  * Licensed under the Apache License, Version 2.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
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15 */
16
17 /*==================================================================================================
18                                     INCLUDE FILES
19 ==================================================================================================*/
20
21 #include <stdlib.h>
22 #include <stdio.h>
23 #include <glib.h>
24 #include <sys/stat.h>
25 #include <unistd.h>
26
27 #include <player.h>
28 #include <recorder.h>
29 #include <sound_manager.h>
30 #include <feedback.h>
31 #include <feedback-internal.h>
32 #include <vconf.h>
33
34 #include <msg-manager-contact.h>
35 #include <msg-manager-debug.h>
36 #include <msg-manager-notification.h>
37 #include <msg-manager-sound.h>
38 #include <msg-manager-util.h>
39
40 /*==================================================================================================
41                                     DEFINES
42 ==================================================================================================*/
43
44 #define DEFAULT_ALERT_FILE              TZ_SYS_RO_APP_PATH "/" MSG_SETTING_APP_ID "shared/res/settings/Alerts/General notification_sdk.wav"
45
46 #define MSG_MGR_SOUND_TIMEOUT 5500
47
48
49 /*==================================================================================================
50                                      VARIABLES
51 ==================================================================================================*/
52 player_h g_PlayerHandle = NULL;
53 sound_stream_info_h g_stream_info = NULL;
54 char *defaultRingtonePath = NULL;
55 bool bFeedbackInit = false;
56 bool bPlaying = false;
57
58 pthread_mutex_t muMmPlay = PTHREAD_MUTEX_INITIALIZER;
59 pthread_mutex_t muStream = PTHREAD_MUTEX_INITIALIZER;
60
61 /*==================================================================================================
62                                                                                 FUNCTION DEFINE
63 ===================================================================================================*/
64 int MsgMgrGetFileSize(const char *pFileName);
65
66 int MsgMgrStreamStart(MSG_MGR_SOUND_TYPE_T soundType);
67 void MsgMgrStreamStop();
68 void MsgMgrGetPlayStatus(bool bOnCall, bool bSound, bool bVibration, bool bMsgSound, bool bMsgVibration, bool *bPlaySound, bool *bPlayVibration);
69
70 void MsgMgrSoundPlayMelody(char *pMsgToneFilePath);
71 void MsgMgrSoundPlayVibration();
72
73 /*==================================================================================================
74                                                                         FUNCTION IMPLEMENTATION
75 ==================================================================================================*/
76 int MsgMgrGetFileSize(const char *pFileName)
77 {
78         struct stat file_stat;
79
80         if (lstat(pFileName, &file_stat)) {
81                 MSG_MGR_FATAL("file[%s] error lstat: %s", pFileName, g_strerror(errno));
82                 return -1;
83         }
84
85         return (int)file_stat.st_size;
86 }
87
88
89 static void MsgMgrSoundPlayeErrorCallback(int error_code, void *user_data)
90 {
91         MSG_MGR_DEBUG("MsgMgrSoundPlayeErrorCallback called [%d]", error_code);
92         MsgMgrStreamStop();
93         MsgMgrSoundPlayStart(NULL, MSG_MGR_SOUND_PLAY_DEFAULT);
94 }
95
96 static void MsgMgrSoundPlayeCompletedCallback(void *user_data)
97 {
98         MSG_MGR_DEBUG("MsgMgrSoundPlayeCompletedCallback called");
99         MsgMgrSoundPlayStop();
100 }
101
102 static void MsgMgrSoundPlayeInterruptedCallback(player_interrupted_code_e code, void *user_data)
103 {
104         MSG_MGR_DEBUG("MsgMgrSoundPlayeInterruptedCallback called [%d]", code);
105         MsgMgrSoundPlayStop();
106 }
107
108 static void MsgStreamFocusCallback(sound_stream_info_h stream_info, sound_stream_focus_mask_e focus_mask, sound_stream_focus_state_e focus_state,
109                                    sound_stream_focus_change_reason_e reason_for_change, int sound_behavior, const char *additional_info, void *user_data)
110 {
111         MSG_MGR_DEBUG("MsgStreamFocusCallback called, reason_for_change [%d], additional_info [%s]", reason_for_change, additional_info);
112
113         if ((focus_mask == SOUND_STREAM_FOCUS_FOR_PLAYBACK) && (focus_state == SOUND_STREAM_FOCUS_STATE_RELEASED)) {
114                 MSG_MGR_DEBUG("sound stream focus released");
115                 MsgMgrSoundPlayStop();
116         }
117 }
118
119
120 void initMsgMgrSoundPlayer()
121 {
122         bPlaying = false;
123         bFeedbackInit = false;
124
125         defaultRingtonePath = vconf_get_str(VCONFKEY_SETAPPL_NOTI_RINGTONE_DEFAULT_PATH_STR);
126
127         if (defaultRingtonePath == NULL || MsgMgrGetFileSize(defaultRingtonePath) < 1) {
128                 free(defaultRingtonePath);
129                 defaultRingtonePath = NULL;
130                 defaultRingtonePath = (char *)DEFAULT_ALERT_FILE;
131         }
132
133         MSG_MGR_DEBUG("defaultRingtonePath [%s]", defaultRingtonePath);
134 }
135
136
137 void MsgMgrGetRingtonePath(char *userRingtonePath, char **msg_tone_file_path_p)
138 {
139         int tmpVal = 0;
140         if (vconf_get_int(MSG_SETTING_RINGTONE_TYPE, &tmpVal) != 0) {
141                 MSG_MGR_INFO("vcong_get_int() is failed");
142         }
143         int ringtoneType = tmpVal;
144
145         MSG_MGR_DEBUG("Ringtone type = [%d]", ringtoneType);
146
147         if (ringtoneType == MSG_RINGTONE_TYPE_SILENT) {
148                 *msg_tone_file_path_p = NULL;
149                 return;
150         }
151
152         char *tmpFilePath = NULL;
153         *msg_tone_file_path_p = new char[MSG_FILEPATH_LEN_MAX+1];
154
155         char *msg_tone_file_path = *msg_tone_file_path_p;
156
157         bool bUserRingtone = userRingtonePath && userRingtonePath[0] != '\0';
158         if (bUserRingtone) {
159                 tmpFilePath = userRingtonePath;
160         } else {
161                 if (ringtoneType == MSG_RINGTONE_TYPE_DEFAULT) {
162                         tmpFilePath = vconf_get_str(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR);
163                 } else {
164                         tmpFilePath = vconf_get_str(MSG_SETTING_RINGTONE_PATH);
165                 }
166         }
167
168         memset(msg_tone_file_path, 0x00, sizeof(char)*(MSG_FILEPATH_LEN_MAX+1));
169 #if 0 /* MSG_DRM_SUPPORT */
170         if ((tmpFilePath == NULL || MsgMgrGetFileSize(tmpFilePath) < 1) || /* wrong ringtone file path */
171                         (MsgDrmIsDrmFile(tmpFilePath) && !MsgDrmCheckRingtone(tmpFilePath))) { /* check DRM */
172 #endif
173         if ((tmpFilePath == NULL || MsgMgrGetFileSize(tmpFilePath) < 1)) { /* wrong ringtone file path */
174                 if (tmpFilePath && (strcmp(tmpFilePath, "silent") == 0)) {
175                         MSG_MGR_DEBUG("Set ringtone to NONE(Silent)");
176                         msg_tone_file_path = NULL;
177                 } else {
178                         MSG_MGR_DEBUG("Set ringtone to defaultRingtonePath.");
179                         if (defaultRingtonePath && defaultRingtonePath[0] != '\0') {
180                                 MSG_MGR_DEBUG("defaultRingtonePath [%s]", defaultRingtonePath);
181                                 snprintf(msg_tone_file_path, MSG_FILEPATH_LEN_MAX, "%s", defaultRingtonePath);
182                         } else {
183                                 MSG_MGR_DEBUG("defaultRingtonePath is null");
184                                 msg_tone_file_path = NULL;
185                         }
186                 }
187         } else {
188                 MSG_MGR_DEBUG("Set ringtone to tmpFilePath.");
189                 snprintf(msg_tone_file_path, MSG_FILEPATH_LEN_MAX, "%s", tmpFilePath);
190         }
191
192         if (tmpFilePath && !bUserRingtone) {
193                 free(tmpFilePath);
194                 tmpFilePath = NULL;
195         }
196 }
197
198 void MsgMgrGetPlayStatus(bool bVoiceMail, bool *bPlaySound, bool *bPlayVibration, bool *bOnCall)
199 {
200         MSG_MGR_BEGIN();
201
202         if (!bPlaySound || !bPlayVibration) {
203                 MSG_MGR_DEBUG("IN parameter is NULL.");
204                 return;
205         }
206
207         *bPlaySound = false;
208         *bPlayVibration = false;
209
210         /* Global setting */
211         int bSoundOn = 0; /* sound setting on notification panel */
212         int bVibrationOn = 0; /* vibration setting on notification panel */
213
214         if (vconf_get_bool(VCONFKEY_SETAPPL_SOUND_STATUS_BOOL, &bSoundOn) != 0)
215                 MSG_MGR_INFO("vconf_get_bool() is failed");
216
217         if (vconf_get_bool(VCONFKEY_SETAPPL_VIBRATION_STATUS_BOOL, &bVibrationOn) != 0)
218                 MSG_MGR_INFO("vconf_get_bool() is failed");
219
220         /* Alert setting */
221 #if 0   /* not used value */
222         int bNotiVibrationOn = 0; /* alert vibration */
223         if (vconf_get_bool(VCONFKEY_SETAPPL_VIBRATE_WHEN_NOTIFICATION_BOOL, &bNotiVibrationOn) != 0)
224                 MSG_MGR_INFO("vconf_get_bool() is failed");
225 #endif
226
227         int bMsgSettingNoti = 1; /* Alert for message notification */
228         int bMsgSettingVibration = 0; /* vibration for message notification */
229
230         int ringtoneType = MSG_RINGTONE_TYPE_DEFAULT; /*sound type for message notification */
231         bool bMsgSettingSound = true;
232
233         if (vconf_get_bool(MSG_SETTING_VIBRATION, &bMsgSettingVibration) != 0)
234                 MSG_MGR_INFO("vconf_get_bool() is failed");
235
236         if (vconf_get_bool(MSG_SETTING_NOTIFICATION, &bMsgSettingNoti) != 0)
237                 MSG_MGR_INFO("vconf_get_bool() is failed");
238
239         int tmpVal = 0;
240         if (vconf_get_int(MSG_SETTING_RINGTONE_TYPE, &tmpVal) != 0) {
241                 MSG_MGR_INFO("vconf_get_int() is failed");
242         }
243         ringtoneType = tmpVal;
244         if (ringtoneType == MSG_RINGTONE_TYPE_SILENT)
245                 bMsgSettingSound = false;
246
247         MSG_MGR_SEC_DEBUG("Sound status : Sound mode[%d], Manner mode[%d]", bSoundOn, bVibrationOn);
248         MSG_MGR_SEC_DEBUG("Msg Setting : Noti Alert[%d], vibration[%d], sound[%d], ringtoneType[%d]", bMsgSettingNoti, bMsgSettingVibration, bMsgSettingSound, ringtoneType);
249
250         cm_call_status_e callStatus = CM_CALL_STATUS_IDLE;
251 /*      int alertOnCall = 0; */
252
253         callStatus = MsgMgrGetCallStatus();
254         MSG_MGR_DEBUG("Call Status [%d]", callStatus);
255
256         /* Check call status */
257         if (callStatus > CM_CALL_STATUS_IDLE && callStatus < CM_CALL_STATUS_MAX) {
258                 /* 1. On Call */
259                 *bOnCall = true; /* set call status; */
260         } else {
261                 /* 2. Call is not active */
262                 MSG_MGR_DEBUG("Call is not active.");
263                 recorder_device_state_e recorderState = RECORDER_DEVICE_STATE_IDLE;
264                 int ret = recorder_get_device_state(RECORDER_TYPE_AUDIO, &recorderState);
265                 if (ret != 0)
266                         MSG_MGR_INFO("recorder_get_device_state() is failed [%d]", ret);
267
268                 if (bVoiceMail) {       /* 2-1. Voice message */
269                         if (bMsgSettingNoti) {
270                                 MsgMgrGetPlayStatus(false, bSoundOn, bVibrationOn, bMsgSettingSound, bMsgSettingVibration, bPlaySound, bPlayVibration);
271
272                         } else {
273                                 MSG_MGR_DEBUG("It doesn't play sound/vibration - voice message.");
274                         }
275                 } else {        /* 2-1. Normal message */
276                         if (bMsgSettingNoti) {
277                                 if (recorderState != RECORDER_DEVICE_STATE_RECORDING) {
278                                         MsgMgrGetPlayStatus(false, bSoundOn, bVibrationOn, bMsgSettingSound, bMsgSettingVibration, bPlaySound, bPlayVibration);
279                                 } else {
280                                         MSG_MGR_DEBUG("It doesn't play sound/vibration.");
281                                 }
282                         } else {
283                                 MSG_MGR_DEBUG("It doesn't play sound/vibration.");
284                         }
285                 }
286         }
287
288         MSG_MGR_END();
289 }
290
291
292 void MsgMgrGetPlayStatus(bool bOnCall, bool bSound, bool bVibration, bool bMsgSound, bool bMsgVibration, bool *bPlaySound, bool *bPlayVibration)
293 {
294         MSG_MGR_BEGIN();
295
296         /* samsung basic concept : feedback should follow profile setting.
297          * And if notification setting exist in msg app, then apply it prior to profile when profile either sound or vibration.
298          * But, Play sound when profile is vibration during call, if device does not support haptic */
299         if (bSound || bVibration) {
300                 bool bHantic_device = false;
301 #ifdef FEATURE_HAPTIC_ENABLE
302                 bHantic_device = true;
303 #endif
304                 if (bHantic_device || (bOnCall == false)) {
305                         if (bSound) {
306                                 if (bMsgSound) {
307                                         MSG_MGR_DEBUG("Play sound.");
308                                         *bPlaySound = true;
309                                 }
310
311                                 if (bMsgVibration) {
312                                         MSG_MGR_DEBUG("Play vibration.");
313                                         *bPlayVibration = true;
314                                 }
315                         } else {
316                                 if (bMsgVibration) {
317                                         MSG_MGR_DEBUG("Play vibration.");
318                                         *bPlayVibration = true;
319                                 }
320                         }
321                 } else { /* during call */
322                         if (bMsgSound || bMsgVibration) {
323                                 MSG_MGR_DEBUG("Play sound.");
324                                 *bPlaySound = true;
325                         }
326                 }
327         }
328
329         MSG_MGR_END();
330 }
331
332
333 void MsgMgrSoundPlayStart(const MSG_MGR_ADDRESS_INFO_S *pAddrInfo, MSG_MGR_SOUND_TYPE_T soundType)
334 {
335         MSG_MGR_BEGIN();
336
337         MSG_MGR_DEBUG("soundType [%d]", soundType);
338
339         /* check recorder state */
340         recorder_device_state_e recorderState = RECORDER_DEVICE_STATE_IDLE;
341         int ret = recorder_get_device_state(RECORDER_TYPE_VIDEO, &recorderState);
342         if (ret != 0)
343                 MSG_MGR_INFO("recorder_get_device_state() is failed [%d]", ret);
344
345         MSG_MGR_SEC_DEBUG("Recorder state [%d]", recorderState);
346
347         if (recorderState == RECORDER_DEVICE_STATE_RECORDING) {
348                 MSG_MGR_END();
349                 return;
350         }
351
352         MSG_MGR_CONTACT_INFO_S contactInfo = {0, };
353         if (pAddrInfo) {
354                 if (MsgMgrGetContactInfo(pAddrInfo, &contactInfo) != 0) {
355                         MSG_MGR_DEBUG("MsgGetContactInfo() fail.");
356                 }
357         }
358
359         /* get ringtone file path */
360         char *msg_tone_file_path = NULL;
361
362         if (soundType == MSG_MGR_SOUND_PLAY_EMERGENCY) {
363                 msg_tone_file_path = new char[MSG_FILEPATH_LEN_MAX+1];
364                 memset(msg_tone_file_path, 0x00, sizeof(char)*(MSG_FILEPATH_LEN_MAX+1));
365         } else if (soundType == MSG_MGR_SOUND_PLAY_DEFAULT) {
366                 msg_tone_file_path = new char[MSG_FILEPATH_LEN_MAX+1];
367                 memset(msg_tone_file_path, 0x00, sizeof(char)*(MSG_FILEPATH_LEN_MAX+1));
368                 snprintf(msg_tone_file_path, MSG_FILEPATH_LEN_MAX, "%s", DEFAULT_ALERT_FILE);
369         } else {
370                 MsgMgrGetRingtonePath(contactInfo.alerttonePath, &msg_tone_file_path);
371         }
372         MSG_MGR_SEC_DEBUG("soundType [%d], Sound File [%s]", soundType, msg_tone_file_path);
373
374         /* get sound play status */
375         bool bPlaySound = false;
376         bool bPlayVibration = false;
377         bool bVoiceMsg = (soundType == MSG_MGR_SOUND_PLAY_VOICEMAIL)?true:false;
378         bool bOnCall = false;
379
380         MsgMgrGetPlayStatus(bVoiceMsg, &bPlaySound, &bPlayVibration, &bOnCall);
381
382         MSG_MGR_SEC_DEBUG("sound=[%d], vibration=[%d], voice_msg?[%d], on_call?[%d]",
383                         bPlaySound, bPlayVibration, bVoiceMsg, bOnCall);
384
385         /* play sound */
386         if (bPlaySound) {
387                 int err = MsgMgrStreamStart(soundType);
388
389                 if (err != SOUND_MANAGER_ERROR_NONE)
390                         MSG_MGR_DEBUG("MsgMgrStreamStart() Failed : %d", err);
391                 else
392                         MsgMgrSoundPlayMelody(msg_tone_file_path);
393         }
394
395         if (bPlayVibration)
396                 MsgMgrSoundPlayVibration();
397
398         if (msg_tone_file_path)
399                 delete [] msg_tone_file_path;
400
401         MSG_MGR_END();
402 }
403
404
405 void MsgMgrSoundPlayStop()
406 {
407         MSG_MGR_BEGIN();
408
409         int err = 0;
410         pthread_mutex_lock(&muMmPlay);
411
412         if (bPlaying == true && g_PlayerHandle != NULL) {
413                 MSG_MGR_DEBUG("stopping the player.");
414                 /* Stop playing media contents */
415                 err = player_stop(g_PlayerHandle);
416
417                 if (err != PLAYER_ERROR_NONE)
418                         MSG_MGR_DEBUG("stopping the player handle failed");
419         }
420
421         if (g_PlayerHandle != NULL) {
422                 MSG_MGR_DEBUG("destroy the player.");
423
424                 player_unset_error_cb(g_PlayerHandle);
425                 player_unset_completed_cb(g_PlayerHandle);
426                 player_unset_interrupted_cb(g_PlayerHandle);
427                 player_unprepare(g_PlayerHandle);
428                 player_destroy(g_PlayerHandle);
429         }
430
431         g_PlayerHandle = NULL;
432         bPlaying = false;
433
434         pthread_mutex_unlock(&muMmPlay);
435
436         MsgMgrStreamStop();
437
438         MSG_MGR_END();
439 }
440
441
442 int MsgMgrStreamStart(MSG_MGR_SOUND_TYPE_T soundType)
443 {
444         MSG_MGR_BEGIN();
445         int err = 0;
446
447         pthread_mutex_lock(&muStream);
448
449         if (g_stream_info != NULL) {
450                 err = sound_manager_destroy_stream_information(g_stream_info);
451                 if (err != SOUND_MANAGER_ERROR_NONE)
452                         MSG_MGR_DEBUG("sound_manager_destroy_stream_information() Failed : %d", err);
453
454                 g_stream_info = NULL;
455         }
456
457         if (soundType == MSG_MGR_SOUND_PLAY_EMERGENCY)
458                 err = sound_manager_create_stream_information(SOUND_STREAM_TYPE_EMERGENCY, MsgStreamFocusCallback, NULL, &g_stream_info);
459         else
460                 err = sound_manager_create_stream_information(SOUND_STREAM_TYPE_NOTIFICATION, MsgStreamFocusCallback, NULL, &g_stream_info);
461
462         if (err != SOUND_MANAGER_ERROR_NONE) {
463                 MSG_MGR_DEBUG("sound_manager_create_stream_information() Failed : %d", err);
464                 pthread_mutex_unlock(&muStream);
465                 return err;
466         }
467
468         err = sound_manager_acquire_focus(g_stream_info, SOUND_STREAM_FOCUS_FOR_PLAYBACK, SOUND_BEHAVIOR_NONE, NULL);
469         pthread_mutex_unlock(&muStream);
470
471         MSG_MGR_END();
472         return err;
473 }
474
475
476 void MsgMgrStreamStop()
477 {
478         MSG_MGR_BEGIN();
479         pthread_mutex_lock(&muStream);
480
481         if (g_stream_info != NULL) {
482                 int err = sound_manager_release_focus(g_stream_info, SOUND_STREAM_FOCUS_FOR_PLAYBACK, SOUND_BEHAVIOR_NONE, NULL);
483                 if (err != SOUND_MANAGER_ERROR_NONE)
484                         MSG_MGR_DEBUG("sound_manager_release_focus() Failed : %d", err);
485
486                 err = sound_manager_destroy_stream_information(g_stream_info);
487                 if (err != SOUND_MANAGER_ERROR_NONE)
488                         MSG_MGR_DEBUG("sound_manager_destroy_stream_information() Failed : %d", err);
489
490                 g_stream_info = NULL;
491         }
492         pthread_mutex_unlock(&muStream);
493
494         MSG_MGR_END();
495 }
496
497
498 void MsgMgrSoundPlayMelody(char *pMsgToneFilePath)
499 {
500         int err = PLAYER_ERROR_NONE;
501
502         if (!pMsgToneFilePath) {
503                 MSG_MGR_DEBUG("Ringtone path is NULL");
504                 return;
505         }
506
507         pthread_mutex_lock(&muMmPlay);
508
509         if (g_stream_info == NULL) {
510                 MSG_MGR_DEBUG("g_stream_info is NULL");
511                 pthread_mutex_unlock(&muMmPlay);
512                 return;
513         }
514
515         if (g_PlayerHandle) {
516                 player_unset_error_cb(g_PlayerHandle);
517                 player_unset_completed_cb(g_PlayerHandle);
518                 player_unset_interrupted_cb(g_PlayerHandle);
519                 player_unprepare(g_PlayerHandle);
520                 player_destroy(g_PlayerHandle);
521         }
522
523         err = player_create(&g_PlayerHandle);
524
525         pthread_mutex_unlock(&muMmPlay);
526
527         if (err != PLAYER_ERROR_NONE) {
528                 MSG_MGR_DEBUG("creating the player handle failed");
529                 return;
530         }
531
532         /* Setting the call back function msg_callback */
533         player_set_error_cb(g_PlayerHandle, MsgMgrSoundPlayeErrorCallback, NULL);
534         player_set_completed_cb(g_PlayerHandle, MsgMgrSoundPlayeCompletedCallback, NULL);
535         player_set_interrupted_cb(g_PlayerHandle, MsgMgrSoundPlayeInterruptedCallback, NULL);
536
537         player_set_sound_stream_info(g_PlayerHandle, g_stream_info);
538
539         do {
540                 err = player_set_uri(g_PlayerHandle, (const char *)pMsgToneFilePath);
541                 if (err != PLAYER_ERROR_NONE)
542                         MSG_MGR_DEBUG("player_set_uri() error : [%d]", err);
543
544                 err = player_prepare(g_PlayerHandle);
545                 if (err != PLAYER_ERROR_NONE) {
546                         MSG_MGR_DEBUG("player_prepare() error : [%d]", err);
547                         if (pMsgToneFilePath != defaultRingtonePath) {
548                                 pMsgToneFilePath = defaultRingtonePath;
549                         } else {
550                                 return;
551                         }
552                 }
553         } while (err != PLAYER_ERROR_NONE);
554
555
556         pthread_mutex_lock(&muMmPlay);
557         MSG_MGR_DEBUG("player_start with [%s]", pMsgToneFilePath);
558         err = player_start(g_PlayerHandle);
559
560         if (err != PLAYER_ERROR_NONE) {
561                 MSG_MGR_DEBUG("player_start, FAIL [%x]", err);
562         } else {
563                 /* Add Timer to stop playing after 5 sec. */
564                 /*
565                 int g_contact_timer = -1;
566                 g_contact_timer = g_timeout_add(MSG_MGR_SOUND_TIMEOUT, (GSourceFunc)MsgSoundMelodyTimeout, NULL);
567                 */
568
569                 bPlaying = true;
570         }
571         pthread_mutex_unlock(&muMmPlay);
572 }
573
574
575 void MsgMgrSoundPlayVibration()
576 {
577         MSG_MGR_BEGIN();
578
579         int ret = 0;
580
581         if (!bFeedbackInit) {
582                 int ret = feedback_initialize();
583
584                 if (ret != FEEDBACK_ERROR_NONE) {
585                         MSG_MGR_DEBUG("Fail to feedback_initialize : [%d]", ret);
586                         bFeedbackInit = false;
587                         return;
588                 } else {
589                         MSG_MGR_DEBUG("Success to feedback_initialize.");
590                         bFeedbackInit = true;
591                 }
592         }
593
594 #if 1
595         ret = feedback_play_type(FEEDBACK_TYPE_VIBRATION, FEEDBACK_PATTERN_MESSAGE);
596         if (ret != FEEDBACK_ERROR_NONE)
597                 MSG_MGR_DEBUG("Fail to feedback_play_type");
598 #else
599         if (vibrationPath && strlen(vibrationPath)) {
600                 MSG_MGR_DEBUG("vibrationPath: [%s]", vibrationPath);
601                 ret = feedback_set_resource_path(FEEDBACK_TYPE_VIBRATION, FEEDBACK_PATTERN_MESSAGE, vibrationPath);
602                 if (ret != FEEDBACK_ERROR_NONE)
603                         MSG_MGR_DEBUG("Fail to feedback_set_resource_path");
604                 ret = feedback_play_type(FEEDBACK_TYPE_VIBRATION, FEEDBACK_PATTERN_MESSAGE);
605
606                 if (ret != FEEDBACK_ERROR_NONE)
607                         MSG_MGR_DEBUG("Fail to feedback_play_type");
608         } else {
609                 ret = feedback_set_resource_path(FEEDBACK_TYPE_VIBRATION, FEEDBACK_PATTERN_MESSAGE, NULL);
610                 if (ret != FEEDBACK_ERROR_NONE)
611                         MSG_MGR_DEBUG("Fail to feedback_set_resource_path");
612
613                 ret = feedback_play_type(FEEDBACK_TYPE_VIBRATION, FEEDBACK_PATTERN_MESSAGE);
614                 if (ret != FEEDBACK_ERROR_NONE)
615                         MSG_MGR_DEBUG("Fail to feedback_play_type");
616         }
617 #endif
618         MSG_MGR_END();
619 }